tab bar history
This commit is contained in:
parent
fd630e4b84
commit
5407ec9cef
@ -99,6 +99,10 @@ import Foundation
|
|||||||
self.tabBar(self, didSelect: newSelectedItem)
|
self.tabBar(self, didSelect: newSelectedItem)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public func currentTabIndex() -> Int {
|
||||||
|
return model.selectedTab
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension UITabBarItem: MFButtonProtocol {
|
extension UITabBarItem: MFButtonProtocol {
|
||||||
|
|||||||
@ -17,4 +17,7 @@ import Foundation
|
|||||||
|
|
||||||
/// Should select the tab index. As if the user selected it.
|
/// Should select the tab index. As if the user selected it.
|
||||||
@objc func selectTab(at index: Int)
|
@objc func selectTab(at index: Int)
|
||||||
|
|
||||||
|
/// Returns the current tab
|
||||||
|
@objc func currentTabIndex() -> Int
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,6 +39,9 @@ import UIKit
|
|||||||
|
|
||||||
public var selectedField: UIView?
|
public var selectedField: UIView?
|
||||||
|
|
||||||
|
// Stores the previous tab bar index.
|
||||||
|
public var tabBarIndex: Int?
|
||||||
|
|
||||||
/// Checks if the screen width has changed
|
/// Checks if the screen width has changed
|
||||||
open func screenSizeChanged() -> Bool {
|
open func screenSizeChanged() -> Bool {
|
||||||
return !MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
|
return !MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
|
||||||
@ -318,13 +321,27 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
open func updateTabBar() {
|
open func updateTabBar() {
|
||||||
guard MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() == self,
|
guard MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() == self else { return }
|
||||||
let tabModel = pageModel as? TabPageModelProtocol else { return }
|
|
||||||
MVMCoreUISplitViewController.main()?.tabBar?.delegateObject = delegateObjectIVar
|
MVMCoreUISplitViewController.main()?.tabBar?.delegateObject = delegateObjectIVar
|
||||||
if let index = tabModel.tabBarIndex {
|
|
||||||
|
if let index = (pageModel as? TabPageModelProtocol)?.tabBarIndex {
|
||||||
MVMCoreUISplitViewController.main()?.tabBar?.highlightTab(at: index)
|
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 {
|
loadObject?.requestParameters?.openSupportPanel ?? (loadObject?.systemParametersJSON?.boolForKey(KeyOpenSupport) ?? false) == true {
|
||||||
MVMCoreUISession.sharedGlobal()?.splitViewController?.showRightPanel(animated: 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)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user