Channel navigation improvements

This commit is contained in:
Ali 2021-08-29 19:10:33 +04:00
parent 235934ae8a
commit 03c0477d21
4 changed files with 44 additions and 19 deletions

View File

@ -54,15 +54,15 @@ final class ChatAvatarNavigationNode: ASDisplayNode {
}
final class SnapshotState {
fileprivate let snapshotView: UIView
fileprivate let snapshotView: UIView?
fileprivate init(snapshotView: UIView) {
fileprivate init(snapshotView: UIView?) {
self.snapshotView = snapshotView
}
}
func prepareSnapshotState() -> SnapshotState {
let snapshotView = self.avatarNode.view.snapshotView(afterScreenUpdates: false)!
let snapshotView = self.avatarNode.view.snapshotView(afterScreenUpdates: false)
return SnapshotState(
snapshotView: snapshotView
)
@ -72,13 +72,14 @@ final class ChatAvatarNavigationNode: ASDisplayNode {
self.avatarNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
self.avatarNode.layer.animateScale(from: 0.1, to: 1.0, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: true)
snapshotState.snapshotView.frame = self.frame
self.containerNode.view.addSubview(snapshotState.snapshotView)
if let snapshotView = snapshotState.snapshotView {
snapshotView.frame = self.frame
self.containerNode.view.addSubview(snapshotView)
let snapshotView = snapshotState.snapshotView
snapshotState.snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshotView] _ in
snapshotView?.removeFromSuperview()
})
snapshotView.layer.animateScale(from: 1.0, to: 0.1, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak snapshotView] _ in
snapshotView?.removeFromSuperview()
})
snapshotView.layer.animateScale(from: 1.0, to: 0.1, duration: 0.5, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
}
}
}

View File

@ -7457,9 +7457,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
nextFolderId = nil
}
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer.id), animated: false, chatListFilter: nextFolderId, completion: { nextController in
(nextController as! ChatControllerImpl).animateFromPreviousController(snapshotState: snapshotState)
}))
//Queue.mainQueue().after(1.0, {
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(peer.id), animated: false, chatListFilter: nextFolderId, completion: { nextController in
(nextController as! ChatControllerImpl).animateFromPreviousController(snapshotState: snapshotState)
}))
//})
}
}

View File

@ -2585,6 +2585,12 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
}
var shouldAllowOverscrollActions: Bool {
if let inputHeight = self.validLayout?.0.inputHeight, inputHeight > 0.0 {
return false
}
if self.chatPresentationInterfaceState.inputTextPanelState.mediaRecordingState != nil {
return false
}
if let inputPanelNode = self.inputPanelNode as? ChatTextInputPanelNode {
if inputPanelNode.isFocused {
return false

View File

@ -2555,15 +2555,18 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
fileprivate let snapshotTopInset: CGFloat
fileprivate let snapshotBottomInset: CGFloat
fileprivate let snapshotView: UIView
fileprivate let overscrollView: UIView?
fileprivate init(
snapshotTopInset: CGFloat,
snapshotBottomInset: CGFloat,
snapshotView: UIView
snapshotView: UIView,
overscrollView: UIView?
) {
self.snapshotTopInset = snapshotTopInset
self.snapshotBottomInset = snapshotBottomInset
self.snapshotView = snapshotView
self.overscrollView = overscrollView
}
}
@ -2578,21 +2581,34 @@ public final class ChatHistoryListNode: ListView, ChatHistoryNode {
snapshotBottomInset = max(snapshotBottomInset, -itemNode.frame.minY)
}
}
let snapshotView = self.view.snapshotView(afterScreenUpdates: false)!
let currentSnapshotView = self.view.snapshotView(afterScreenUpdates: false)!
currentSnapshotView.frame = self.view.bounds
let overscrollView = self.overscrollView
self.overscrollView = nil
if let overscrollView = overscrollView {
self.view.superview?.insertSubview(overscrollView, aboveSubview: self.view)
}
let snapshotView = self.view.snapshotView(afterScreenUpdates: true)!
snapshotView.frame = self.view.bounds
if let sublayers = self.layer.sublayers {
for sublayer in sublayers {
sublayer.isHidden = true
}
}
self.view.addSubview(currentSnapshotView)
self.view.addSubview(snapshotView)
if let overscrollView = overscrollView {
overscrollView.alpha = 1.0
snapshotView.addSubview(overscrollView)
}
return SnapshotState(
snapshotTopInset: snapshotTopInset,
snapshotBottomInset: snapshotBottomInset,
snapshotView: snapshotView
snapshotView: snapshotView,
overscrollView: overscrollView
)
}