mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
a668ad006d
commit
50625dd5fe
@ -1648,7 +1648,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
self.loadingNode.updateLayout(size: contentBounds.size, insets: visibleAreaInset, transition: transition)
|
||||
|
||||
if let loadingPlaceholderNode = self.loadingPlaceholderNode {
|
||||
loadingPlaceholderNode.updateLayout(size: contentBounds.size, insets: visibleAreaInset, transition: transition)
|
||||
loadingPlaceholderNode.updateLayout(size: contentBounds.size, insets: visibleAreaInset, metrics: layout.metrics, transition: transition)
|
||||
loadingPlaceholderNode.update(rect: contentBounds, within: contentBounds.size, transition: transition)
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode {
|
||||
|
||||
private var absolutePosition: (CGRect, CGSize)?
|
||||
|
||||
private var validLayout: (CGSize, UIEdgeInsets)?
|
||||
private var validLayout: (CGSize, UIEdgeInsets, LayoutMetrics)?
|
||||
|
||||
init(context: AccountContext, theme: PresentationTheme, chatWallpaper: TelegramWallpaper, bubbleCorners: PresentationChatBubbleCorners, backgroundNode: WallpaperBackgroundNode) {
|
||||
self.context = context
|
||||
@ -280,7 +280,7 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
func animateOut(_ historyNode: ChatHistoryNode, completion: @escaping () -> Void = {}) {
|
||||
guard let listNode = historyNode as? ListView, let (size, _) = self.validLayout else {
|
||||
guard let listNode = historyNode as? ListView, let (size, _, _) = self.validLayout else {
|
||||
return
|
||||
}
|
||||
|
||||
@ -408,14 +408,14 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode {
|
||||
|
||||
if self.chatType != chatType {
|
||||
self.chatType = chatType
|
||||
if let (size, insets) = self.validLayout {
|
||||
self.updateLayout(size: size, insets: insets, transition: .immediate)
|
||||
if let (size, insets, metrics) = self.validLayout {
|
||||
self.updateLayout(size: size, insets: insets, metrics: metrics, transition: .immediate)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, transition: ContainedViewLayoutTransition) {
|
||||
self.validLayout = (size, insets)
|
||||
func updateLayout(size: CGSize, insets: UIEdgeInsets, metrics: LayoutMetrics, transition: ContainedViewLayoutTransition) {
|
||||
self.validLayout = (size, insets, metrics)
|
||||
|
||||
let bounds = CGRect(origin: .zero, size: size)
|
||||
|
||||
@ -435,22 +435,27 @@ final class ChatLoadingPlaceholderNode: ASDisplayNode {
|
||||
|
||||
let shortHeight: CGFloat = 71.0
|
||||
let tallHeight: CGFloat = 93.0
|
||||
|
||||
var width = size.width
|
||||
if case .regular = metrics.widthClass, abs(size.width - size.height) < 0.2 * size.height {
|
||||
width *= 0.7
|
||||
}
|
||||
|
||||
let dimensions: [CGSize] = [
|
||||
CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.69 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * size.width), height: shortHeight),
|
||||
CGSize(width: floorToScreenPixels(0.36 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.36 * size.width), height: shortHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.69 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.36 * size.width), height: shortHeight),
|
||||
CGSize(width: floorToScreenPixels(0.47 * size.width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * size.width), height: tallHeight)
|
||||
CGSize(width: floorToScreenPixels(0.47 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.69 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.47 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * width), height: shortHeight),
|
||||
CGSize(width: floorToScreenPixels(0.36 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.47 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.36 * width), height: shortHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.69 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.36 * width), height: shortHeight),
|
||||
CGSize(width: floorToScreenPixels(0.47 * width), height: tallHeight),
|
||||
CGSize(width: floorToScreenPixels(0.58 * width), height: tallHeight)
|
||||
].map {
|
||||
if self.chatType == .channel {
|
||||
return CGSize(width: floor($0.width * 1.3), height: floor($0.height * 1.8))
|
||||
|
@ -3095,7 +3095,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
|
||||
let titleLockOffset: CGFloat = 7.0 + singleTitleLockOffset
|
||||
let titleMaxLockOffset: CGFloat = 7.0
|
||||
var titleCollapseOffset = titleFrame.midY - statusBarHeight - titleLockOffset
|
||||
if case .regular = metrics.widthClass {
|
||||
if case .regular = metrics.widthClass, !isSettings {
|
||||
titleCollapseOffset -= 7.0
|
||||
}
|
||||
let titleOffset = -min(titleCollapseOffset, contentOffset)
|
||||
|
@ -9,7 +9,6 @@ import TelegramAudio
|
||||
import AccountContext
|
||||
import TelegramUniversalVideoContent
|
||||
import DeviceProximity
|
||||
import RaiseToListen
|
||||
|
||||
private enum SharedMediaPlaybackItem: Equatable {
|
||||
case audio(MediaPlayer)
|
||||
@ -121,9 +120,7 @@ final class SharedMediaPlayer {
|
||||
|
||||
private var playbackRate: AudioPlaybackRate
|
||||
|
||||
//private var proximityManagerIndex: Int?
|
||||
private var raiseToListen: RaiseToListenManager?
|
||||
|
||||
private var proximityManagerIndex: Int?
|
||||
private let controlPlaybackWithProximity: Bool
|
||||
private var forceAudioToSpeaker = false
|
||||
|
||||
@ -353,10 +350,9 @@ final class SharedMediaPlayer {
|
||||
} else {
|
||||
strongSelf.playbackStateValue.set(.single(nil))
|
||||
if !state.loading {
|
||||
strongSelf.raiseToListen = nil
|
||||
// if let proximityManagerIndex = strongSelf.proximityManagerIndex {
|
||||
// DeviceProximityManager.shared().remove(proximityManagerIndex)
|
||||
// }
|
||||
if let proximityManagerIndex = strongSelf.proximityManagerIndex {
|
||||
DeviceProximityManager.shared().remove(proximityManagerIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -370,44 +366,18 @@ final class SharedMediaPlayer {
|
||||
})
|
||||
|
||||
if controlPlaybackWithProximity {
|
||||
self.raiseToListen = RaiseToListenManager(shouldActivate: {
|
||||
return true
|
||||
}, activate: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
let forceAudioToSpeaker = false
|
||||
if strongSelf.forceAudioToSpeaker != forceAudioToSpeaker {
|
||||
strongSelf.forceAudioToSpeaker = forceAudioToSpeaker
|
||||
strongSelf.playbackItem?.setForceAudioToSpeaker(forceAudioToSpeaker)
|
||||
if !forceAudioToSpeaker {
|
||||
strongSelf.control(.playback(.play))
|
||||
}
|
||||
self.proximityManagerIndex = DeviceProximityManager.shared().add { [weak self] value in
|
||||
let forceAudioToSpeaker = !value
|
||||
if let strongSelf = self, strongSelf.forceAudioToSpeaker != forceAudioToSpeaker {
|
||||
strongSelf.forceAudioToSpeaker = forceAudioToSpeaker
|
||||
strongSelf.playbackItem?.setForceAudioToSpeaker(forceAudioToSpeaker)
|
||||
if !forceAudioToSpeaker {
|
||||
strongSelf.control(.playback(.play))
|
||||
} else {
|
||||
strongSelf.control(.playback(.pause))
|
||||
}
|
||||
}
|
||||
}, deactivate: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
let forceAudioToSpeaker = true
|
||||
if strongSelf.forceAudioToSpeaker != forceAudioToSpeaker {
|
||||
strongSelf.forceAudioToSpeaker = forceAudioToSpeaker
|
||||
strongSelf.playbackItem?.setForceAudioToSpeaker(forceAudioToSpeaker)
|
||||
if forceAudioToSpeaker {
|
||||
strongSelf.control(.playback(.pause))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
self.raiseToListen?.enabled = true
|
||||
// self.proximityManagerIndex = DeviceProximityManager.shared().add { [weak self] value in
|
||||
// let forceAudioToSpeaker = !value
|
||||
// if let strongSelf = self, strongSelf.forceAudioToSpeaker != forceAudioToSpeaker {
|
||||
// strongSelf.forceAudioToSpeaker = forceAudioToSpeaker
|
||||
// strongSelf.playbackItem?.setForceAudioToSpeaker(forceAudioToSpeaker)
|
||||
// if !forceAudioToSpeaker {
|
||||
// strongSelf.control(.playback(.play))
|
||||
// } else {
|
||||
// strongSelf.control(.playback(.pause))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,9 +388,9 @@ final class SharedMediaPlayer {
|
||||
self.playbackStateValueDisposable?.dispose()
|
||||
self.prefetchDisposable.dispose()
|
||||
|
||||
// if let proximityManagerIndex = self.proximityManagerIndex {
|
||||
// DeviceProximityManager.shared().remove(proximityManagerIndex)
|
||||
// }
|
||||
if let proximityManagerIndex = self.proximityManagerIndex {
|
||||
DeviceProximityManager.shared().remove(proximityManagerIndex)
|
||||
}
|
||||
|
||||
if let playbackItem = self.playbackItem {
|
||||
switch playbackItem {
|
||||
|
Loading…
x
Reference in New Issue
Block a user