This commit is contained in:
Ilya Laktyushin 2024-04-08 15:18:16 +04:00
parent 2e38e21c9a
commit 30d31c42c6

View File

@ -325,13 +325,17 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
strongSelf.navigationItem.titleView = nil strongSelf.navigationItem.titleView = nil
strongSelf.segmentedTitleView = nil strongSelf.segmentedTitleView = nil
strongSelf.navigationBar?.setContentNode(nil, animated: false) strongSelf.navigationBar?.setContentNode(nil, animated: false)
strongSelf.controllerNode.panRecognizer?.isEnabled = false if strongSelf.isNodeLoaded {
strongSelf.controllerNode.panRecognizer?.isEnabled = false
}
case let .textWithSubtitle(title, subtitle): case let .textWithSubtitle(title, subtitle):
strongSelf.title = "" strongSelf.title = ""
strongSelf.controllerNode.panRecognizer?.isEnabled = false
strongSelf.navigationItem.titleView = ItemListTextWithSubtitleTitleView(theme: controllerState.presentationData.theme, title: title, subtitle: subtitle) strongSelf.navigationItem.titleView = ItemListTextWithSubtitleTitleView(theme: controllerState.presentationData.theme, title: title, subtitle: subtitle)
strongSelf.segmentedTitleView = nil strongSelf.segmentedTitleView = nil
strongSelf.navigationBar?.setContentNode(nil, animated: false) strongSelf.navigationBar?.setContentNode(nil, animated: false)
if strongSelf.isNodeLoaded {
strongSelf.controllerNode.panRecognizer?.isEnabled = false
}
case let .sectionControl(sections, index): case let .sectionControl(sections, index):
strongSelf.title = "" strongSelf.title = ""
if let segmentedTitleView = strongSelf.segmentedTitleView, segmentedTitleView.segments == sections { if let segmentedTitleView = strongSelf.segmentedTitleView, segmentedTitleView.segments == sections {
@ -347,7 +351,9 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
} }
} }
strongSelf.navigationBar?.setContentNode(nil, animated: false) strongSelf.navigationBar?.setContentNode(nil, animated: false)
strongSelf.controllerNode.panRecognizer?.isEnabled = false if strongSelf.isNodeLoaded {
strongSelf.controllerNode.panRecognizer?.isEnabled = false
}
case let .textWithTabs(title, sections, index): case let .textWithTabs(title, sections, index):
strongSelf.title = title strongSelf.title = title
if let tabsNavigationContentNode = strongSelf.tabsNavigationContentNode, tabsNavigationContentNode.segments == sections { if let tabsNavigationContentNode = strongSelf.tabsNavigationContentNode, tabsNavigationContentNode.segments == sections {
@ -366,21 +372,23 @@ open class ItemListController: ViewController, KeyShortcutResponder, Presentable
} }
strongSelf.navigationBar?.updateBackgroundAlpha(1.0, transition: .immediate) strongSelf.navigationBar?.updateBackgroundAlpha(1.0, transition: .immediate)
} }
strongSelf.controllerNode.panTransitionFractionChanged = { [weak self] transitionFraction in if strongSelf.isNodeLoaded {
if let strongSelf = self { strongSelf.controllerNode.panTransitionFractionChanged = { [weak self] transitionFraction in
strongSelf.tabsNavigationContentNode?.transitionFraction = transitionFraction if let strongSelf = self {
strongSelf.tabsNavigationContentNode?.transitionFraction = transitionFraction
}
} }
} strongSelf.controllerNode.panGestureAllowedDirections = {
strongSelf.controllerNode.panGestureAllowedDirections = { if index == 0 {
if index == 0 { return [.leftCenter]
return [.leftCenter] } else if index == sections.count - 1 {
} else if index == sections.count - 1 { return [.rightCenter]
return [.rightCenter] } else {
} else { return [.leftCenter, .rightCenter]
return [.leftCenter, .rightCenter] }
} }
strongSelf.controllerNode.panRecognizer?.isEnabled = true
} }
strongSelf.controllerNode.panRecognizer?.isEnabled = true
} }
} }
strongSelf.navigationButtonActions = (left: controllerState.leftNavigationButton?.action, right: controllerState.rightNavigationButton?.action, secondaryRight: controllerState.secondaryRightNavigationButton?.action) strongSelf.navigationButtonActions = (left: controllerState.leftNavigationButton?.action, right: controllerState.rightNavigationButton?.action, secondaryRight: controllerState.secondaryRightNavigationButton?.action)