Various fixes

This commit is contained in:
Ilya Laktyushin 2024-10-11 21:51:06 +04:00
parent ea3ad1ae8e
commit 5f81995c63
5 changed files with 28 additions and 12 deletions

View File

@ -443,6 +443,7 @@ final class CallListControllerNode: ASDisplayNode {
}
let previousView = Atomic<CallListNodeView?>(value: nil)
let previousType = Atomic<EngineCallList.Scope?>(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)
}

View File

@ -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 {

View File

@ -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()
}
}
}

View File

@ -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 {

View File

@ -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))
}
}