diff --git a/submodules/CallListUI/Sources/CallListControllerNode.swift b/submodules/CallListUI/Sources/CallListControllerNode.swift index 937fb4f4d0..6179e2bf82 100644 --- a/submodules/CallListUI/Sources/CallListControllerNode.swift +++ b/submodules/CallListUI/Sources/CallListControllerNode.swift @@ -443,6 +443,7 @@ final class CallListControllerNode: ASDisplayNode { } let previousView = Atomic(value: nil) + let previousType = Atomic(value: nil) let showSettings: Bool switch mode { @@ -505,7 +506,8 @@ final class CallListControllerNode: ASDisplayNode { let processedView = CallListNodeView(originalView: update.view, filteredEntries: callListNodeEntriesForView(view: update.view, groupCalls: groupCalls, state: state, showSettings: showSettings, showCallsTab: showCallsTab, isRecentCalls: type == .all, currentGroupCallPeerId: currentGroupCallPeerId), presentationData: state.presentationData) let previous = previousView.swap(processedView) - + let previousType = previousType.swap(type) + let reason: CallListNodeViewTransitionReason var prepareOnMainQueue = false @@ -565,8 +567,12 @@ final class CallListControllerNode: ASDisplayNode { } } } + var scrollPosition = update.scrollPosition + if previousType != type { + scrollPosition = .top(animated: false) + } - return preparedCallListNodeViewTransition(from: previous, to: processedView, reason: reason, disableAnimations: disableAnimations, context: context, scrollPosition: update.scrollPosition) + return preparedCallListNodeViewTransition(from: previous, to: processedView, reason: reason, disableAnimations: disableAnimations, context: context, scrollPosition: scrollPosition) |> map({ mappedCallListNodeViewListTransition(context: context, presentationData: state.presentationData, showSettings: showSettings, nodeInteraction: nodeInteraction, transition: $0) }) |> runOn(prepareOnMainQueue ? Queue.mainQueue() : viewProcessingQueue) } diff --git a/submodules/CallListUI/Sources/CallListViewTransition.swift b/submodules/CallListUI/Sources/CallListViewTransition.swift index 27c8725318..3925952182 100644 --- a/submodules/CallListUI/Sources/CallListViewTransition.swift +++ b/submodules/CallListUI/Sources/CallListViewTransition.swift @@ -45,6 +45,7 @@ struct CallListNodeViewTransition { } enum CallListNodeViewScrollPosition { + case top(animated: Bool) case index(index: EngineMessage.Index, position: ListViewScrollPosition, directionHint: ListViewScrollToItemDirectionHint, animated: Bool) } @@ -135,6 +136,8 @@ func preparedCallListNodeViewTransition(from fromView: CallListNodeView?, to toV if let scrollPosition = scrollPosition { switch scrollPosition { + case let .top(animated): + scrollToItem = ListViewScrollToItem(index: 0, position: .top(0.0), animated: animated, curve: .Default(duration: nil), directionHint: .Up) case let .index(scrollIndex, position, directionHint, animated): var index = toView.filteredEntries.count - 1 for entry in toView.filteredEntries { diff --git a/submodules/TabBarUI/Sources/TabBarContollerNode.swift b/submodules/TabBarUI/Sources/TabBarContollerNode.swift index 118dbb51b5..d0b8d37680 100644 --- a/submodules/TabBarUI/Sources/TabBarContollerNode.swift +++ b/submodules/TabBarUI/Sources/TabBarContollerNode.swift @@ -35,8 +35,10 @@ final class TabBarControllerNode: ASDisplayNode { } } - return { [weak previousNode] in - previousNode?.removeFromSupernode() + return { [weak self, weak previousNode] in + if previousNode !== self?.currentControllerNode { + previousNode?.removeFromSupernode() + } } } diff --git a/submodules/TabBarUI/Sources/TabBarController.swift b/submodules/TabBarUI/Sources/TabBarController.swift index 55af39e871..d614adeeec 100644 --- a/submodules/TabBarUI/Sources/TabBarController.swift +++ b/submodules/TabBarUI/Sources/TabBarController.swift @@ -373,8 +373,10 @@ open class TabBarControllerImpl: ViewController, TabBarController { //self.tabBarControllerNode.currentControllerNode = nil if animated { - currentController.view.layer.animateScale(from: 1.0, to: transitionSale, duration: 0.15, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { _ in - currentController.view.layer.removeAllAnimations() + currentController.view.layer.animateScale(from: 1.0, to: transitionSale, duration: 0.15, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, completion: { completed in + if completed { + currentController.view.layer.removeAllAnimations() + } }) } currentController.removeFromParent() @@ -395,8 +397,10 @@ open class TabBarControllerImpl: ViewController, TabBarController { if animated { currentController.view.layer.animateScale(from: transitionSale, to: 1.0, duration: 0.15, delay: 0.15, timingFunction: kCAMediaTimingFunctionSpring) currentController.view.layer.allowsGroupOpacity = true - currentController.view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15, completion: { _ in - currentController.view.layer.allowsGroupOpacity = false + currentController.view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15, completion: { completed in + if completed { + currentController.view.layer.allowsGroupOpacity = false + } commit() }) } else { diff --git a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift index 1793c5f6fb..f6e23c1cd9 100644 --- a/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift +++ b/submodules/TelegramUI/Components/PeerInfo/PeerInfoScreen/Sources/PeerInfoHeaderNode.swift @@ -2106,7 +2106,8 @@ final class PeerInfoHeaderNode: ASDisplayNode { navigationTransition.updateAlpha(node: self.buttonsContainerNode, alpha: backgroundBannerAlpha) - let bannerFrame = CGRect(origin: CGPoint(x: 0.0, y: -2000.0 + apparentBackgroundHeight), size: CGSize(width: width, height: 2000.0)) + let bannerInset: CGFloat = 3.0 + let bannerFrame = CGRect(origin: CGPoint(x: -bannerInset, y: -2000.0 + apparentBackgroundHeight), size: CGSize(width: width + bannerInset * 2.0, height: 2000.0)) if additive { transition.updateFrameAdditive(view: self.backgroundBannerView, frame: bannerFrame) @@ -2128,16 +2129,16 @@ final class PeerInfoHeaderNode: ASDisplayNode { patternTransitionFraction: buttonsTransitionFraction * backgroundTransitionFraction )), environment: {}, - containerSize: CGSize(width: width, height: apparentBackgroundHeight) + containerSize: CGSize(width: width + bannerInset * 2.0, height: apparentBackgroundHeight + bannerInset) ) if let backgroundCoverView = self.backgroundCover.view { if backgroundCoverView.superview == nil { self.backgroundBannerView.addSubview(backgroundCoverView) } if additive { - transition.updateFrameAdditive(view: backgroundCoverView, frame: CGRect(origin: CGPoint(x: 0.0, y: bannerFrame.height - backgroundCoverSize.height), size: backgroundCoverSize)) + transition.updateFrameAdditive(view: backgroundCoverView, frame: CGRect(origin: CGPoint(x: -3.0, y: bannerFrame.height - backgroundCoverSize.height - bannerInset), size: backgroundCoverSize)) } else { - transition.updateFrame(view: backgroundCoverView, frame: CGRect(origin: CGPoint(x: 0.0, y: bannerFrame.height - backgroundCoverSize.height), size: backgroundCoverSize)) + transition.updateFrame(view: backgroundCoverView, frame: CGRect(origin: CGPoint(x: 0.0, y: bannerFrame.height - backgroundCoverSize.height - bannerInset), size: backgroundCoverSize)) } }