tab bar history

This commit is contained in:
Pfeil, Scott Robert 2020-09-15 14:10:45 -04:00
parent fd630e4b84
commit 5407ec9cef
3 changed files with 28 additions and 13 deletions

View File

@ -99,6 +99,10 @@ import Foundation
self.tabBar(self, didSelect: newSelectedItem)
})
}
public func currentTabIndex() -> Int {
return model.selectedTab
}
}
extension UITabBarItem: MFButtonProtocol {

View File

@ -17,4 +17,7 @@ import Foundation
/// Should select the tab index. As if the user selected it.
@objc func selectTab(at index: Int)
/// Returns the current tab
@objc func currentTabIndex() -> Int
}

View File

@ -39,6 +39,9 @@ import UIKit
public var selectedField: UIView?
// Stores the previous tab bar index.
public var tabBarIndex: Int?
/// Checks if the screen width has changed
open func screenSizeChanged() -> Bool {
return !MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
@ -318,13 +321,27 @@ import UIKit
//--------------------------------------------------
open func updateTabBar() {
guard MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() == self,
let tabModel = pageModel as? TabPageModelProtocol else { return }
guard MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() == self else { return }
MVMCoreUISplitViewController.main()?.tabBar?.delegateObject = delegateObjectIVar
if let index = tabModel.tabBarIndex {
if let index = (pageModel as? TabPageModelProtocol)?.tabBarIndex {
MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index)
} else if let index = loadObject?.requestParameters?.actionMap?["tabBarIndex"] as? Int {
MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index)
} else if let index = self.tabBarIndex {
MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index)
} else if let index = MVMCoreUISplitViewController.main()?.tabBar?.currentTabIndex() {
// Store current tab index for cases like back button.
self.tabBarIndex = index
}
if let hidden = (pageModel as? TabPageModelProtocol)?.tabBarHidden {
MVMCoreUISplitViewController.main()?.updateTabBarShowing(!hidden)
} else if let hidden = loadObject?.requestParameters?.actionMap?["tabBarHidden"] as? Bool {
MVMCoreUISplitViewController.main()?.updateTabBarShowing(!hidden)
} else {
MVMCoreUISplitViewController.main()?.updateTabBarShowing(true)
}
MVMCoreUISplitViewController.main()?.updateTabBarShowing(!tabModel.tabBarHidden)
}
//--------------------------------------------------
@ -454,15 +471,6 @@ import UIKit
loadObject?.requestParameters?.openSupportPanel ?? (loadObject?.systemParametersJSON?.boolForKey(KeyOpenSupport) ?? false) == true {
MVMCoreUISession.sharedGlobal()?.splitViewController?.showRightPanel(animated: true)
}
// Selects the tab if needed. Page driven takes priority over action driven (see viewWillAppear)
if let tab: Int = loadObject?.requestParameters?.actionMap?["tabBarIndex"] as? Int,
error == nil,
loadObject?.pageJSON?["tabBarIndex"] == nil {
MVMCoreDispatchUtility.performBlock(onMainThread: {
MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: tab)
})
}
}
//--------------------------------------------------