From b6226616d8ebe465b19d324721c021e57b113a95 Mon Sep 17 00:00:00 2001 From: Scott Pfeil Date: Thu, 5 May 2022 12:33:13 -0400 Subject: [PATCH] Remove tab bar logic from base controllers and move to the manager. --- .../BaseControllers/ViewController.swift | 43 ------------------- .../MVMCoreUISplitViewController.h | 3 ++ .../MVMCoreUISplitViewController.m | 9 +++- 3 files changed, 11 insertions(+), 44 deletions(-) diff --git a/MVMCoreUI/BaseControllers/ViewController.swift b/MVMCoreUI/BaseControllers/ViewController.swift index 26ab983f..772742b4 100644 --- a/MVMCoreUI/BaseControllers/ViewController.swift +++ b/MVMCoreUI/BaseControllers/ViewController.swift @@ -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) diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index db5e9cd9..d0530cc9 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -55,6 +55,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { /// Reference to the tabbar. @property (nullable, weak, nonatomic) UIView *tabBar; +/// Tab bar index history. +@property (nonnull, strong, nonatomic) NSMutableArray *tabBarIndices; + // Convenience getter + (nullable instancetype)mainSplitViewController; diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index 5c337072..e005763b 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -93,13 +93,20 @@ CGFloat const PanelAnimationDuration = 0.2; } - (nullable instancetype)initWithLeftPanel:(nullable UIViewController *)leftPanel rightPanel:(nullable UIViewController *)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 {