mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix chat background transition
This commit is contained in:
parent
f6f110fde9
commit
e447b8e7a4
@ -195,6 +195,7 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
private final var lastContentOffset: CGPoint = CGPoint()
|
||||
private final var lastContentOffsetTimestamp: CFAbsoluteTime = 0.0
|
||||
private final var ignoreScrollingEvents: Bool = false
|
||||
public final var globalIgnoreScrollingEvents: Bool = false
|
||||
|
||||
private let infiniteScrollSize: CGFloat
|
||||
|
||||
@ -939,6 +940,9 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture
|
||||
if self.ignoreScrollingEvents || scroller !== self.scroller {
|
||||
return
|
||||
}
|
||||
if self.globalIgnoreScrollingEvents {
|
||||
return
|
||||
}
|
||||
|
||||
/*let timestamp = CACurrentMediaTime()
|
||||
if !self.previousDidScrollTimestamp.isZero {
|
||||
|
@ -3440,6 +3440,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
}
|
||||
|
||||
final class SnapshotState {
|
||||
let backgroundNode: WallpaperBackgroundNode
|
||||
fileprivate let historySnapshotState: ChatHistoryListNode.SnapshotState
|
||||
let titleViewSnapshotState: ChatTitleView.SnapshotState?
|
||||
let avatarSnapshotState: ChatAvatarNavigationNode.SnapshotState?
|
||||
@ -3450,6 +3451,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
let inputPanelOverscrollNodeSnapshot: UIView?
|
||||
|
||||
fileprivate init(
|
||||
backgroundNode: WallpaperBackgroundNode,
|
||||
historySnapshotState: ChatHistoryListNode.SnapshotState,
|
||||
titleViewSnapshotState: ChatTitleView.SnapshotState?,
|
||||
avatarSnapshotState: ChatAvatarNavigationNode.SnapshotState?,
|
||||
@ -3459,6 +3461,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
inputPanelNodeSnapshot: UIView?,
|
||||
inputPanelOverscrollNodeSnapshot: UIView?
|
||||
) {
|
||||
self.backgroundNode = backgroundNode
|
||||
self.historySnapshotState = historySnapshotState
|
||||
self.titleViewSnapshotState = titleViewSnapshotState
|
||||
self.avatarSnapshotState = avatarSnapshotState
|
||||
@ -3490,6 +3493,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
inputPanelOverscrollNodeSnapshot = snapshot
|
||||
}
|
||||
return SnapshotState(
|
||||
backgroundNode: self.backgroundNode,
|
||||
historySnapshotState: self.historyNode.prepareSnapshotState(),
|
||||
titleViewSnapshotState: titleViewSnapshotState,
|
||||
avatarSnapshotState: avatarSnapshotState,
|
||||
@ -3502,7 +3506,14 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
||||
}
|
||||
|
||||
func animateFromSnapshot(_ snapshotState: SnapshotState, completion: @escaping () -> Void) {
|
||||
self.historyNode.animateFromSnapshot(snapshotState.historySnapshotState, completion: completion)
|
||||
let previousBackgroundNode = snapshotState.backgroundNode
|
||||
self.backgroundNode.supernode?.insertSubnode(previousBackgroundNode, belowSubnode: self.backgroundNode)
|
||||
|
||||
self.historyNode.animateFromSnapshot(snapshotState.historySnapshotState, completion: { [weak previousBackgroundNode] in
|
||||
previousBackgroundNode?.removeFromSupernode()
|
||||
|
||||
completion()
|
||||
})
|
||||
self.navigateButtons.animateFromSnapshot(snapshotState.navigationButtonsSnapshotState)
|
||||
|
||||
if let titleAccessoryPanelSnapshot = snapshotState.titleAccessoryPanelSnapshot {
|
||||
|
@ -3779,15 +3779,16 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
||||
}
|
||||
}
|
||||
|
||||
let snapshotView = self.view.snapshotView(afterScreenUpdates: false)!
|
||||
let snapshotView = self.view//.snapshotView(afterScreenUpdates: false)!
|
||||
self.globalIgnoreScrollingEvents = true
|
||||
|
||||
snapshotView.frame = self.view.bounds
|
||||
if let sublayers = self.layer.sublayers {
|
||||
//snapshotView.frame = self.view.bounds
|
||||
/*if let sublayers = self.layer.sublayers {
|
||||
for sublayer in sublayers {
|
||||
sublayer.isHidden = true
|
||||
}
|
||||
}
|
||||
self.view.addSubview(snapshotView)
|
||||
}*/
|
||||
//self.view.addSubview(snapshotView)
|
||||
|
||||
let overscrollView = self.overscrollView
|
||||
if let overscrollView = overscrollView {
|
||||
@ -3825,6 +3826,10 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
|
||||
snapshotParentView.frame = self.view.frame
|
||||
|
||||
snapshotState.snapshotView.frame = snapshotParentView.bounds
|
||||
|
||||
snapshotState.snapshotView.clipsToBounds = true
|
||||
snapshotState.snapshotView.layer.sublayerTransform = CATransform3DMakeRotation(CGFloat.pi, 0.0, 0.0, 1.0)
|
||||
|
||||
self.view.superview?.insertSubview(snapshotParentView, belowSubview: self.view)
|
||||
|
||||
snapshotParentView.layer.animatePosition(from: CGPoint(x: 0.0, y: 0.0), to: CGPoint(x: 0.0, y: -self.view.bounds.height - snapshotState.snapshotBottomInset - snapshotTopInset), duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, additive: true, completion: { [weak snapshotParentView] _ in
|
||||
|
Loading…
x
Reference in New Issue
Block a user