Fix new tab bar VC getting stuck in bad state after presenting Compose
This commit is contained in:
parent
230696f456
commit
4945a234e7
|
@ -246,10 +246,14 @@ final class NewMainTabBarViewController: BaseMainTabBarViewController {
|
||||||
}
|
}
|
||||||
|
|
||||||
private func embedInNavigationController(_ vc: UIViewController) -> UIViewController {
|
private func embedInNavigationController(_ vc: UIViewController) -> UIViewController {
|
||||||
|
if UIDevice.current.userInterfaceIdiom == .phone {
|
||||||
|
return UINavigationController(rootViewController: vc)
|
||||||
|
} else {
|
||||||
let nav = AdaptableNavigationController()
|
let nav = AdaptableNavigationController()
|
||||||
nav.viewControllers = [vc]
|
nav.viewControllers = [vc]
|
||||||
return nav
|
return nav
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override func viewDidAppear(_ animated: Bool) {
|
override func viewDidAppear(_ animated: Bool) {
|
||||||
super.viewDidAppear(animated)
|
super.viewDidAppear(animated)
|
||||||
|
@ -428,12 +432,13 @@ extension NewMainTabBarViewController: UITabBarControllerDelegate {
|
||||||
if tab.identifier == Tab.compose.rawValue {
|
if tab.identifier == Tab.compose.rawValue {
|
||||||
let currentTab = selectedTab
|
let currentTab = selectedTab
|
||||||
// returning false for shouldSelectTab doesn't prevent the UITabBar from being updated (FB14857254)
|
// returning false for shouldSelectTab doesn't prevent the UITabBar from being updated (FB14857254)
|
||||||
// but we need it to change to _something_ so that we can change back to the current tab
|
// returning false and then setting selectedTab=tab and selectedTab=currentTab seems to leave things in a bad state (currentTab's VC is on screen but in the disappeared state)
|
||||||
self.selectedTab = tab
|
// so return true, and then after the tab bar VC has finished updating, go back to currentTab
|
||||||
|
DispatchQueue.main.async {
|
||||||
self.selectedTab = currentTab
|
self.selectedTab = currentTab
|
||||||
|
}
|
||||||
compose(editing: nil)
|
compose(editing: nil)
|
||||||
return false
|
return true
|
||||||
} else if let selectedTab,
|
} else if let selectedTab,
|
||||||
selectedTab == tab,
|
selectedTab == tab,
|
||||||
let nav = selectedViewController as? any NavigationControllerProtocol,
|
let nav = selectedViewController as? any NavigationControllerProtocol,
|
||||||
|
|
Loading…
Reference in New Issue