diff --git a/Tusker/Screens/Main/MainSplitViewController.swift b/Tusker/Screens/Main/MainSplitViewController.swift index 2c48052c..e5ad98f9 100644 --- a/Tusker/Screens/Main/MainSplitViewController.swift +++ b/Tusker/Screens/Main/MainSplitViewController.swift @@ -225,7 +225,7 @@ extension MainSplitViewController: UISplitViewControllerDelegate { case let .tab(tab): // sidebar items that map 1 <-> 1 can be transferred directly - tabBarViewController.select(tab: tab) + tabBarViewController.select(tab: tab, dismissPresented: false) case .explore: // Search sidebar item maps to the Explore tab with the search controller/results visible @@ -268,10 +268,10 @@ extension MainSplitViewController: UISplitViewControllerDelegate { // Transfer the navigation stack, dropping the search VC, to keep anything the user has opened transferNavigationStack(from: .explore, to: exploreNav, dropFirst: true, append: true) - tabBarViewController.select(tab: .explore) + tabBarViewController.select(tab: .explore, dismissPresented: false) case .bookmarks, .favorites, .list(_), .savedHashtag(_), .savedInstance(_): - tabBarViewController.select(tab: .explore) + tabBarViewController.select(tab: .explore, dismissPresented: false) // Make sure the Explore VC doesn't show its search bar when it appears, in case the user was previously // in compact mode and performing a search. let exploreNav = tabBarViewController.viewController(for: .explore) as! UINavigationController diff --git a/Tusker/Screens/Main/MainTabBarViewController.swift b/Tusker/Screens/Main/MainTabBarViewController.swift index dc3b81b3..fde598c3 100644 --- a/Tusker/Screens/Main/MainTabBarViewController.swift +++ b/Tusker/Screens/Main/MainTabBarViewController.swift @@ -111,13 +111,13 @@ class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate { repositionFastSwitcherIndicator() } - func select(tab: Tab) { + func select(tab: Tab, dismissPresented: Bool) { if tab == .compose { compose(editing: nil) } else { // when switching tabs, dismiss the currently presented VC // otherwise the selected tab changes behind the presented VC - if presentedViewController != nil { + if presentedViewController != nil && dismissPresented { dismiss(animated: true) { self.selectedIndex = tab.rawValue } @@ -291,18 +291,18 @@ extension MainTabBarViewController: TuskerRootViewController { func select(route: TuskerRoute, animated: Bool) { switch route { case .timelines: - select(tab: .timelines) + select(tab: .timelines, dismissPresented: true) case .notifications: - select(tab: .notifications) + select(tab: .notifications, dismissPresented: true) case .myProfile: - select(tab: .myProfile) + select(tab: .myProfile, dismissPresented: true) case .explore: - select(tab: .explore) + select(tab: .explore, dismissPresented: true) case .bookmarks: - select(tab: .explore) + select(tab: .explore, dismissPresented: true) getNavigationController().pushViewController(BookmarksViewController(mastodonController: mastodonController), animated: animated) case .list(id: let id): - select(tab: .explore) + select(tab: .explore, dismissPresented: true) if let list = mastodonController.getCachedList(id: id) { let nav = getNavigationController() _ = nav.popToRootViewController(animated: animated) @@ -325,7 +325,7 @@ extension MainTabBarViewController: TuskerRootViewController { return } - select(tab: .explore) + select(tab: .explore, dismissPresented: true) exploreNavController.popToRootViewController(animated: false) // setting searchController.isActive directly doesn't work until the view has loaded/appeared for the first time