fix for double tracking
Change the way the navigation bar is updated.
This commit is contained in:
parent
728a3ca622
commit
69712928fc
@ -323,6 +323,7 @@
|
||||
D27CD40E2322EEAF00C1DC07 /* TabsTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */; };
|
||||
D27CD4102339057800C1DC07 /* EyebrowHeadlineBodyLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */; };
|
||||
D282AABA224131D100C46919 /* MFTransparentGIFView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */; };
|
||||
D2874024249BA6F300BE950A /* MVMCoreUISplitViewController+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D2874023249BA6F300BE950A /* MVMCoreUISplitViewController+Extension.swift */; };
|
||||
D28764AA2458980300CB882D /* ThreeLayerFillMiddleTemplate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28764A92458980300CB882D /* ThreeLayerFillMiddleTemplate.swift */; };
|
||||
D28764AC245898A400CB882D /* ThreeLayerFillMiddleTemplateModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28764AB245898A400CB882D /* ThreeLayerFillMiddleTemplateModel.swift */; };
|
||||
D28764F9245A327200CB882D /* TwoLinkView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D28764F8245A327200CB882D /* TwoLinkView.swift */; };
|
||||
@ -769,6 +770,7 @@
|
||||
D27CD40D2322EEAF00C1DC07 /* TabsTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabsTableViewCell.swift; sourceTree = "<group>"; };
|
||||
D27CD40F2339057800C1DC07 /* EyebrowHeadlineBodyLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EyebrowHeadlineBodyLink.swift; sourceTree = "<group>"; };
|
||||
D282AAB9224131D100C46919 /* MFTransparentGIFView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFTransparentGIFView.swift; sourceTree = "<group>"; };
|
||||
D2874023249BA6F300BE950A /* MVMCoreUISplitViewController+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "MVMCoreUISplitViewController+Extension.swift"; sourceTree = "<group>"; };
|
||||
D28764A92458980300CB882D /* ThreeLayerFillMiddleTemplate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerFillMiddleTemplate.swift; sourceTree = "<group>"; };
|
||||
D28764AB245898A400CB882D /* ThreeLayerFillMiddleTemplateModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeLayerFillMiddleTemplateModel.swift; sourceTree = "<group>"; };
|
||||
D28764F8245A327200CB882D /* TwoLinkView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwoLinkView.swift; sourceTree = "<group>"; };
|
||||
@ -1813,6 +1815,7 @@
|
||||
D29DF15321E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h */,
|
||||
D29DF11A21E684A9003B2FB9 /* MVMCoreUISplitViewController.h */,
|
||||
D29DF11B21E684A9003B2FB9 /* MVMCoreUISplitViewController.m */,
|
||||
D2874023249BA6F300BE950A /* MVMCoreUISplitViewController+Extension.swift */,
|
||||
);
|
||||
path = SplitViewController;
|
||||
sourceTree = "<group>";
|
||||
@ -2261,6 +2264,7 @@
|
||||
942C378E2412F5B60066E45E /* ModalMoleculeStackTemplate.swift in Sources */,
|
||||
8D8067D32444473A00203BE8 /* ListRightVariablePriceChangeAllTextAndLinks.swift in Sources */,
|
||||
8D4687E4242E2DF300802879 /* ListFourColumnDataUsageListItem.swift in Sources */,
|
||||
D2874024249BA6F300BE950A /* MVMCoreUISplitViewController+Extension.swift in Sources */,
|
||||
01F2A03223A4498200D954D8 /* CaretLinkModel.swift in Sources */,
|
||||
0A7BAFA1232BE61800FB8E22 /* Checkbox.swift in Sources */,
|
||||
011B58F023A2AA980085F53C /* ListItemModelProtocol.swift in Sources */,
|
||||
|
||||
@ -196,18 +196,8 @@ import UIKit
|
||||
// We additionally want our left items
|
||||
navigationItem.leftItemsSupplementBackButton = true
|
||||
|
||||
NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController)
|
||||
|
||||
// Special logic when using the split view controller. Legacy Update Panels. Change how this is done.
|
||||
guard navigationController == MVMCoreUISplitViewController.main()?.navigationController,
|
||||
navigationController.topViewController == viewController else { return }
|
||||
|
||||
MVMCoreUISession.sharedGlobal()?.splitViewController?.setupPanels()
|
||||
showBottomProgressBar()
|
||||
|
||||
MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(isMasterInitiallyAccessible(), for: viewController)
|
||||
MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(isSupportInitiallyAccessible(), for: viewController)
|
||||
MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(navigationItemModel.tintColor.uiColor)
|
||||
// Utilize helper function to set the split view and navigation item state.
|
||||
MVMCoreUISplitViewController.setSplitViewController(for: viewController, navigationController: navigationController, navigationItemModel: navigationItemModel, leftPanelAccessible: isMasterInitiallyAccessible(), rightPanelAccessible: isSupportInitiallyAccessible(), progress: bottomProgress())
|
||||
}
|
||||
|
||||
// Eventually will be moved to server
|
||||
@ -249,12 +239,10 @@ import UIKit
|
||||
}
|
||||
|
||||
// Eventually will be moved to Model
|
||||
open func showBottomProgressBar() {
|
||||
if MVMCoreUISplitViewController.main()?.getCurrentVisibleController() == self,
|
||||
let progressString = loadObject?.pageJSON?.optionalStringForKey(KeyProgressPercent),
|
||||
let progress = Float(progressString) {
|
||||
MVMCoreUISplitViewController.main()?.setBottomProgressBarProgress(progress / Float(100))
|
||||
}
|
||||
open func bottomProgress() -> Float? {
|
||||
guard let progressString = loadObject?.pageJSON?.optionalStringForKey(KeyProgressPercent),
|
||||
let progress = Float(progressString) else { return nil }
|
||||
return (progress / Float(100))
|
||||
}
|
||||
|
||||
// MARK: - TabBar
|
||||
@ -318,24 +306,23 @@ import UIKit
|
||||
super.viewDidLayoutSubviews()
|
||||
}
|
||||
|
||||
open override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
open func pageShown() {
|
||||
// Update the navigation bar ui when view is appearing.
|
||||
setNavigationController()
|
||||
|
||||
// Update the navigation bar ui when view is appearing. Can remove check in the future, see viewControllerReady
|
||||
if manager == nil {
|
||||
setNavigationController()
|
||||
}
|
||||
// Update tab if needed.
|
||||
updateTabBar()
|
||||
|
||||
// Track.
|
||||
MVMCoreUISession.sharedGlobal()?.currentPageType = pageType
|
||||
MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)
|
||||
}
|
||||
|
||||
open override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
// Update tab if needed.
|
||||
updateTabBar()
|
||||
|
||||
if manager == nil {
|
||||
MVMCoreUISession.sharedGlobal()?.currentPageType = pageType
|
||||
MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)
|
||||
pageShown()
|
||||
}
|
||||
|
||||
executeBehaviors { (behavior: PageVisibilityBehavior) in
|
||||
@ -372,13 +359,7 @@ import UIKit
|
||||
|
||||
// MARK: - MVMCoreViewManagerViewControllerProtocol
|
||||
open func viewControllerReady(inManager manager: UIViewController & MVMCoreViewManagerProtocol) {
|
||||
// TODO: This check and set aren't technically needed anymore. The one in viewwillappear should be enough. However, there is a timing issue with the manager where the screen lays out before the menu shows, so the screen grows off the screen. Can fix in the future.
|
||||
if let _ = self.view {
|
||||
setNavigationController()
|
||||
}
|
||||
// Janky way to track current page.
|
||||
MVMCoreUISession.sharedGlobal()?.currentPageType = pageType
|
||||
MVMCoreUILoggingHandler.shared()?.defaultLogPageState(forController: self)
|
||||
pageShown()
|
||||
}
|
||||
|
||||
// MARK: - MVMCoreLoadDelegateProtocol
|
||||
|
||||
@ -67,8 +67,8 @@ import UIKit
|
||||
viewController.navigationItem.rightBarButtonItems = rightItems.count > 0 ? rightItems : nil
|
||||
}
|
||||
|
||||
/// Convenience function for setting navigation bar with model.
|
||||
public static func set(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) {
|
||||
/// Convenience function for setting the navigation bar ui, except for the buttons.
|
||||
public static func setNavigationUI(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) {
|
||||
viewController.navigationItem.title = navigationItemModel.title
|
||||
viewController.navigationItem.accessibilityLabel = navigationItemModel.title
|
||||
viewController.navigationItem.hidesBackButton = (navigationItemModel.backButton != nil)
|
||||
@ -86,8 +86,11 @@ import UIKit
|
||||
if let navigationController = navigationController as? NavigationController {
|
||||
navigationController.separatorView?.isHidden = navigationItemModel.line?.type ?? .standard == .none
|
||||
}
|
||||
}
|
||||
|
||||
// Sets up the navigation buttons.
|
||||
/// Convenience function for setting navigation bar with model.
|
||||
public static func set(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, viewController: UIViewController) {
|
||||
setNavigationUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController)
|
||||
setNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController)
|
||||
}
|
||||
|
||||
|
||||
@ -42,6 +42,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (UIStatusBarStyle)defaultStatusBarStyle;
|
||||
- (nullable UIColor *)defaultStatusBarBackgroundColor;
|
||||
|
||||
/// Called when the split view did reset. If this function found, the splitview assumes it is handling the split view state and does not do anything. If you have navigation item buttons, override this function and handle the panels manually.
|
||||
- (void)splitViewDidReset;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -0,0 +1,122 @@
|
||||
//
|
||||
// MVMCoreUISplitViewController+Extension.swift
|
||||
// MVMCoreUI
|
||||
//
|
||||
// Created by Scott Pfeil on 6/18/20.
|
||||
// Copyright © 2020 Verizon Wireless. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
public extension MVMCoreUISplitViewController {
|
||||
|
||||
/// Convenience function. Sets the navigation and split view properties for the view controller.
|
||||
static func setSplitViewController(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, leftPanelAccessible: Bool, rightPanelAccessible: Bool, progress: Float? = nil) {
|
||||
guard let splitView = MVMCoreUISplitViewController.main(),
|
||||
navigationController == splitView.navigationController,
|
||||
navigationController.topViewController == viewController else {
|
||||
NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController)
|
||||
return
|
||||
}
|
||||
splitView.set(for: viewController, navigationController: navigationController, navigationItemModel: navigationItemModel, leftPanelAccessible: leftPanelAccessible, rightPanelAccessible: rightPanelAccessible, progress: progress)
|
||||
}
|
||||
|
||||
/// Sets the navigation item for the view controller based on the model and splitview controller
|
||||
func set(for viewController: UIViewController, navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol, leftPanelAccessible: Bool, rightPanelAccessible: Bool, progress: Float? = nil) {
|
||||
|
||||
// Setup the panels.
|
||||
MVMCoreUISession.sharedGlobal()?.splitViewController?.setupPanels()
|
||||
|
||||
NavigationController.setNavigationUI(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController)
|
||||
|
||||
MVMCoreUISplitViewController.main()?.setLeftPanelIsAccessible(leftPanelAccessible, for: viewController, updateNavigationButtons: false)
|
||||
MVMCoreUISplitViewController.main()?.setRightPanelIsAccessible(rightPanelAccessible, for: viewController, updateNavigationButtons: false)
|
||||
|
||||
setLeftNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController)
|
||||
setRightNavigationButtons(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController)
|
||||
|
||||
MVMCoreUISession.sharedGlobal()?.splitViewController?.setNavigationIconColor(navigationItemModel.tintColor.uiColor)
|
||||
|
||||
setBottomProgressBarProgress(progress ?? 0)
|
||||
}
|
||||
|
||||
/// Sets the left navigation items for the view controller based on model and splitview.
|
||||
func setLeftNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) {
|
||||
var leftItems: [UIBarButtonItem] = []
|
||||
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||
|
||||
// Add back button first.
|
||||
if let backButtonModel = navigationItemModel?.backButton {
|
||||
if navigationController.viewControllers.count > 1 || navigationItemModel!.alwaysShowBackButton {
|
||||
leftItems.append(backButtonModel.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
||||
}
|
||||
} else if let backButton = backButton,
|
||||
navigationController.viewControllers.count > 1 {
|
||||
leftItems.append(backButton)
|
||||
}
|
||||
|
||||
// Add the panel button after the back button.
|
||||
if let panelButton = leftPanelButton,
|
||||
leftPanelIsAccessible,
|
||||
!leftPanelStaysExtended() {
|
||||
leftItems.append(panelButton)
|
||||
}
|
||||
|
||||
// Add other model buttons
|
||||
if let leftItemModels = navigationItemModel?.additionalLeftButtons {
|
||||
for item in leftItemModels {
|
||||
leftItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
||||
}
|
||||
}
|
||||
|
||||
// Add any buttons added by the splitview.
|
||||
if let additionalLeftButtons = additionalLeftButtons(for: viewController) {
|
||||
leftItems.append(contentsOf: additionalLeftButtons)
|
||||
}
|
||||
|
||||
viewController.navigationItem.setLeftBarButtonItems(leftItems.count > 0 ? leftItems : nil, animated: !DisableAnimations.boolValue)
|
||||
}
|
||||
|
||||
/// Sets the right navigation items for the view controller based on model and splitview.
|
||||
func setRightNavigationButtons(navigationController: UINavigationController, navigationItemModel: NavigationItemModelProtocol?, viewController: UIViewController) {
|
||||
let delegate = (viewController as? MVMCoreViewControllerProtocol)?.delegateObject?() as? MVMCoreUIDelegateObject
|
||||
var rightItems: [UIBarButtonItem] = []
|
||||
|
||||
// Add the panel button first.
|
||||
if let panelButton = rightPanelButton,
|
||||
rightPanelIsAccessible,
|
||||
!rightPanelStaysExtended() {
|
||||
rightItems.append(panelButton)
|
||||
}
|
||||
|
||||
// Add other model buttons
|
||||
if let rightItemModels = navigationItemModel?.additionalRightButtons {
|
||||
for item in rightItemModels {
|
||||
rightItems.append(item.createNavigationItemButton(delegateObject: delegate, additionalData: nil))
|
||||
}
|
||||
}
|
||||
|
||||
// Add any buttons added by the splitview.
|
||||
if let additionalRightButtons = additionalRightButtons(for: viewController) {
|
||||
rightItems.append(contentsOf: additionalRightButtons)
|
||||
}
|
||||
|
||||
viewController.navigationItem.setRightBarButtonItems(rightItems.count > 0 ? rightItems : nil, animated: !DisableAnimations.boolValue)
|
||||
}
|
||||
|
||||
// MARK: - Legacy Functions
|
||||
/// Convenience setter for legacy files. Sets the navigation item for the view controller based on the json and splitview controller
|
||||
@objc static func setSplitViewController(for viewController: UIViewController, navigationController: UINavigationController, navigationJSON: [String: Any], leftPanelAccessible: Bool, rightPanelAccessible: Bool, progress: NSNumber?) throws {
|
||||
guard let navigationItemModel = try MoleculeObjectMapping.shared()?.getMoleculeModelForJSON(navigationJSON) as? (MoleculeModelProtocol & NavigationItemModelProtocol) else {
|
||||
throw ModelRegistry.Error.decoderOther(message: "Model not a bar model")
|
||||
}
|
||||
guard let splitView = MVMCoreUISplitViewController.main(),
|
||||
navigationController == splitView.navigationController,
|
||||
navigationController.topViewController == viewController else {
|
||||
NavigationController.set(navigationController: navigationController, navigationItemModel: navigationItemModel, viewController: viewController)
|
||||
return
|
||||
}
|
||||
let progress = progress?.floatValue
|
||||
splitView.set(for: viewController, navigationController: navigationController, navigationItemModel: navigationItemModel, leftPanelAccessible: leftPanelAccessible, rightPanelAccessible: rightPanelAccessible, progress: progress)
|
||||
}
|
||||
}
|
||||
@ -67,10 +67,10 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
|
||||
#pragma mark - Panel Functions
|
||||
|
||||
// Sets if the left panel accessible for the view controller. Will show or hide the button.
|
||||
- (void)setLeftPanelIsAccessible:(BOOL)leftPanelIsAccessible forViewController:(nonnull UIViewController *)viewController;
|
||||
- (void)setLeftPanelIsAccessible:(BOOL)leftPanelIsAccessible forViewController:(nonnull UIViewController *)viewController updateNavigationButtons:(BOOL)updateNavigationButtons;
|
||||
|
||||
// Sets if the right panel accessible for the view controller. Will show or hide the button.
|
||||
- (void)setRightPanelIsAccessible:(BOOL)rightPanelIsAccessible forViewController:(nonnull UIViewController *)viewController;
|
||||
- (void)setRightPanelIsAccessible:(BOOL)rightPanelIsAccessible forViewController:(nonnull UIViewController *)viewController updateNavigationButtons:(BOOL)updateNavigationButtons;
|
||||
|
||||
- (void)hideLeftPanelIfNeededAnimated:(BOOL)animated;
|
||||
- (void)showLeftPanelAnimated:(BOOL)animated;
|
||||
@ -94,6 +94,12 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
|
||||
/// Updates the panels that are used.
|
||||
- (void)setupPanels;
|
||||
|
||||
/// Returns if the left panel is staying extended (usually do to screen size threshold)
|
||||
- (BOOL)leftPanelStaysExtended;
|
||||
|
||||
/// Returns if the right panel is staying extended (usually do to screen size threshold)
|
||||
- (BOOL)rightPanelStaysExtended;
|
||||
|
||||
#pragma mark - Bottom Progress Bar
|
||||
|
||||
- (void)setBottomProgressBarProgress:(float)progress;
|
||||
|
||||
@ -110,11 +110,11 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
}
|
||||
|
||||
- (nullable NSArray <UIBarButtonItem *>*)additionalLeftButtonsForViewController:(nonnull UIViewController *)viewController {
|
||||
return viewController.navigationItem.leftBarButtonItems;
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (nullable NSArray <UIBarButtonItem *>*)additionalRightButtonsForViewController:(nonnull UIViewController *)viewController {
|
||||
return viewController.navigationItem.rightBarButtonItems;
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (CGFloat)leftPanelExtendedWidth {
|
||||
@ -234,19 +234,27 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)leftPanelStaysExtended {
|
||||
MFNumberOfDrawers numberOfDrawers = [self numberOfDrawersShouldShow:self.transitionWidth];
|
||||
return [self shouldExtendLeftPanel:numberOfDrawers] && (numberOfDrawers != MFOneDrawer || self.explictlyShowingPanel != self.rightPanel);
|
||||
}
|
||||
|
||||
- (void)setLeftNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended {
|
||||
NSMutableArray *leftBarButtonItems = [NSMutableArray array];
|
||||
NSArray *extraButtons = [self additionalLeftButtonsForViewController:viewController];
|
||||
if ((accessible && !extended) && self.leftPanelButton && ![extraButtons containsObject:self.leftPanelButton]) {
|
||||
if ([viewController.navigationController.viewControllers count] > 1) {
|
||||
[leftBarButtonItems addObject:self.backButton];
|
||||
}
|
||||
if ((accessible && !extended) && self.leftPanelButton) {
|
||||
[leftBarButtonItems addObject:self.leftPanelButton];
|
||||
}
|
||||
NSArray *extraButtons = [self additionalLeftButtonsForViewController:viewController];
|
||||
if (extraButtons) {
|
||||
[leftBarButtonItems addObjectsFromArray:extraButtons];
|
||||
}
|
||||
[viewController.navigationItem setLeftBarButtonItems:(leftBarButtonItems.count > 0 ? leftBarButtonItems : nil) animated:!DisableAnimations];
|
||||
}
|
||||
|
||||
- (void)setLeftPanelIsAccessible:(BOOL)leftPanelIsAccessible forViewController:(UIViewController *)viewController {
|
||||
- (void)setLeftPanelIsAccessible:(BOOL)leftPanelIsAccessible forViewController:(UIViewController *)viewController updateNavigationButtons:(BOOL)updateNavigationButtons {
|
||||
if ([self.leftPanel respondsToSelector:@selector(panelAvailable)]) {
|
||||
self.leftPanelIsAccessible = leftPanelIsAccessible && [self.leftPanel panelAvailable];
|
||||
} else {
|
||||
@ -262,8 +270,7 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
} else {
|
||||
|
||||
// Determine if we should show the panel (extended based on width or from explicit action).
|
||||
MFNumberOfDrawers numberOfDrawers = [self numberOfDrawersShouldShow:self.transitionWidth];
|
||||
extended = [self shouldExtendLeftPanel:numberOfDrawers] && (numberOfDrawers != MFOneDrawer || self.explictlyShowingPanel != self.rightPanel);
|
||||
extended = [self leftPanelStaysExtended];
|
||||
if (extended || self.explictlyShowingPanel == self.leftPanel) {
|
||||
[self showLeftPanelAnimated:NO explict:NO];
|
||||
}
|
||||
@ -272,7 +279,9 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
[self.leftPanel resetIconToDefault];
|
||||
}
|
||||
}
|
||||
[self setLeftNavigationItemForViewController:viewController accessible:self.leftPanelIsAccessible extended:extended];
|
||||
if (updateNavigationButtons) {
|
||||
[self setLeftNavigationItemForViewController:viewController accessible:self.leftPanelIsAccessible extended:extended];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@ -407,10 +416,10 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
|
||||
- (void)setRightNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended {
|
||||
NSMutableArray *navigationItems = [[NSMutableArray alloc] init];
|
||||
NSArray *extraButtons = [self additionalRightButtonsForViewController:viewController];
|
||||
if ((accessible && !extended) && self.rightPanelButton && ![extraButtons containsObject:self.rightPanelButton]) {
|
||||
if ((accessible && !extended) && self.rightPanelButton) {
|
||||
[navigationItems addObject:self.rightPanelButton];
|
||||
}
|
||||
NSArray *extraButtons = [self additionalRightButtonsForViewController:viewController];
|
||||
if (extraButtons) {
|
||||
[navigationItems addObjectsFromArray:extraButtons];
|
||||
}
|
||||
@ -440,7 +449,12 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setRightPanelIsAccessible:(BOOL)rightPanelIsAccessible forViewController:(UIViewController *)viewController {
|
||||
- (BOOL)rightPanelStaysExtended {
|
||||
MFNumberOfDrawers numberOfDrawers = [self numberOfDrawersShouldShow:self.transitionWidth];
|
||||
return [self shouldExtendRightPanel:numberOfDrawers] && (numberOfDrawers != MFOneDrawer || self.explictlyShowingPanel != self.leftPanel);
|
||||
}
|
||||
|
||||
- (void)setRightPanelIsAccessible:(BOOL)rightPanelIsAccessible forViewController:(UIViewController *)viewController updateNavigationButtons:(BOOL)updateNavigationButtons {
|
||||
|
||||
if ([self.rightPanel respondsToSelector:@selector(panelAvailable)]) {
|
||||
self.rightPanelIsAccessible = rightPanelIsAccessible && [self.rightPanel panelAvailable];
|
||||
@ -458,8 +472,7 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
} else {
|
||||
|
||||
// Determine if we should show the right panel (extended based on width or from explicit action).
|
||||
MFNumberOfDrawers numberOfDrawers = [self numberOfDrawersShouldShow:self.transitionWidth];
|
||||
extended = [self shouldExtendRightPanel:numberOfDrawers] && (numberOfDrawers != MFOneDrawer || self.explictlyShowingPanel != self.leftPanel);
|
||||
extended = [self rightPanelStaysExtended];
|
||||
if (extended || self.explictlyShowingPanel == self.rightPanel) {
|
||||
[self showRightPanelAnimated:NO explict:NO];
|
||||
}
|
||||
@ -468,7 +481,10 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
[self.rightPanel resetIconToDefault];
|
||||
}
|
||||
}
|
||||
[self setRightNavigationItemForViewController:viewController accessible:rightPanelIsAccessible extended:extended];
|
||||
|
||||
if (updateNavigationButtons) {
|
||||
[self setRightNavigationItemForViewController:viewController accessible:rightPanelIsAccessible extended:extended];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
@ -958,11 +974,11 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
self.transitionWidth = @(size.width);
|
||||
|
||||
void (^animate)(id<UIViewControllerTransitionCoordinatorContext>) = nil;
|
||||
if (self.leftPanelIsAccessible || self.rightPanelIsAccessible) {
|
||||
// if (self.leftPanelIsAccessible || self.rightPanelIsAccessible) {
|
||||
animate = ^(id<UIViewControllerTransitionCoordinatorContext> context) {
|
||||
[self resetDrawers];
|
||||
};
|
||||
}
|
||||
// }
|
||||
|
||||
[coordinator animateAlongsideTransition:animate completion:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
|
||||
self.transitionWidth = nil;
|
||||
@ -974,11 +990,15 @@ CGFloat const PanelAnimationDuration = 0.2;
|
||||
}
|
||||
|
||||
- (void)resetDrawers {
|
||||
[self setLeftPanelIsAccessible:self.leftPanelIsAccessible forViewController:self.navigationItemViewController];
|
||||
[self setRightPanelIsAccessible:self.rightPanelIsAccessible forViewController:self.navigationItemViewController];
|
||||
|
||||
[self.view setNeedsLayout];
|
||||
[self.view layoutIfNeeded];
|
||||
if ([self.navigationItemViewController respondsToSelector:@selector(splitViewDidReset)]) {
|
||||
[((UIViewController<MVMCoreUIDetailViewProtocol> *)self.navigationItemViewController) splitViewDidReset];
|
||||
} else {
|
||||
[self setLeftPanelIsAccessible:self.leftPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES];
|
||||
[self setRightPanelIsAccessible:self.rightPanelIsAccessible forViewController:self.navigationItemViewController updateNavigationButtons:YES];
|
||||
|
||||
[self.view setNeedsLayout];
|
||||
[self.view layoutIfNeeded];
|
||||
}
|
||||
}
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user