Remove UITabBarController workaround on iOS 18.1

This commit is contained in:
Shadowfacts 2024-10-14 18:24:47 -04:00
parent f4b51c06c1
commit 12bab71b17
1 changed files with 13 additions and 8 deletions

View File

@ -454,15 +454,20 @@ extension NewMainTabBarViewController {
extension NewMainTabBarViewController: UITabBarControllerDelegate { extension NewMainTabBarViewController: UITabBarControllerDelegate {
func tabBarController(_ tabBarController: UITabBarController, shouldSelectTab tab: UITab) -> Bool { func tabBarController(_ tabBarController: UITabBarController, shouldSelectTab tab: UITab) -> Bool {
if tab.identifier == Tab.compose.rawValue { if tab.identifier == Tab.compose.rawValue {
let currentTab = selectedTab if #unavailable(iOS 18.1) {
// returning false for shouldSelectTab doesn't prevent the UITabBar from being updated (FB14857254) let currentTab = selectedTab
// 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) // returning false for shouldSelectTab doesn't prevent the UITabBar from being updated (FB14857254)
// so return true, and then after the tab bar VC has finished updating, go back to currentTab // 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)
DispatchQueue.main.async { // so return true, and then after the tab bar VC has finished updating, go back to currentTab
self.selectedTab = currentTab DispatchQueue.main.async {
self.selectedTab = currentTab
}
compose(editing: nil)
return true
} else {
compose(editing: nil)
return false
} }
compose(editing: nil)
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 {