Fix reselecting current sidebar item not popping to root on Catalyst and new sidebar
Closes #525
This commit is contained in:
parent
6de255681c
commit
9b2e6140a3
|
@ -15,7 +15,7 @@ protocol MainSidebarViewControllerDelegate: AnyObject {
|
|||
func sidebarRequestPresentCompose(_ sidebarViewController: MainSidebarViewController)
|
||||
func sidebar(_ sidebarViewController: MainSidebarViewController, didSelectItem item: MainSidebarViewController.Item, previousItem: MainSidebarViewController.Item?)
|
||||
func sidebar(_ sidebarViewController: MainSidebarViewController, showViewController viewController: UIViewController, previousItem: MainSidebarViewController.Item?)
|
||||
func sidebar(_ sidebarViewController: MainSidebarViewController, scrollToTopFor item: MainSidebarViewController.Item)
|
||||
func sidebar(_ sidebarViewController: MainSidebarViewController, didReselectItem item: MainSidebarViewController.Item)
|
||||
}
|
||||
|
||||
class MainSidebarViewController: UIViewController {
|
||||
|
@ -452,7 +452,7 @@ extension MainSidebarViewController: UICollectionViewDelegate {
|
|||
}
|
||||
itemLastSelectedTimestamps[item] = Date()
|
||||
if previouslySelectedItem == item {
|
||||
sidebarDelegate?.sidebar(self, scrollToTopFor: item)
|
||||
sidebarDelegate?.sidebar(self, didReselectItem: item)
|
||||
} else if [MainSidebarViewController.Item.tab(.compose), .addList, .addSavedHashtag, .addSavedInstance].contains(item) {
|
||||
if let previous = previouslySelectedItem, let indexPath = dataSource.indexPath(for: previous) {
|
||||
collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredVertically)
|
||||
|
|
|
@ -493,8 +493,12 @@ extension MainSplitViewController: MainSidebarViewControllerDelegate {
|
|||
secondaryNavController.viewControllers = [viewController]
|
||||
}
|
||||
|
||||
func sidebar(_ sidebarViewController: MainSidebarViewController, scrollToTopFor item: MainSidebarViewController.Item) {
|
||||
(secondaryNavController as? TabBarScrollableViewController)?.tabBarScrollToTop()
|
||||
func sidebar(_ sidebarViewController: MainSidebarViewController, didReselectItem item: MainSidebarViewController.Item) {
|
||||
if secondaryNavController.viewControllers.count == 1 {
|
||||
(secondaryNavController.topViewController as? TabBarScrollableViewController)?.tabBarScrollToTop()
|
||||
} else {
|
||||
secondaryNavController.popToRootViewController(animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -441,10 +441,12 @@ extension NewMainTabBarViewController: UITabBarControllerDelegate {
|
|||
return true
|
||||
} else if let selectedTab,
|
||||
selectedTab == tab,
|
||||
let nav = selectedViewController as? any NavigationControllerProtocol,
|
||||
nav.viewControllers.count == 1,
|
||||
let scrollableVC = nav.viewControllers[0] as? TabBarScrollableViewController {
|
||||
scrollableVC.tabBarScrollToTop()
|
||||
let nav = selectedViewController as? any NavigationControllerProtocol {
|
||||
if nav.viewControllers.count == 1 {
|
||||
(nav.viewControllers[0] as? TabBarScrollableViewController)?.tabBarScrollToTop()
|
||||
} else {
|
||||
nav.popToRootViewController(animated: true)
|
||||
}
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue