Remove tab bar logic from base controllers and move to the manager.
This commit is contained in:
parent
f8e71c3232
commit
b6226616d8
@ -43,9 +43,6 @@ 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 {
|
||||
!MVMCoreGetterUtility.cgfequalwiththreshold(previousScreenSize.width, view.bounds.size.width, 0.1)
|
||||
@ -244,12 +241,6 @@ import UIKit
|
||||
view.backgroundColor = backgroundColor.uiColor
|
||||
}
|
||||
|
||||
// Update splitview properties
|
||||
if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() {
|
||||
MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(bottomProgress() ?? 0)
|
||||
updateTabBar()
|
||||
}
|
||||
|
||||
// Notify the manager of new data
|
||||
manager?.newDataReceived?(in: self)
|
||||
}
|
||||
@ -267,34 +258,6 @@ import UIKit
|
||||
return model?.navigationBar
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - TabBar
|
||||
//--------------------------------------------------
|
||||
|
||||
open func updateTabBar() {
|
||||
guard MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() == self else { return }
|
||||
MVMCoreUISplitViewController.main()?.tabBar?.delegateObject = delegateObjectIVar
|
||||
|
||||
if let index = (model 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 = (model 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)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - View Lifecycle
|
||||
//--------------------------------------------------
|
||||
@ -349,12 +312,6 @@ import UIKit
|
||||
}
|
||||
|
||||
open func pageShown() {
|
||||
// Update split view properties if this is the current detail controller.
|
||||
if self == MVMCoreUISplitViewController.main()?.getCurrentDetailViewController() {
|
||||
MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(bottomProgress() ?? 0)
|
||||
updateTabBar()
|
||||
}
|
||||
|
||||
// Track.
|
||||
MVMCoreUISession.sharedGlobal()?.currentPageType = pageType
|
||||
MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)
|
||||
|
||||
@ -55,6 +55,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
|
||||
/// Reference to the tabbar.
|
||||
@property (nullable, weak, nonatomic) UIView <TabBarProtocol>*tabBar;
|
||||
|
||||
/// Tab bar index history.
|
||||
@property (nonnull, strong, nonatomic) NSMutableArray <NSNumber *>*tabBarIndices;
|
||||
|
||||
// Convenience getter
|
||||
+ (nullable instancetype)mainSplitViewController;
|
||||
|
||||
|
||||
@ -93,13 +93,20 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
}
|
||||
|
||||
- (nullable instancetype)initWithLeftPanel:(nullable UIViewController <MVMCoreUIPanelProtocol> *)leftPanel rightPanel:(nullable UIViewController <MVMCoreUIPanelProtocol> *)rightPanel {
|
||||
if (self = [super init]) {
|
||||
if (self = [self init]) {
|
||||
self.globalLeftPanel = leftPanel;
|
||||
self.globalRightPanel = rightPanel;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (nullable instancetype)init {
|
||||
if (self = [super init]) {
|
||||
self.tabBarIndices = [NSMutableArray array];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Main Subclassables
|
||||
|
||||
- (MFNumberOfDrawers)numberOfDrawersShouldShow:(NSNumber *)forWidth {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user