diff --git a/MVMCoreUI.xcodeproj/project.pbxproj b/MVMCoreUI.xcodeproj/project.pbxproj index 0207bb62..20c02ce4 100644 --- a/MVMCoreUI.xcodeproj/project.pbxproj +++ b/MVMCoreUI.xcodeproj/project.pbxproj @@ -69,7 +69,7 @@ D29DF27621E79E81003B2FB9 /* MVMCoreUILoggingHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF27421E79E81003B2FB9 /* MVMCoreUILoggingHandler.m */; }; D29DF27921E7A533003B2FB9 /* MVMCoreUISession.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF27A21E7A533003B2FB9 /* MVMCoreUISession.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF27821E7A533003B2FB9 /* MVMCoreUISession.m */; }; - D29DF28021E7AA51003B2FB9 /* MVMCoreDetailViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF27F21E7AA50003B2FB9 /* MVMCoreDetailViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; D29DF28321E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */; }; D29DF28421E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */; }; D29DF28921E7AC2B003B2FB9 /* MFLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF28521E7AC2B003B2FB9 /* MFLabel.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -112,6 +112,7 @@ D29DF2CE21E7C104003B2FB9 /* MFLoadingViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */; }; D29DF2CF21E7C104003B2FB9 /* MFLoadingViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */; }; D29DF2D121E7C1C8003B2FB9 /* MVMAnimationFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D29DF2D021E7C1C8003B2FB9 /* MVMAnimationFramework.framework */; }; + D29DF2E121E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = D29DF2E021E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -187,7 +188,7 @@ D29DF27421E79E81003B2FB9 /* MVMCoreUILoggingHandler.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUILoggingHandler.m; sourceTree = ""; }; D29DF27721E7A533003B2FB9 /* MVMCoreUISession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MVMCoreUISession.h; sourceTree = ""; }; D29DF27821E7A533003B2FB9 /* MVMCoreUISession.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUISession.m; sourceTree = ""; }; - D29DF27F21E7AA50003B2FB9 /* MVMCoreDetailViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreDetailViewProtocol.h; sourceTree = ""; }; + D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIDetailViewProtocol.h; sourceTree = ""; }; D29DF28121E7AB23003B2FB9 /* MVMCoreUICommonViewsUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreUICommonViewsUtility.m; sourceTree = ""; }; D29DF28221E7AB24003B2FB9 /* MVMCoreUICommonViewsUtility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUICommonViewsUtility.h; sourceTree = ""; }; D29DF28521E7AC2B003B2FB9 /* MFLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLabel.h; sourceTree = ""; }; @@ -224,6 +225,7 @@ D29DF2CC21E7C104003B2FB9 /* MFLoadingViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFLoadingViewController.h; sourceTree = ""; }; D29DF2CD21E7C104003B2FB9 /* MFLoadingViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFLoadingViewController.m; sourceTree = ""; }; D29DF2D021E7C1C8003B2FB9 /* MVMAnimationFramework.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MVMAnimationFramework.framework; path = ../SharedFrameworks/MVMAnimationFramework.framework; sourceTree = ""; }; + D29DF2E021E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreUIPanelProtocol.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -507,7 +509,8 @@ D29DF2B621E7BE66003B2FB9 /* SplitViewController */ = { isa = PBXGroup; children = ( - D29DF27F21E7AA50003B2FB9 /* MVMCoreDetailViewProtocol.h */, + D29DF2E021E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h */, + D29DF27F21E7AA50003B2FB9 /* MVMCoreUIDetailViewProtocol.h */, D29DF15321E69760003B2FB9 /* MVMCoreUIPanelButtonProtocol.h */, D29DF11A21E684A9003B2FB9 /* MVMCoreUISplitViewController.h */, D29DF11B21E684A9003B2FB9 /* MVMCoreUISplitViewController.m */, @@ -577,7 +580,7 @@ D29DF13121E6851E003B2FB9 /* MVMCoreUITopAlertExpandableView.h in Headers */, D29DF2C421E7BF57003B2FB9 /* MFTabBarSwipeAnimator.h in Headers */, D29DF2CA21E7BFC8003B2FB9 /* MFSizeThreshold.h in Headers */, - D29DF28021E7AA51003B2FB9 /* MVMCoreDetailViewProtocol.h in Headers */, + D29DF28021E7AA51003B2FB9 /* MVMCoreUIDetailViewProtocol.h in Headers */, D29DF2BD21E7BEA4003B2FB9 /* MVMCoreUITabBarPageControlViewController.h in Headers */, D29DF12D21E6851E003B2FB9 /* MVMCoreUITopAlertBaseView.h in Headers */, D29DF24E21E6A177003B2FB9 /* MFDigitTextField.h in Headers */, @@ -588,6 +591,7 @@ D29DF2A121E7AF4E003B2FB9 /* MVMCoreUIUtility.h in Headers */, D29DF17621E69E1F003B2FB9 /* PrimaryButton.h in Headers */, D29DF2C821E7BFC1003B2FB9 /* MFSizeObject.h in Headers */, + D29DF2E121E9240B003B2FB9 /* MVMCoreUIPanelProtocol.h in Headers */, D29DF12921E6851E003B2FB9 /* MVMCoreUITopAlertMainView.h in Headers */, D29DF12C21E6851E003B2FB9 /* MVMCoreUITopAlertShortView.h in Headers */, ); diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreDetailViewProtocol.h deleted file mode 100644 index 853af619..00000000 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreDetailViewProtocol.h +++ /dev/null @@ -1,26 +0,0 @@ -// -// MVMCoreDetailViewProtocol.h -// MobileFirstFramework -// -// Created by Yang, Tianhang (Chris) on 11/14/18. -// Copyright © 2018 Verizon Wireless. All rights reserved. -// - -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -@protocol MVMCoreDetailViewProtocol - -@optional - -- (void)panelWillAppear:(nonnull NSObject *)panel; -- (void)panelDidAppear:(nonnull NSObject *)panel; - -- (void)panelWillDisappear:(nonnull NSObject *)panel; -- (void)panelDidDisappear:(nonnull NSObject *)panel; - -@end - -NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h new file mode 100644 index 00000000..5af78022 --- /dev/null +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h @@ -0,0 +1,29 @@ +// +// MVMCoreUIDetailViewProtocol.h +// MobileFirstFramework +// +// Created by Yang, Tianhang (Chris) on 11/14/18. +// Copyright © 2018 Verizon Wireless. All rights reserved. +// + +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol MVMCoreUIDetailViewProtocol + +@optional + +- (void)panelWillAppear:(nonnull NSObject *)panel; +- (void)panelDidAppear:(nonnull NSObject *)panel; + +- (void)panelWillDisappear:(nonnull NSObject *)panel; +- (void)panelDidDisappear:(nonnull NSObject *)panel; + +// Called when the back button is pressed. Overwrite for special functionality. +- (void)backButtonPressed; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h new file mode 100644 index 00000000..f90391d3 --- /dev/null +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIPanelProtocol.h @@ -0,0 +1,41 @@ +// +// MVMCoreUIPanelProtocol.h +// mobilefirst +// +// Created by Seshamani, Shreyas on 6/2/17. +// Copyright © 2017 Verizon Wireless. All rights reserved. +// + +#import +@protocol MVMCoreUIPanelProtocol + +#pragma mark - life cycle + +@optional + +// The panel can return if it should be available or not. +- (BOOL)panelAvailable; + +// Notified when it is appearing and disappearing. Called by the container. +- (void)willOpenWithActionInformation:(nullable NSDictionary *)actionInformation; +- (void)willAppear:(BOOL)animated; +- (void)didAppear:(BOOL)animated; +- (void)willDisappear:(BOOL)animated; +- (void)didDisappear:(BOOL)animated; + +// Can overide to return the image to use for the standard panel button. +- (nonnull UIImage *)imageForButtonForPanel; + +// Can overide to return the button to use for the panel. The selector should be the appropriate container selector otherwise the container will not work. +- (nonnull UIBarButtonItem *)buttonForPanel; + +// Notifies the panel if it should show its close button or hide it. Depends on width of screen if automatic extension. +- (void)showArrow; +- (void)hideArrow; + +// Gets called when we are restarting or clearing a session. +- (void)clearData; + +- (void)resetIconToDefault; + +@end diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index 18b18858..bb888bb2 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -8,15 +8,13 @@ // The main splitview controller. Handles the hamburger menu and other content. Used because at the time, apple's UISplitViewController wasn't robust enough to satisfy our needs. #import -#import -#import #import #import -#import "MVMCoreUIPanelButtonProtocol.h" +#import +#import @class SeparatorView; @class MVMCoreUITopAlertView; -@class MFSupportBarButtonItem; @class MFViewController; typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { @@ -27,13 +25,13 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { @interface MVMCoreUISplitViewController : UIViewController -// Reference to the main menu. -@property (nullable, weak, nonatomic, readonly) MFViewController *masterMenu; +// Reference to the panels. +@property (nullable, weak, nonatomic, readonly) UIViewController *leftPanel; +@property (nullable, weak, nonatomic, readonly) UIViewController *rightPanel; -// Reference to the support panel -@property (nullable, weak, nonatomic, readonly) MFViewController *supportPanel; - -@property (nullable, strong, nonatomic) MFSupportBarButtonItem *animatedSupportButton; +// Can be of protocol MVMCoreUIPanelButtonProtocol +@property (nullable, strong, nonatomic) UIBarButtonItem *leftPanelButton; +@property (nullable, strong, nonatomic) UIBarButtonItem *rightPanelButton; @property (nullable, weak, nonatomic, readonly) UINavigationController *navigationController; @@ -41,35 +39,22 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { @property (nullable, weak, nonatomic) MVMCoreUITopAlertView *topAlertView; @property (nullable, strong, nonatomic) SeparatorView *navigationBarSeparator; -@property (nullable, strong, nonatomic) NSDictionary *actionMapForCommunity; - -@property (nullable, weak, nonatomic) UIView *notificationDot; - +// Convenience getter + (nullable instancetype)mainSplitViewController; -// Sets if the master accessible for the view controller. Will show or hide the button. -- (void)setMasterIsAccessible:(BOOL)masterIsAccessible forViewController:(nonnull UIViewController *)viewController; +#pragma mark - Panel Functions -// Sets if the support accessible for the view controller. Will show or hide the button. -- (void)setSupportIsAccessible:(BOOL)supportIsAccessible forViewController:(nonnull UIViewController *)viewController; +// Sets if the left panel accessible for the view controller. Will show or hide the button. +- (void)setLeftPanelIsAccessible:(BOOL)leftPanelIsAccessible forViewController:(nonnull UIViewController *)viewController; -// Sets if community is accessible for the view controller. Will show or hide the button. -- (void)setCommunityIsAccessible:(BOOL)communityisAccessile forViewController:(nonnull UIViewController *)viewController; +// Sets if the right panel accessible for the view controller. Will show or hide the button. +- (void)setRightPanelIsAccessible:(BOOL)rightPanelIsAccessible forViewController:(nonnull UIViewController *)viewController; -// Sets the accessibility for the support and cart buttons, set close button if closeActionMap is available -- (void)setSupportIsAccessible:(BOOL)supportIsAccessible cartIsAccessible:(BOOL)cartIsAccessible communityIsAccessible:(BOOL)communityIsAccessible closeButtonActionMap:(nullable NSDictionary *)closeActionMap forViewController:(nonnull UIViewController *)viewController; +- (void)hideLeftPanelIfNeededAnimated:(BOOL)animated; +- (void)showLeftPanelAnimated:(BOOL)animated; -// Hides the master. -- (void)hideMasterIfNeededAnimated:(BOOL)animated; - -// Shows the master. -- (void)showMasterAnimated:(BOOL)animated; - -// Hides the support. -- (void)hideSupportIfNeededAnimated:(BOOL)animated; - -// Shows the support. -- (void)showSupportAnimated:(BOOL)animated; +- (void)hideRightPanelIfNeededAnimated:(BOOL)animated; +- (void)showRightPanelAnimated:(BOOL)animated; // Force hides both drawers. Does not animate or open always extended drawers on ipad either. - (void)forceHideBothDrawers; @@ -77,6 +62,15 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { // reset drawers - (void)resetDrawers; +// contains speicaly logic to set the support icon color +- (void)setNavigationIconColor:(nullable UIColor *)color; + +#pragma mark - Bottom Progress Bar + +- (void)setBottomProgressBarProgress:(float)progress; + +#pragma mark - Getters + // Returns the topmost visible view controller. This can also be the top level presented view controller. - (nullable UIViewController *)getCurrentVisibleController; @@ -86,15 +80,6 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { // Returns the current detail view controller only if it is an MFViewController. - (nullable MFViewController *)getCurrentDetailMFViewController; -- (void)setActionMapForCartButton:(nullable NSDictionary *)actionMap delegate:(nullable NSObject *)delegate; - -//- (void)setCloseButtonAccessibleWithCartIsAccessible:(BOOL)cartIsAccessible actionMap:(nullable NSDictionary *)actionMap forViewController:(nonnull UIViewController *)viewController; - -- (void)setBottomProgressBarProgress:(float)progress; - -// contains speicaly logic to set the support icon color -- (void)setNavigationIconColor:(nullable UIColor *)color; - // Provides the width of the detail view. + (CGFloat)getDetailViewWidth; @@ -108,7 +93,34 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { + (CGFloat)getApplicationViewWidth; + (CGFloat)getApplicationViewMaxSize; -// Show or hide the Notification dot on the menu button -- (void)showOrHideMenuButtonNotificationDot:(BOOL)hide; +#pragma mark - Main Subclassables + +// Can subclass to set threshold for when the drawers are permanently extended. Default is 1000 for the left panel and 2000 for both. +- (MFNumberOfDrawers)numberOfDrawersShouldShow:(NSNumber *)forWidth; + +// subclass to return panels +- (nullable UIViewController *)createLeftPanelViewController; +- (nullable UIViewController *)createRightPanelViewController; + +// subclass to change image of back button +- (nullable UIImage *)imageForBackButton; + +// Can overide to provide other global buttons to be on the navigation bar. +- (nullable NSArray *)additionalLeftButtons; +- (nullable NSArray *)additionalRightButtons; + +// The width of the panel when it is permanently extended. Default 320. +- (CGFloat)leftPanelExtendedWidth; +- (CGFloat)rightPanelExtendedWidth; + +// The maximum width of the panel. It will never grow past these sizes. Otherwise it is the size of the main view. +- (CGFloat)leftPanelMaxWidth; // Default 415 +- (CGFloat)rightPanelMaxWidth; // Default 500 + +#pragma mark - Button Presses + +- (IBAction)leftPanelButtonPressed:(id)sender; +- (IBAction)backButtonPressed:(id)sender; +- (IBAction)rightPanelButtonPressed:(id)sender; @end diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index edc1885d..033194d3 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -7,96 +7,67 @@ // #import "MVMCoreUISplitViewController.h" -#import #import #import +#import +#import +#import #import "MVMCoreUIUtility.h" #import "UIColor+MVMCoreUIConvenience.h" -#import -#import -#import -#import +#import "NSLayoutConstraint+MVMCoreUIConvenience.h" #import "MFViewController.h" #import "MFFonts.h" #import "MFLoadingViewController.h" #import "MFSizeObject.h" #import "SeparatorView.h" -#import "MFCustomButton.h" #import "MVMCoreUISession.h" #import "MVMCoreUIConstants.h" +#import "MVMCoreUICommonViewsUtility.h" @interface MVMCoreUISplitViewController () -@property (weak, nonatomic) UIView *masterView; -@property (weak, nonatomic) UIView *detailView; -@property (weak, nonatomic) UIView *supportView; -@property (weak, nonatomic) NSLayoutConstraint *detailViewLeading; -@property (weak, nonatomic) NSLayoutConstraint *detailViewTrailing; -@property (weak, nonatomic) NSLayoutConstraint *masterWidth; -@property (weak, nonatomic) NSLayoutConstraint *supportWidth; +@property (weak, nonatomic) UIView *leftView; +@property (weak, nonatomic) UIView *mainView; +@property (weak, nonatomic) UIView *rightView; +@property (weak, nonatomic) NSLayoutConstraint *mainViewLeading; +@property (weak, nonatomic) NSLayoutConstraint *mainViewTrailing; +@property (weak, nonatomic) NSLayoutConstraint *leftPanelWidth; +@property (weak, nonatomic) NSLayoutConstraint *rightPanelWidth; @property (weak, nonatomic) UIView *leftPanelSeparator; @property (weak, nonatomic) UIView *rightPanelSeparator; -@property (weak, nonatomic, readwrite) MFViewController *masterMenu; -@property (weak, nonatomic, readwrite) MFViewController *supportPanel; +@property (weak, nonatomic, readwrite) UIViewController *leftPanel; +@property (weak, nonatomic, readwrite) UIViewController *rightPanel; @property (weak, nonatomic, readwrite) UINavigationController *navigationController; // A view that covers the detail view when the master is out. -@property (weak, nonatomic) IBOutlet UIView *detailCoverView; - -@property (strong, nonatomic) UIBarButtonItem *mainMenuButton; +@property (weak, nonatomic) IBOutlet UIView *mainViewCoverView; @property (strong, nonatomic) UIBarButtonItem *backButton; -@property (strong, nonatomic) UIBarButtonItem *cartButton; -@property (strong, nonatomic) UIBarButtonItem *closeBarButton; + @property (weak, nonatomic) IBOutlet UIProgressView *bottomProgressBar; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomProgressBarHeightConstraint; @property (weak, nonatomic) MFLoadingViewController *loadingViewController; - -//typedef NS_ENUM(NSInteger, NavigationAnimationState) { -// NavAnimStateReady = 0, -// NavAnimStateInProgress, -// NavAnimStateDone -//}; -//@property (nonatomic) NavigationAnimationState showSupportAnimationState; -//@property (nonatomic) NavigationAnimationState showMainMenuAnimationState; - -@property (weak, nonatomic) UIViewController *animatingViewController; - -@property (strong, nonatomic) NSMutableArray *queuedRightBarButtonItems; - @property (nonatomic, strong) UIGestureRecognizer *tapToDismissGesture; -@property (nonatomic, strong) MFCustomButton *closeButton; -@property (nullable, readwrite, weak, nonatomic) NSObject *explictlyShowingPanel; -@property (nullable, weak, nonatomic) NSObject *prioritizedExtendedPanel; - -@property (strong, nonatomic) NSArray *addtionalRightNavigationItems; +@property (nullable, readwrite, weak, nonatomic) NSObject *explictlyShowingPanel; +@property (nullable, weak, nonatomic) NSObject *prioritizedExtendedPanel; typedef NS_OPTIONS(NSInteger, MFExtendedDrawer) { MFExtendedDrawerNone = 0, - MFExtendedDrawerSupport, - MFExtendedDrawerMenu + MFExtendedDrawerRight, + MFExtendedDrawerLeft }; -// Will re-write, just for demo @property (nonatomic) MFExtendedDrawer extendedDrawers; -@property (nonatomic) BOOL masterIsAccessible; -@property (nonatomic) BOOL supportIsAccessible; -@property (nonatomic) BOOL cartIsAccessible; -@property (nonatomic) BOOL communityIsAccessible; +@property (nonatomic) BOOL leftPanelIsAccessible; +@property (nonatomic) BOOL rightPanelIsAccessible; @property (weak, nonatomic) UIViewController *viewController; @property (strong, nonatomic) NSNumber *transitionWidth; -// The user pressed the master button. -- (IBAction)masterButtonPressed:(id)sender; - -// The user pressed the support button -- (IBAction)supportButtonPressed:(id)sender; - // Dismisses any panel - (void)dismissPanels:(id)sender; @@ -104,20 +75,15 @@ typedef NS_OPTIONS(NSInteger, MFExtendedDrawer) { @implementation MVMCoreUISplitViewController -CGFloat const ExtendedPanelWidth = 320; -CGFloat const MaxPanelWidth = 415; -CGFloat const MaxSupportPanelWidth = 500; CGFloat const PanelAnimationDuration = 0.2; -static NSString * const KeyGlobal_Nav = @"Global_Nav"; + (instancetype)mainSplitViewController { return [MVMCoreUISession sharedGlobal].splitViewController; } -#pragma mark - Master and Support Functions +#pragma mark - Main Subclassables -+ (MFNumberOfDrawers)numberOfDrawersShouldShow:(NSNumber *)forWidth { - +- (MFNumberOfDrawers)numberOfDrawersShouldShow:(NSNumber *)forWidth { CGFloat width; if (forWidth) { width = [forWidth floatValue]; @@ -127,32 +93,96 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; return (width > 2000 ? MFTwoDrawer : (width > 1000 ? MFOneDrawer : MFNoDrawer)); } -- (void)setLeftNavigationItemForPanel:(BOOL)accessible extended:(BOOL)extended viewController:(UIViewController * _Nonnull)viewController { - if ([viewController.navigationController.viewControllers count] > 1) { - if (!accessible || extended) { - // No menu button if always extended. - [viewController.navigationItem setLeftBarButtonItems:@[self.backButton] animated:!DisableAnimations]; +- (nullable UIViewController *)createLeftPanelViewController { + return nil; +} + +- (nullable UIViewController *)createRightPanelViewController { + return nil; +} + +- (nullable NSArray *)additionalLeftButtons { + return nil; +} + +- (nullable NSArray *)additionalRightButtons { + return nil; +} + +- (CGFloat)leftPanelExtendedWidth { + return 320; +} + +- (CGFloat)leftPanelMaxWidth { + return 415; +} + +- (CGFloat)rightPanelExtendedWidth { + return 320; +} + +- (CGFloat)rightPanelMaxWidth { + return 500; +} + +- (nullable UIImage *)imageForBackButton { + return [MVMCoreUIUtility imageNamed:@"back"]; +} + +#pragma mark - Button Presses + +- (IBAction)leftPanelButtonPressed:(id)sender { + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + if (self.mainViewLeading.constant < .1) { + + // Hide the keyboard + [self.navigationController.topViewController.view endEditing:YES]; + + // Show + [self showLeftPanelAnimated:YES]; } else { - // Back and menu - [viewController.navigationItem setLeftBarButtonItems:@[self.backButton, self.mainMenuButton] animated:!DisableAnimations]; + // Hide + [self hideLeftPanelIfNeededAnimated:YES]; } - } else if (!accessible || extended) { - // No menu button if always extended. - [viewController.navigationItem setLeftBarButtonItems:nil animated:NO]; - } else { - // Just menu button - [viewController.navigationItem setLeftBarButtonItems:@[self.mainMenuButton] animated:NO]; - } + }]; } -- (BOOL)shouldExtendMaster { - MFNumberOfDrawers numberOfDrawers = [MVMCoreUISplitViewController numberOfDrawersShouldShow:self.transitionWidth]; - return [self shouldExtendMaster:numberOfDrawers]; +- (IBAction)backButtonPressed:(id)sender { + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + UIViewController *viewController = self.navigationController.topViewController; + if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] && [viewController respondsToSelector:@selector(backButtonPressed)]) { + [((UIViewController *)viewController) backButtonPressed]; + } else { + [[MVMCoreNavigationHandler sharedNavigationHandler] popTopViewControllerAnimated:YES]; + } + }]; } -- (BOOL)shouldExtendMaster:(MFNumberOfDrawers)numberOfDrawers { - if (!(self.extendedDrawers & MFExtendedDrawerMenu)) { - // Master not set to be extended. +- (IBAction)rightPanelButtonPressed:(id)sender { + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + if (self.mainViewTrailing.constant < .1) { + // Hide the keyboard + [self.navigationController.topViewController.view endEditing:YES]; + + // Show + [self showRightPanelAnimated:YES]; + } else { + // Hide + [self hideRightPanelIfNeededAnimated:YES]; + } + }]; +} + +#pragma mark - Left Panel Functions + +- (BOOL)shouldExtendLeftPanel { + MFNumberOfDrawers numberOfDrawers = [self numberOfDrawersShouldShow:self.transitionWidth]; + return [self shouldExtendLeftPanel:numberOfDrawers]; +} + +- (BOOL)shouldExtendLeftPanel:(MFNumberOfDrawers)numberOfDrawers { + if (!(self.extendedDrawers & MFExtendedDrawerLeft)) { + // Left panel not set to be extended. return NO; } else { if (numberOfDrawers == MFTwoDrawer) { @@ -162,62 +192,200 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; // No drawer is extended. return NO; } else { - // master is extended if the support panel isn't prioritized. - return self.prioritizedExtendedPanel != self.supportPanel; + // left is extended if the right panel isn't prioritized. + return self.prioritizedExtendedPanel != self.rightPanel; } } } -- (void)setMasterIsAccessible:(BOOL)masterIsAccessible forViewController:(UIViewController *)viewController { - - if ([self.masterMenu respondsToSelector:@selector(panelAvailable)]) { - self.masterIsAccessible = masterIsAccessible && [self.masterMenu panelAvailable]; +- (void)setLeftNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended { + NSMutableArray *leftBarButtonItems = [NSMutableArray array]; + if ([viewController.navigationController.viewControllers count] > 1) { + [leftBarButtonItems addObject:self.backButton]; + } + if ((accessible || !extended) && self.leftPanelButton) { + [leftBarButtonItems addObject:self.leftPanelButton]; + } + NSArray *extraButtons = [self additionalLeftButtons]; + if (extraButtons) { + [leftBarButtonItems addObjectsFromArray:extraButtons]; + } + [viewController.navigationItem setLeftBarButtonItems:(leftBarButtonItems.count > 0 ? leftBarButtonItems : nil) animated:!DisableAnimations]; +} + +- (void)setLeftPanelIsAccessible:(BOOL)leftPanelIsAccessible forViewController:(UIViewController *)viewController { + if ([self.leftPanel respondsToSelector:@selector(panelAvailable)]) { + self.leftPanelIsAccessible = leftPanelIsAccessible && [self.leftPanel panelAvailable]; } else { - self.masterIsAccessible = masterIsAccessible; + self.leftPanelIsAccessible = leftPanelIsAccessible; } self.viewController = viewController; [MVMCoreDispatchUtility performBlockOnMainThread:^{ - - // TODO: Scott, may need to update this due to TabBar having own navigation. BOOL extended = NO; - if (!self.masterIsAccessible) { + if (!self.leftPanelIsAccessible) { - // Hides master if showing. - [self hideMasterAnimated:NO]; + // Hides panel if showing. + [self hideLeftPanelAnimated:NO]; } 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); + if (extended || self.explictlyShowingPanel == self.leftPanel) { + [self showLeftPanelAnimated:NO explict:NO]; + } - // Determine if we should show the master (extended based on width or from explicit action). - MFNumberOfDrawers numberOfDrawers = [MVMCoreUISplitViewController numberOfDrawersShouldShow:self.transitionWidth]; - extended = [self shouldExtendMaster:numberOfDrawers] && (numberOfDrawers != MFOneDrawer || self.explictlyShowingPanel != self.supportPanel); - if (extended || self.explictlyShowingPanel == self.masterMenu) { - [self showMasterAnimated:NO explict:NO]; + if ([self.leftPanel respondsToSelector:@selector(resetIconToDefault)]) { + [self.leftPanel resetIconToDefault]; } } - [self setLeftNavigationItemForPanel:self.masterIsAccessible extended:extended viewController:viewController]; + [self setLeftNavigationItemForViewController:viewController accessible:self.leftPanelIsAccessible extended:extended]; }]; } -- (void)setRightNavigationItemForPanel:(BOOL)accessible extended:(BOOL)extended viewController:(UIViewController * _Nonnull)viewController { - NSMutableArray *navigationItems = [[NSMutableArray alloc] init]; - [navigationItems addObjectsFromArray:self.addtionalRightNavigationItems]; - if (!accessible || extended) { - [viewController.navigationItem setRightBarButtonItems:navigationItems animated:NO]; - } else { - if (self.animatedSupportButton) { - [navigationItems insertObject:self.animatedSupportButton atIndex:0]; +- (nonnull void (^)(void))getLeftPanelShowAnimationBlock { + MFNumberOfDrawers numberOfDrawers = [self numberOfDrawersShouldShow:self.transitionWidth]; + return ^{ + + // Bring panel onto screen. + self.mainViewLeading.constant = self.leftPanelWidth.constant; + + // Make main view untouchable if panel is not extended. + if (![self shouldExtendLeftPanel:numberOfDrawers]) { + self.mainViewCoverView.alpha = 0.3; + + // right drawer is not always extended or we cannot fit both drawers + if (!(self.extendedDrawers & MFExtendedDrawerRight) || numberOfDrawers == MFNoDrawer) { + self.mainViewTrailing.constant = -self.leftPanelWidth.constant; + } else if (numberOfDrawers < MFTwoDrawer) { + self.mainViewTrailing.constant = -self.leftPanelWidth.constant + self.rightPanelWidth.constant; + } } - [viewController.navigationItem setRightBarButtonItems:navigationItems animated:NO]; + [self.view layoutIfNeeded]; + }; +} + +- (void)hideLeftPanelIfNeededAnimated:(BOOL)animated { + if (![self shouldExtendLeftPanel] || self.explictlyShowingPanel == self.leftPanel) { + [self hideLeftPanelAnimated:animated]; } } -- (BOOL)shouldExtendSupport { - MFNumberOfDrawers numberOfDrawers = [MVMCoreUISplitViewController numberOfDrawersShouldShow:self.transitionWidth]; - return [self shouldExtendSupport:numberOfDrawers]; +- (void)hideLeftPanelAnimated:(BOOL)animated { + [self hideLeftPanelAnimated:animated checkingForOtherExtendedDrawers:YES]; } -- (BOOL)shouldExtendSupport:(MFNumberOfDrawers)numberOfDrawers { - if (!(self.extendedDrawers & MFExtendedDrawerSupport)) { - // Support not set to be extended. +- (void)hideLeftPanelAnimated:(BOOL)animated checkingForOtherExtendedDrawers:(BOOL)checkingForOtherExtendedDrawers { + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + if (self.mainViewLeading.constant > .1) { + if (checkingForOtherExtendedDrawers && self.explictlyShowingPanel == self.leftPanel) { + self.explictlyShowingPanel = nil; + } + void (^animation)(void) = ^{ + self.mainViewCoverView.alpha = 0; + self.mainViewLeading.constant = 0; + + // If the support drawer should be extended, make sure it's extended. + if (checkingForOtherExtendedDrawers && self.rightPanelIsAccessible && [self shouldExtendRightPanel]) { + void (^showRightPanel)(void) = [self getRightPanelShowAnimationBlock]; + showRightPanel(); + } else { + self.mainViewTrailing.constant = 0; + } + [self.view layoutIfNeeded]; + }; + + void (^completion)(BOOL) = ^(BOOL finished){ + self.mainViewCoverView.hidden = YES; + [self panelDidDisappear:self.leftPanel animated:animated]; + self.mainView.accessibilityElementsHidden = NO; + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.mainView); + }; + + [self.leftPanelSeparator removeFromSuperview]; + [self panelWillDisappear:self.leftPanel animated:animated]; + if (animated) { + [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animation completion:completion]; + } else { + animation(); + completion(NO); + } + } + }]; +} + +- (void)showLeftPanelAnimated:(BOOL)animated explict:(BOOL)explict { + [MVMCoreDispatchUtility performBlockOnMainThread:^{ + if (self.mainViewLeading.constant < .1) { + if (explict) { + self.explictlyShowingPanel = self.leftPanel; + } + void (^animations)(void) = [self getLeftPanelShowAnimationBlock]; + + void (^completion)(BOOL) = ^(BOOL finished){ + [self panelDidAppear:self.leftPanel animated:animated]; + }; + + if (![self shouldExtendLeftPanel]) { + if ([self.leftPanel respondsToSelector:@selector(showArrow)]){ + [self.leftPanel showArrow]; + } + self.mainView.accessibilityElementsHidden = YES; + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil); + } else { + if ([self.leftPanel respondsToSelector:@selector(hideArrow)]){ + [self.leftPanel hideArrow]; + } + + UIView *leftPanelSeparator = [[UIView alloc] init]; + leftPanelSeparator.backgroundColor = [UIColor mfSilver]; + leftPanelSeparator.translatesAutoresizingMaskIntoConstraints = NO; + [self.view addSubview:leftPanelSeparator]; + [leftPanelSeparator.widthAnchor constraintEqualToConstant:1].active = YES; + [leftPanelSeparator.leftAnchor constraintEqualToAnchor:self.leftView.rightAnchor].active = YES; + [leftPanelSeparator.topAnchor constraintEqualToAnchor:self.mainView.topAnchor].active = YES; + [leftPanelSeparator.bottomAnchor constraintEqualToAnchor:self.mainView.bottomAnchor].active = YES; + self.leftPanelSeparator = leftPanelSeparator; + } + + self.mainViewCoverView.hidden = NO; + [self panelWillAppear:self.leftPanel animated:animated]; + if (animated) { + [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion]; + } else { + animations(); + completion(NO); + } + } + }]; +} + +- (void)showLeftPanelAnimated:(BOOL)animated { + [self showLeftPanelAnimated:animated explict:YES]; +} + +#pragma mark - Right Panel Functions + +- (void)setRightNavigationItemForViewController:(UIViewController * _Nonnull)viewController accessible:(BOOL)accessible extended:(BOOL)extended { + NSMutableArray *navigationItems = [[NSMutableArray alloc] init]; + if ((accessible || !extended) && self.rightPanelButton) { + [navigationItems addObject:self.rightPanelButton]; + } + NSArray *extraButtons = [self additionalRightButtons]; + if (extraButtons) { + [navigationItems addObjectsFromArray:extraButtons]; + } + [viewController.navigationItem setRightBarButtonItems:(navigationItems.count > 0 ? navigationItems : nil) animated:!DisableAnimations]; +} + +- (BOOL)shouldExtendRightPanel { + MFNumberOfDrawers numberOfDrawers = [self numberOfDrawersShouldShow:self.transitionWidth]; + return [self shouldExtendRightPanel:numberOfDrawers]; +} + +- (BOOL)shouldExtendRightPanel:(MFNumberOfDrawers)numberOfDrawers { + if (!(self.extendedDrawers & MFExtendedDrawerRight)) { + // Panel not set to be extended. return NO; } else { if (numberOfDrawers == MFTwoDrawer) { @@ -228,403 +396,104 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; return NO; } else { // Extend support if the master panel isn't prioritized. - return self.prioritizedExtendedPanel != self.masterMenu; + return self.prioritizedExtendedPanel != self.leftPanel; } } } -- (void)setSupportIsAccessible:(BOOL)supportIsAccessible forViewController:(UIViewController *)viewController { +- (void)setRightPanelIsAccessible:(BOOL)rightPanelIsAccessible forViewController:(UIViewController *)viewController { - if ([self.supportPanel respondsToSelector:@selector(panelAvailable)]) { - self.supportIsAccessible = supportIsAccessible && [self.supportPanel panelAvailable]; + if ([self.rightPanel respondsToSelector:@selector(panelAvailable)]) { + self.rightPanelIsAccessible = rightPanelIsAccessible && [self.rightPanel panelAvailable]; } else { - self.supportIsAccessible = supportIsAccessible; + self.rightPanelIsAccessible = rightPanelIsAccessible; } self.viewController = viewController; [MVMCoreDispatchUtility performBlockOnMainThread:^{ BOOL extended = NO; - if (!supportIsAccessible) { + if (!rightPanelIsAccessible) { - // Hides support if showing. - [self hideSupportAnimated:NO]; + // Hides panel if showing. + [self hideRightPanelAnimated:NO]; } else { - // Determine if we should show the support (extended based on width or from explicit action). - MFNumberOfDrawers numberOfDrawers = [MVMCoreUISplitViewController numberOfDrawersShouldShow:self.transitionWidth]; - extended = [self shouldExtendSupport:numberOfDrawers] && (numberOfDrawers != MFOneDrawer || self.explictlyShowingPanel != self.masterMenu); - if (extended || self.explictlyShowingPanel == self.supportPanel) { - [self showSupportAnimated:NO explict:NO]; + // 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); + if (extended || self.explictlyShowingPanel == self.rightPanel) { + [self showRightPanelAnimated:NO explict:NO]; } - if ([self.supportPanel respondsToSelector:@selector(resetIconToDefault)]) { - [self.supportPanel resetIconToDefault]; + if ([self.rightPanel respondsToSelector:@selector(resetIconToDefault)]) { + [self.rightPanel resetIconToDefault]; } } - [self setRightNavigationItemForPanel:supportIsAccessible extended:extended viewController:viewController]; + [self setRightNavigationItemForViewController:viewController accessible:rightPanelIsAccessible extended:extended]; }]; } -- (UIBarButtonItem *)createCommunityBarButtonItem { - - UIImage *communityImage = [[MVMCoreUIUtility imageNamed:@"icon_nav_community_selected"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; - UIBarButtonItem *communityButton = [[UIBarButtonItem alloc] initWithImage:communityImage style:UIBarButtonItemStylePlain target:self action:@selector(communityButtonPressed:)]; - communityButton.width = 25.0; - return communityButton; -} - -- (void)setCommunityIsAccessible:(BOOL)communityIsAccessible forViewController:(nonnull UIViewController *)viewController { - - self.communityIsAccessible = communityIsAccessible; - if (communityIsAccessible) { - UIBarButtonItem *communityButton = [self createCommunityBarButtonItem]; - [viewController.navigationItem setRightBarButtonItems:@[communityButton]]; - } -} - -- (void)setSupportIsAccessible:(BOOL)supportIsAccessible cartIsAccessible:(BOOL)cartIsAccessible communityIsAccessible:(BOOL)communityIsAccessible closeButtonActionMap:(NSDictionary *)closeActionMap forViewController:(UIViewController *)viewController { - - self.communityIsAccessible = communityIsAccessible; - if (communityIsAccessible) { - supportIsAccessible = NO; - self.supportIsAccessible = NO; - } else if ([self.supportPanel respondsToSelector:@selector(panelAvailable)]) { - self.supportIsAccessible = supportIsAccessible && [self.supportPanel panelAvailable]; - } else { - self.supportIsAccessible = supportIsAccessible; - } - - self.cartIsAccessible = cartIsAccessible; - self.viewController = viewController; - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - - NSMutableArray *rightBarButtonItems = [[NSMutableArray alloc] init]; - - BOOL extended = NO; - if (!supportIsAccessible) { - [self hideSupportAnimated:NO]; - } else { - - // Determine if we should show the support (extended based on width or from explicit action). - MFNumberOfDrawers numberOfDrawers = [MVMCoreUISplitViewController numberOfDrawersShouldShow:self.transitionWidth]; - extended = [self shouldExtendSupport:numberOfDrawers] && (numberOfDrawers != MFOneDrawer || self.explictlyShowingPanel != self.masterMenu); - if (extended || self.explictlyShowingPanel == self.supportPanel) { - [self showSupportAnimated:NO explict:NO]; - } - - if ([self.supportPanel respondsToSelector:@selector(resetIconToDefault)]) { - [self.supportPanel resetIconToDefault]; - } - - //notify support data pass handler to send data pass for shop - [[NSNotificationCenter defaultCenter] postNotificationName:NotificationLivechatDatapass object:nil userInfo:@{@"type":@"shop"}]; - - if (!extended && self.animatingViewController == viewController) { - [self.queuedRightBarButtonItems removeAllObjects]; - [self.queuedRightBarButtonItems addObject:self.animatedSupportButton]; - if (cartIsAccessible) { - [self.queuedRightBarButtonItems addObject:self.cartButton]; - [self.cartButtonView setWithActionMap:[ShopCart sharedCartInstance].cartButtonActionMap delegate:viewController additionalData:nil]; - } - return; - } - - } - - if (communityIsAccessible) { - UIBarButtonItem *communityButton = [self createCommunityBarButtonItem]; - [rightBarButtonItems addObject:communityButton]; - } - - if (closeActionMap.count) { - self.closeButton = [[MFCustomButton alloc]initWithFrame:CGRectMake(0, 0, CloseButtonWidth, CloseButtonHeight)]; - [self.closeButton setContentMode:UIViewContentModeCenter]; - [self.closeButton setImage:[MVMCoreUIUtility imageNamed:@"close"] forState:UIControlStateNormal]; - - [self.closeButton setWithActionMap:closeActionMap delegate:viewController - additionalData:nil]; - - // Setting blank title explicitly because server is not able to send blank title - [self.closeButton setTitle:@"" forState:UIControlStateNormal]; - - self.closeBarButton = [[UIBarButtonItem alloc] initWithCustomView:self.closeButton]; - [rightBarButtonItems addObject:self.closeBarButton]; - - UIBarButtonItem *fixedSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; - fixedSpace.width = 10.0f; - [rightBarButtonItems addObject:fixedSpace]; - } - - if (cartIsAccessible) { - [rightBarButtonItems addObject:self.cartButton]; - - [self.cartButtonView setWithActionMap:[ShopCart sharedCartInstance].cartButtonActionMap delegate:viewController additionalData:nil]; - - // Cart icon should not be enabled if we are already on the cart screen - self.cartButtonView.enabled = ![self.getCurrentDetailViewController isKindOfClass:[CartViewController class]]; - } - self.addtionalRightNavigationItems = rightBarButtonItems; - [self setRightNavigationItemForPanel:supportIsAccessible extended:extended viewController:viewController]; - - if ([self.supportPanel respondsToSelector:@selector(resetIconToDefault)]) { - - [self.supportPanel resetIconToDefault]; - [self.supportPanel resetIconToDefault]; - } - }]; -} - -- (IBAction)masterButtonPressed:(id)sender { - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - if (self.detailViewLeading.constant < .1) { - - // Hide the keyboard - [self.navigationController.topViewController.view endEditing:YES]; - - // Show - [self showMasterAnimated:YES]; - } else { - // Hide - [self hideMasterIfNeededAnimated:YES]; - } - [self sentTrackerDatabyLinkName:@"nav"]; - }]; -} - -- (IBAction)supportButtonPressed:(id)sender { - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - if (self.detailViewTrailing.constant < .1) { - // Hide the keyboard - [self.navigationController.topViewController.view endEditing:YES]; - - // Show - [self showSupportAnimated:YES]; - } else { - // Hide - [self hideSupportIfNeededAnimated:YES]; - } - [self sentTrackerDatabyLinkName:@"support"]; - }]; -} - -- (IBAction)communityButtonPressed:(id)sender { - - if (self.actionMapForCommunity) { - MFViewController *currentViewController = [self getCurrentDetailMFViewController]; - if (currentViewController) { - [MVMCoreActionHandler.sharedActionHandler handleActionWithDictionary:self.actionMapForCommunity additionalData:nil delegate:currentViewController]; - } - } -} - -- (IBAction)backButtonPressed:(id)sender { - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - UIViewController *viewController = self.navigationController.topViewController; - if ([viewController conformsToProtocol:@protocol(MVMCoreViewControllerProtocol)] && [viewController respondsToSelector:@selector(backButtonPressed)]) { - [((UIViewController *)viewController) backButtonPressed]; - } else { - [[MVMCoreNavigationHandler sharedNavigationHandler] popTopViewControllerAnimated:YES]; - } - [self sentTrackerDatabyLinkName:@"back"]; - }]; -} - -- (nonnull void (^)(void))getMenuShowAnimationBlock { - MFNumberOfDrawers numberOfDrawers = [MVMCoreUISplitViewController numberOfDrawersShouldShow:self.transitionWidth]; +- (nonnull void (^)(void))getRightPanelShowAnimationBlock { + MFNumberOfDrawers numberOfDrawers = [self numberOfDrawersShouldShow:self.transitionWidth]; return ^{ - // Bring master onto screen. - self.detailViewLeading.constant = self.masterWidth.constant; + // Bring right panel onto screen. + self.mainViewTrailing.constant = self.rightPanelWidth.constant; - // Make detail view untouchable if master is not extended. - if (![self shouldExtendMaster:numberOfDrawers]) { - self.detailCoverView.alpha = 0.3; + // Right Panel is not always extended, make detail view untouchable + if (![self shouldExtendRightPanel:numberOfDrawers]) { + self.mainViewCoverView.alpha = 0.3; - // Support drawer is not always extended or we cannot fit both drawers - if (!(self.extendedDrawers & MFExtendedDrawerSupport) || numberOfDrawers == MFNoDrawer) { - self.detailViewTrailing.constant = -self.masterWidth.constant; + // Right drawer is not always extended or we cannot fit both drawers + if (!(self.extendedDrawers & MFExtendedDrawerLeft) || numberOfDrawers == MFNoDrawer) { + self.mainViewLeading.constant = -self.rightPanelWidth.constant; } else if (numberOfDrawers < MFTwoDrawer) { - self.detailViewTrailing.constant = -self.masterWidth.constant + self.supportWidth.constant; + self.mainViewLeading.constant = -self.rightPanelWidth.constant + self.leftPanelWidth.constant; } } [self.view layoutIfNeeded]; }; } -- (nonnull void (^)(void))getSupportShowAnimationBlock { - MFNumberOfDrawers numberOfDrawers = [MVMCoreUISplitViewController numberOfDrawersShouldShow:self.transitionWidth]; - return ^{ - - // Bring support onto screen. - self.detailViewTrailing.constant = self.supportWidth.constant; - - // Support is not always extended, make detail view untouchable - if (![self shouldExtendSupport:numberOfDrawers]) { - self.detailCoverView.alpha = 0.3; - - // Support drawer is not always extended or we cannot fit both drawers - if (!(self.extendedDrawers & MFExtendedDrawerMenu) || numberOfDrawers == MFNoDrawer) { - self.detailViewLeading.constant = -self.supportWidth.constant; - } else if (numberOfDrawers < MFTwoDrawer) { - self.detailViewLeading.constant = -self.supportWidth.constant + self.masterWidth.constant; - } - } - [self.view layoutIfNeeded]; - }; -} - - -- (void)hideMasterIfNeededAnimated:(BOOL)animated { - if (![self shouldExtendMaster] || self.explictlyShowingPanel == self.masterMenu) { - [self hideMasterAnimated:animated]; +- (void)hideRightPanelIfNeededAnimated:(BOOL)animated { + if (![self shouldExtendRightPanel] || self.explictlyShowingPanel == self.rightPanel) { + [self hideRightPanelAnimated:animated]; } } -- (void)hideMasterAnimated:(BOOL)animated { - [self hideMasterAnimated:animated checkingForOtherExtendedDrawers:YES]; +- (void)hideRightPanelAnimated:(BOOL)animated { + [self hideRightPanelAnimated:animated checkingForOtherExtendedDrawers:YES]; } -- (void)hideMasterAnimated:(BOOL)animated checkingForOtherExtendedDrawers:(BOOL)checkingForOtherExtendedDrawers { +- (void)hideRightPanelAnimated:(BOOL)animated checkingForOtherExtendedDrawers:(BOOL)checkingForOtherExtendedDrawers { [MVMCoreDispatchUtility performBlockOnMainThread:^{ - if (self.detailViewLeading.constant > .1) { - if (checkingForOtherExtendedDrawers && self.explictlyShowingPanel == self.masterMenu) { + if (self.mainViewTrailing.constant > .1) { + if (checkingForOtherExtendedDrawers && self.explictlyShowingPanel == self.rightPanel) { self.explictlyShowingPanel = nil; } void (^animation)(void) = ^{ - self.detailCoverView.alpha = 0; - self.detailViewLeading.constant = 0; - - // If the support drawer should be extended, make sure it's extended. - if (checkingForOtherExtendedDrawers && self.supportIsAccessible && [self shouldExtendSupport]) { - void (^showSupport)(void) = [self getSupportShowAnimationBlock]; - showSupport(); - } else { - self.detailViewTrailing.constant = 0; - } - [self.view layoutIfNeeded]; - }; - - void (^completion)(BOOL) = ^(BOOL finished){ - self.detailCoverView.hidden = YES; - [self panelDidDisappear:self.masterMenu animated:animated]; - - self.detailView.accessibilityElementsHidden = NO; - UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.detailView); - - }; - - [self.leftPanelSeparator removeFromSuperview]; - - [self panelWillDisappear:self.masterMenu animated:animated]; - - if (animated) { - [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animation completion:completion]; - } else { - animation(); - completion(NO); - } - } - }]; -} - - -- (void)showMasterAnimated:(BOOL)animated explict:(BOOL)explict { - - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - if (self.detailViewLeading.constant < .1) { - if (explict) { - self.explictlyShowingPanel = self.masterMenu; - } - void (^animations)(void) = [self getMenuShowAnimationBlock]; - - void (^completion)(BOOL) = ^(BOOL finished){ - [self panelDidAppear:self.masterMenu animated:animated]; - }; - - // show or hide arrow. - if (![self shouldExtendMaster]) { - if ([self.masterMenu respondsToSelector:@selector(showArrow)]){ - [self.masterMenu showArrow]; - } - self.detailView.accessibilityElementsHidden = YES; - UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil); - } else { - if ([self.masterMenu respondsToSelector:@selector(hideArrow)]){ - [self.masterMenu hideArrow]; - } - - UIView *leftPanelSeparator = [[UIView alloc] init]; - leftPanelSeparator.backgroundColor = [UIColor mfSilver]; - leftPanelSeparator.translatesAutoresizingMaskIntoConstraints = NO; - [self.view addSubview:leftPanelSeparator]; - [leftPanelSeparator.widthAnchor constraintEqualToConstant:1].active = YES; - [leftPanelSeparator.leftAnchor constraintEqualToAnchor:self.masterView.rightAnchor].active = YES; - [leftPanelSeparator.topAnchor constraintEqualToAnchor:self.detailView.topAnchor].active = YES; - [leftPanelSeparator.bottomAnchor constraintEqualToAnchor:self.detailView.bottomAnchor].active = YES; - self.leftPanelSeparator = leftPanelSeparator; - } - - self.detailCoverView.hidden = NO; - [self panelWillAppear:self.masterMenu animated:animated]; - if (animated) { - [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion]; - } else { - animations(); - completion(NO); - } - - if ([self.masterMenu respondsToSelector:@selector(getCurrentDetailViewController:)]) { - [self.masterMenu getCurrentDetailViewController:[self getCurrentDetailViewController]]; - } - } - }]; -} - -- (void)showMasterAnimated:(BOOL)animated { - [self showMasterAnimated:animated explict:YES]; -} - -- (void)hideSupportIfNeededAnimated:(BOOL)animated { - if (![self shouldExtendSupport] || self.explictlyShowingPanel == self.supportPanel) { - [self hideSupportAnimated:animated]; - } -} - -- (void)hideSupportAnimated:(BOOL)animated { - [self hideSupportAnimated:animated checkingForOtherExtendedDrawers:YES]; -} - -- (void)hideSupportAnimated:(BOOL)animated checkingForOtherExtendedDrawers:(BOOL)checkingForOtherExtendedDrawers { - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - if (self.detailViewTrailing.constant > .1) { - if (checkingForOtherExtendedDrawers && self.explictlyShowingPanel == self.supportPanel) { - self.explictlyShowingPanel = nil; - } - void (^animation)(void) = ^{ - self.detailCoverView.alpha = 0; - self.detailViewTrailing.constant = 0; + self.mainViewCoverView.alpha = 0; + self.mainViewTrailing.constant = 0; // If the menu drawer should be extended, make sure it's extended. - if (checkingForOtherExtendedDrawers && self.masterIsAccessible && [self shouldExtendMaster]) { - void (^showMenu)(void) = [self getMenuShowAnimationBlock]; - showMenu(); + if (checkingForOtherExtendedDrawers && self.leftPanelIsAccessible && [self shouldExtendLeftPanel]) { + void (^showRightPanel)(void) = [self getLeftPanelShowAnimationBlock]; + showRightPanel(); } else { - self.detailViewLeading.constant = 0; + self.mainViewLeading.constant = 0; } [self.view layoutIfNeeded]; }; void (^completion)(BOOL) = ^(BOOL finished){ - self.detailCoverView.hidden = YES; - [self panelDidDisappear:self.supportPanel animated:animated]; - self.detailView.accessibilityElementsHidden = NO; - UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.detailView); + self.mainViewCoverView.hidden = YES; + [self panelDidDisappear:self.rightPanel animated:animated]; + self.mainView.accessibilityElementsHidden = NO; + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.mainView); }; [self.rightPanelSeparator removeFromSuperview]; - - [self panelWillDisappear:self.supportPanel animated:animated]; - + [self panelWillDisappear:self.rightPanel animated:animated]; if (animated) { [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animation completion:completion]; } else { @@ -635,30 +504,28 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; }]; } -- (void)showSupportAnimated:(BOOL)animated explict:(BOOL)explict { +- (void)showRightPanelAnimated:(BOOL)animated explict:(BOOL)explict { [MVMCoreDispatchUtility performBlockOnMainThread:^{ - if (self.detailViewTrailing.constant < .1) { + if (self.mainViewTrailing.constant < .1) { if (explict) { - self.explictlyShowingPanel = self.supportPanel; + self.explictlyShowingPanel = self.rightPanel; } - void (^animations)(void) = [self getSupportShowAnimationBlock]; + void (^animations)(void) = [self getRightPanelShowAnimationBlock]; void (^completion)(BOOL) = ^(BOOL finished){ - [self panelDidAppear:self.supportPanel animated:animated]; - self.detailView.accessibilityElementsHidden = YES; - UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.supportPanel); + [self panelDidAppear:self.rightPanel animated:animated]; + self.mainView.accessibilityElementsHidden = YES; + UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, self.rightPanel); }; - self.detailCoverView.hidden = NO; - - // show or hide arrow. - if (![self shouldExtendSupport]) { - if ([self.supportPanel respondsToSelector:@selector(showArrow)]){ - [self.supportPanel showArrow]; + self.mainViewCoverView.hidden = NO; + if (![self shouldExtendRightPanel]) { + if ([self.rightPanel respondsToSelector:@selector(showArrow)]){ + [self.rightPanel showArrow]; } } else { - if ([self.supportPanel respondsToSelector:@selector(hideArrow)]){ - [self.supportPanel hideArrow]; + if ([self.rightPanel respondsToSelector:@selector(hideArrow)]){ + [self.rightPanel hideArrow]; } UIView *rightPanelSeparator = [[UIView alloc] init]; @@ -666,14 +533,13 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; rightPanelSeparator.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:rightPanelSeparator]; [rightPanelSeparator.widthAnchor constraintEqualToConstant:1].active = YES; - [rightPanelSeparator.leftAnchor constraintEqualToAnchor:self.supportView.leftAnchor].active = YES; - [rightPanelSeparator.topAnchor constraintEqualToAnchor:self.detailView.topAnchor].active = YES; - [rightPanelSeparator.bottomAnchor constraintEqualToAnchor:self.detailView.bottomAnchor].active = YES; + [rightPanelSeparator.leftAnchor constraintEqualToAnchor:self.rightView.leftAnchor].active = YES; + [rightPanelSeparator.topAnchor constraintEqualToAnchor:self.mainView.topAnchor].active = YES; + [rightPanelSeparator.bottomAnchor constraintEqualToAnchor:self.mainView.bottomAnchor].active = YES; self.rightPanelSeparator = rightPanelSeparator; } - [self panelWillAppear:self.supportPanel animated:animated]; - + [self panelWillAppear:self.rightPanel animated:animated]; if (animated) { [UIView animateWithDuration:PanelAnimationDuration delay:0 options:UIViewAnimationOptionCurveLinear animations:animations completion:completion]; } else { @@ -684,31 +550,90 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; }]; } -- (void)showSupportAnimated:(BOOL)animated { - [self showSupportAnimated:animated explict:YES]; +- (void)showRightPanelAnimated:(BOOL)animated { + [self showRightPanelAnimated:animated explict:YES]; } +#pragma mark - Other Panel Functions + - (void)forceHideBothDrawers { [self hideBothDrawersShouldForceHide:YES]; } - (void)hideBothDrawersShouldForceHide:(BOOL)force { //force indicates if we really need to hide the panels - //if not force, that means the hiding is just a temporary state, we might need to show certain panels based on other logics - [self hideMasterAnimated:NO checkingForOtherExtendedDrawers:!force]; - [self hideSupportAnimated:NO checkingForOtherExtendedDrawers:!force]; + //if not force, that means the hiding is just a temporary state, we might need to show certain panels based on other logics + [self hideLeftPanelAnimated:NO checkingForOtherExtendedDrawers:!force]; + [self hideRightPanelAnimated:NO checkingForOtherExtendedDrawers:!force]; } - (void)dismissPanels:(id)sender { - [self hideMasterIfNeededAnimated:YES]; - [self hideSupportIfNeededAnimated:YES]; + [self hideLeftPanelIfNeededAnimated:YES]; + [self hideRightPanelIfNeededAnimated:YES]; } -- (void)setActionMapForCartButton:(NSDictionary *)actionMap delegate:(nullable NSObject *)delegate { - - [self.cartButtonView setWithActionMap:actionMap delegate:delegate additionalData:nil]; +- (void)panelWillAppear:(UIViewController *)panel animated:(BOOL)animated { + if ([panel respondsToSelector:@selector(willAppear:)]) { + [panel willAppear:animated]; + } else { + [panel viewWillAppear:animated]; + } + UIViewController *controller = [self getCurrentDetailViewController]; + if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { + UIViewController * protocolController = (UIViewController *)controller; + if ([protocolController respondsToSelector:@selector(panelWillAppear:)]) { + [protocolController panelWillAppear:panel]; + } + } } +- (void)panelDidAppear:(UIViewController *)panel animated:(BOOL)animated { + if ([panel respondsToSelector:@selector(didAppear:)]) { + [panel didAppear:animated]; + } else { + [panel viewDidAppear:animated]; + } + UIViewController *controller = [self getCurrentDetailViewController]; + if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { + UIViewController * protocolController = (UIViewController *)controller; + if ([protocolController respondsToSelector:@selector(panelDidAppear:)]) { + [protocolController panelDidAppear:panel]; + } + } +} + +- (void)panelWillDisappear:(UIViewController *)panel animated:(BOOL)animated { + if ([panel respondsToSelector:@selector(willDisappear:)]) { + [panel willDisappear:animated]; + } else { + [panel viewWillDisappear:animated]; + } + UIViewController *controller = [self getCurrentDetailViewController]; + if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { + UIViewController * protocolController = (UIViewController *)controller; + if ([protocolController respondsToSelector:@selector(panelWillDisappear:)]) { + [protocolController panelWillDisappear:panel]; + } + } +} + +- (void)panelDidDisappear:(UIViewController *)panel animated:(BOOL)animated { + if ([panel respondsToSelector:@selector(didDisappear:)]) { + [panel didDisappear:animated]; + } else { + [panel viewDidDisappear:animated]; + } + UIViewController *controller = [self getCurrentDetailViewController]; + if ([controller.class conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]) { + UIViewController * protocolController = (UIViewController *)controller; + if ([protocolController respondsToSelector:@selector(panelDidDisappear:)]) { + [protocolController panelDidDisappear:panel]; + } + } +} + +#pragma mark - Bottom Progress Bar + - (void)setBottomProgressBarProgress:(float)progress { [MVMCoreDispatchUtility performBlockOnMainThread:^{ if (self.bottomProgressBarHeightConstraint.constant != PaddingOne) { @@ -725,83 +650,14 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; }]; } -// Returns the desired view or falls back. Hot fix until we can get away from using these functions... -+ (CGRect)getBounds:(UIView *)desiredView { - UIView *view = desiredView ?: [MFSessionSingleton sharedGlobal].navigationController.view ?: [UIApplication sharedApplication].keyWindow.rootViewController.view; - return view ? view.bounds : [UIScreen mainScreen].bounds; -} - -+ (CGFloat)getDetailViewWidth { - return CGRectGetWidth([self getBounds:[MFSessionSingleton sharedGlobal].splitViewController.detailView]); -} - -+ (CGFloat)getDetailViewHeight { - return CGRectGetHeight([self getBounds:[MFSessionSingleton sharedGlobal].splitViewController.detailView]); -} - -+ (CGFloat)getSupportWidth { - return CGRectGetWidth([MFSessionSingleton sharedGlobal].splitViewController.supportView.bounds); -} - -+ (CGFloat)getApplicationViewWidth { - return CGRectGetWidth([self getBounds:[MFSessionSingleton sharedGlobal].splitViewController.view.superview]); -} - -+ (CGFloat)getApplicationViewMaxSize { - return MAX(CGRectGetWidth([MFSessionSingleton sharedGlobal].splitViewController.view.bounds), CGRectGetHeight([MFSessionSingleton sharedGlobal].splitViewController.view.superview.bounds)); -} - -- (void)showOrHideMenuButtonNotificationDot:(BOOL)hide { - self.notificationDot.hidden = hide; - if (hide) { - self.mainMenuButton.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"main_menu_button_acc_label"]; - } else { - self.mainMenuButton.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"main_menu_button_acc_label_unread"]; - } -} - #pragma mark - View Cyle -- (MFViewController *)createMainMenuViewController { - return (MFViewController *)[[MVMCoreObject sharedInstance].splitViewDelegate getLeftPanel]; -} - -- (MFViewController *)createSupportViewController { - return (MFViewController *)[[MVMCoreObject sharedInstance].splitViewDelegate getRightPanel]; -} - -- (void)longPress { - - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - static dispatch_once_t once; - static MFLoggingViewController *loggingViewController; - dispatch_once(&once, ^{ - loggingViewController = [[MFLoggingViewController alloc] init]; - }); - - if (!loggingViewController.presentingViewController) { - UIViewController *topController = [UIApplication sharedApplication].keyWindow.rootViewController; - while (topController.presentedViewController) { - topController = topController.presentedViewController; - } - [topController presentViewController:loggingViewController animated:YES completion:NULL]; - } - }]; -} - - (void)loadView { UIView *view = [[UIView alloc] init]; view.translatesAutoresizingMaskIntoConstraints = NO; self.view = view; - // For debugging. -#ifdef DEBUG - UILongPressGestureRecognizer *gesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress)]; - gesture.minimumPressDuration = 2; - [view addGestureRecognizer:gesture]; -#endif - // Top Alert MVMCoreUITopAlertView *topAlertView = nil; if ([[MVMCoreObject sharedInstance].globalTopAlertDelegate respondsToSelector:@selector(getTopAlertView)]) { @@ -813,7 +669,7 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; } } - // The main detail view. + // The main view. UINavigationController *navigationController = [[UINavigationController alloc] init]; self.navigationController = navigationController; self.automaticallyAdjustsScrollViewInsets = NO; @@ -823,28 +679,25 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; [navigationController.navigationBar setShadowImage:[[UIImage alloc] init]]; navigationController.navigationBar.translucent = NO; navigationController.navigationBar.opaque = YES; - + navigationController.navigationBar.tintColor = [UIColor blackColor]; self.navigationBarSeparator = [SeparatorView separatorAddToView:navigationController.navigationBar position:SeparatorPositionBot withHorizontalPadding:0]; [self.navigationBarSeparator setAsLight]; - - - // Font [navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[MFFonts mfFont75Bd:[[MFSizeObject sizeObjectWithStandardSize:14 standardiPadPortraitSize:16 iPadProLandscapeSize:18] getValueBasedOnScreenSize]]}]; - UIView *detailView = navigationController.view; - detailView.translatesAutoresizingMaskIntoConstraints = NO; + UIView *mainView = navigationController.view; + mainView.translatesAutoresizingMaskIntoConstraints = NO; [self addChildViewController:navigationController]; - [self.view addSubview:detailView]; + [self.view addSubview:mainView]; [navigationController didMoveToParentViewController:self]; - self.detailView = detailView; + self.mainView = mainView; - NSLayoutConstraint *detailLeading = [NSLayoutConstraint constraintWithItem:detailView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; - detailLeading.active = YES; - self.detailViewLeading = detailLeading; + NSLayoutConstraint *mainLeading = [NSLayoutConstraint constraintWithItem:mainView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]; + mainLeading.active = YES; + self.mainViewLeading = mainLeading; - NSLayoutConstraint *detailTrailing = [NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]; - detailTrailing.active = YES; - self.detailViewTrailing = detailTrailing; + NSLayoutConstraint *mainTrailing = [NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]; + mainTrailing.active = YES; + self.mainViewTrailing = mainTrailing; // Create bottom progress bar UIProgressView *progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault]; @@ -852,17 +705,17 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; progressView.tintColor = [UIColor mfTomatoRed]; [self.view addSubview:progressView]; self.bottomProgressBar = progressView; - [NSLayoutConstraint constraintWithItem:progressView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0].active = YES; - [NSLayoutConstraint constraintWithItem:progressView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0].active = YES; + [NSLayoutConstraint constraintWithItem:progressView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0].active = YES; + [NSLayoutConstraint constraintWithItem:progressView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0].active = YES; NSLayoutConstraint *bottomProgressHeight = [NSLayoutConstraint constraintWithItem:progressView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:0]; bottomProgressHeight.active = YES; self.bottomProgressBarHeightConstraint = bottomProgressHeight; if (topAlertView) { - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[topAlertView]-0-[detailView]-0-[progressView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAlertView, detailView, progressView)]]; + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[topAlertView]-0-[mainView]-0-[progressView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(topAlertView, mainView, progressView)]]; } else { - [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[detailView]-0-[progressView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(detailView, progressView)]]; + [NSLayoutConstraint activateConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[mainView]-0-[progressView]-0-|" options:NSLayoutFormatDirectionLeadingToTrailing metrics:nil views:NSDictionaryOfVariableBindings(mainView, progressView)]]; } // Cover View @@ -871,41 +724,45 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; coverView.alpha = 0; coverView.hidden = YES; [self.view addSubview:coverView]; - self.detailCoverView = coverView; - [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0].active = YES; - [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0].active = YES; - [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0].active = YES; - [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0].active = YES; + self.mainViewCoverView = coverView; + [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0].active = YES; + [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0].active = YES; + [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0].active = YES; + [NSLayoutConstraint constraintWithItem:coverView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0].active = YES; - // Main Menu Panel - MFViewController *mainMenuController = [self createMainMenuViewController]; - UIView *masterView = mainMenuController.view; - [self addChildViewController:mainMenuController]; - [self.view addSubview:masterView]; - [mainMenuController didMoveToParentViewController:self]; - self.masterView = masterView; - self.masterMenu = mainMenuController; - NSLayoutConstraint *masterWidth = [NSLayoutConstraint constraintWithItem:masterView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:270]; - masterWidth.active = YES; - self.masterWidth = masterWidth; - [NSLayoutConstraint constraintWithItem:detailView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:masterView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0].active = YES; - [NSLayoutConstraint constraintWithItem:masterView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0].active = YES; - [NSLayoutConstraint constraintWithItem:masterView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0].active = YES; + // Left Panel + UIViewController *leftPanel = [self createLeftPanelViewController]; + if (leftPanel) { + UIView *leftView = leftPanel.view; + [self addChildViewController:leftPanel]; + [self.view addSubview:leftView]; + [leftPanel didMoveToParentViewController:self]; + self.leftView = leftView; + self.leftPanel = leftPanel; + NSLayoutConstraint *leftPanelWidth = [NSLayoutConstraint constraintWithItem:leftView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:270]; + leftPanelWidth.active = YES; + self.leftPanelWidth = leftPanelWidth; + [NSLayoutConstraint constraintWithItem:mainView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:leftView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0].active = YES; + [NSLayoutConstraint constraintWithItem:leftView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0].active = YES; + [NSLayoutConstraint constraintWithItem:leftView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0].active = YES; + } - // Support Panel - MFViewController *supportViewController = [self createSupportViewController]; - UIView *supportView = supportViewController.view; - [self addChildViewController:supportViewController]; - [self.view addSubview:supportView]; - [supportViewController didMoveToParentViewController:self]; - self.supportView = supportView; - self.supportPanel = supportViewController; - NSLayoutConstraint *supportWidth = [NSLayoutConstraint constraintWithItem:supportView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:270]; - supportWidth.active = YES; - self.supportWidth = supportWidth; - [NSLayoutConstraint constraintWithItem:supportView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0].active = YES; - [NSLayoutConstraint constraintWithItem:supportView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0].active = YES; - [NSLayoutConstraint constraintWithItem:supportView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:detailView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0].active = YES; + // Right Panel + UIViewController *rightPanel = [self createRightPanelViewController]; + if (rightPanel) { + UIView *rightView = rightPanel.view; + [self addChildViewController:rightPanel]; + [self.view addSubview:rightView]; + [rightPanel didMoveToParentViewController:self]; + self.rightView = rightView; + self.rightPanel = rightPanel; + NSLayoutConstraint *rightPanelWidth = [NSLayoutConstraint constraintWithItem:rightView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:270]; + rightPanelWidth.active = YES; + self.rightPanelWidth = rightPanelWidth; + [NSLayoutConstraint constraintWithItem:rightView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0].active = YES; + [NSLayoutConstraint constraintWithItem:rightView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0].active = YES; + [NSLayoutConstraint constraintWithItem:rightView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:mainView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0].active = YES; + } } - (void)viewDidLoad { @@ -913,61 +770,34 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; [self.topAlertView pinATopViewController:self]; // Do any additional setup after loading the view. - self.navigationController.navigationBar.translucent = NO; - self.navigationController.navigationBar.tintColor = [UIColor blackColor]; - - UIButton *menuButton= [UIButton buttonWithType:UIButtonTypeCustom]; - [menuButton setImage:[[MVMCoreUIUtility imageNamed:@"menu"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] forState:UIControlStateNormal]; - [menuButton addTarget:self action:@selector(masterButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; - menuButton.frame = CGRectMake(0, 0, 26, 36); - - UIView *notificationDot = [MVMCoreUICommonViewsUtility commonView]; - [menuButton addSubview:notificationDot]; - notificationDot.translatesAutoresizingMaskIntoConstraints = NO; - notificationDot.backgroundColor = [UIColor mfRedColor]; - self.notificationDot = notificationDot; - - CGFloat dotSize = 8; - notificationDot.layer.cornerRadius = dotSize/2; - [notificationDot.widthAnchor constraintEqualToConstant:dotSize].active = YES; - [notificationDot.heightAnchor constraintEqualToConstant:dotSize].active = YES; - [notificationDot.centerXAnchor constraintEqualToAnchor:menuButton.imageView.trailingAnchor].active = YES; - [notificationDot.centerYAnchor constraintEqualToAnchor:menuButton.imageView.centerYAnchor constant:-8].active = YES; - [self showOrHideMenuButtonNotificationDot:YES]; - - [menuButton addTarget:self action:@selector(masterButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; - self.mainMenuButton = [[UIBarButtonItem alloc] initWithCustomView:menuButton]; - self.mainMenuButton.width = 26; - self.animatedSupportButton = [[MFSupportBarButtonItem alloc] initWithImage:[MVMCoreUIUtility imageNamed:@"support_default"] style:UIBarButtonItemStylePlain target:self action:@selector(supportButtonPressed:)]; - - self.queuedRightBarButtonItems = [NSMutableArray new]; - - // Creates the shopping cart button - self.cartButtonView = [[CartView alloc]init]; - [self.cartButtonView setNeedsLayout]; - [self.cartButtonView layoutIfNeeded]; - - self.cartButton = [[UIBarButtonItem alloc]initWithCustomView:self.cartButtonView]; - self.cartButton.tintColor = [UIColor whiteColor]; - - // Creates the back button - self.backButton = [[UIBarButtonItem alloc] initWithImage:[MVMCoreUIUtility imageNamed:@"back"] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)]; - self.backButton.imageInsets = UIEdgeInsetsMake(0, 4, 0, -8); - - if (!self.tapToDismissGesture) { - self.tapToDismissGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissPanels:)]; - [self.detailCoverView addGestureRecognizer:self.tapToDismissGesture]; + if (self.leftPanel) { + if ([self.leftPanel respondsToSelector:@selector(buttonForPanel)]) { + self.leftPanelButton = [self.leftPanel buttonForPanel]; + } else { + self.leftPanelButton = [[UIBarButtonItem alloc] initWithImage:[self.leftPanel imageForButtonForPanel] style:UIBarButtonItemStylePlain target:self action:@selector(leftPanelButtonPressed:)]; + } } - [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(cartWasModified) name:@"CartWasModified" object:nil]; + if (self.rightPanel) { + if ([self.rightPanel respondsToSelector:@selector(buttonForPanel)]) { + self.rightPanelButton = [self.rightPanel buttonForPanel]; + } else { + self.rightPanelButton = [[UIBarButtonItem alloc] initWithImage:[self.rightPanel imageForButtonForPanel] style:UIBarButtonItemStylePlain target:self action:@selector(rightPanelButtonPressed:)]; + } + } - //Accessibility label - self.mainMenuButton.accessibilityLabel =[MVMCoreUIUtility hardcodedStringWithKey:@"main_menu_button_acc_label"]; - self.cartButton.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"cart_button_acc_label"]; - self.backButton.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"back_button_acc_label"]; + // Creates the back button + self.backButton = [[UIBarButtonItem alloc] initWithImage:[self imageForBackButton] style:UIBarButtonItemStylePlain target:self action:@selector(backButtonPressed:)]; + self.backButton.imageInsets = UIEdgeInsetsMake(0, 4, 0, -8); + + // Dismisses a panel if the user taps the main view. + if (!self.tapToDismissGesture) { + self.tapToDismissGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissPanels:)]; + [self.mainViewCoverView addGestureRecognizer:self.tapToDismissGesture]; + } - self.extendedDrawers = MFExtendedDrawerMenu | MFExtendedDrawerSupport; - self.prioritizedExtendedPanel = self.masterMenu; + self.extendedDrawers = MFExtendedDrawerLeft | MFExtendedDrawerRight; + self.prioritizedExtendedPanel = self.leftPanel; self.view.backgroundColor = [UIColor blackColor]; } @@ -975,37 +805,33 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; - (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; - // Sets the master and support size, top space. + // Sets the panel sizes, top space. CGFloat viewWidth = CGRectGetWidth(self.view.bounds); + MFNumberOfDrawers numberOfDrawers = [self numberOfDrawersShouldShow:@(viewWidth)]; - MFNumberOfDrawers numberOfDrawers = [MVMCoreUISplitViewController numberOfDrawersShouldShow:@(viewWidth)]; - - // Extended master size is smaller. - if ([self shouldExtendMaster:numberOfDrawers] && viewWidth > ExtendedPanelWidth) { - self.masterWidth.constant = ExtendedPanelWidth; - } else if (viewWidth > MaxPanelWidth) { - self.masterWidth.constant = MaxPanelWidth; + CGFloat leftPanelExtendedWidth = [self leftPanelExtendedWidth]; + CGFloat leftPanelMaxWidth = [self leftPanelMaxWidth]; + if ([self shouldExtendLeftPanel:numberOfDrawers] && viewWidth > leftPanelExtendedWidth) { + self.leftPanelWidth.constant = leftPanelExtendedWidth; + } else if (viewWidth > leftPanelMaxWidth) { + self.leftPanelWidth.constant = leftPanelMaxWidth; } else { - self.masterWidth.constant = viewWidth; + self.leftPanelWidth.constant = viewWidth; } - if ([self shouldExtendSupport:numberOfDrawers] && viewWidth > ExtendedPanelWidth) { - self.supportWidth.constant = ExtendedPanelWidth; - } else if (viewWidth > MaxSupportPanelWidth) { - self.supportWidth.constant = MaxSupportPanelWidth; + CGFloat rightPanelExtendedWidth = [self rightPanelExtendedWidth]; + CGFloat rightPanelMaxWidth = [self rightPanelMaxWidth]; + if ([self shouldExtendRightPanel:numberOfDrawers] && viewWidth > rightPanelExtendedWidth) { + self.rightPanelWidth.constant = rightPanelExtendedWidth; + } else if (viewWidth > rightPanelMaxWidth) { + self.rightPanelWidth.constant = rightPanelMaxWidth; } else { - self.supportWidth.constant = viewWidth; + self.rightPanelWidth.constant = viewWidth; } [self.view layoutIfNeeded]; } - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; @@ -1013,7 +839,7 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; self.transitionWidth = @(size.width); void (^animate)(id) = nil; - if (self.masterIsAccessible || self.supportIsAccessible) { + if (self.leftPanelIsAccessible || self.rightPanelIsAccessible) { animate = ^(id context) { [self resetDrawers]; }; @@ -1021,46 +847,52 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; [coordinator animateAlongsideTransition:animate completion:^(id _Nonnull context) { self.transitionWidth = nil; - self.masterMenu.needToUpdateUI = YES; - [self.masterMenu.view setNeedsLayout]; - [self.masterMenu.view layoutIfNeeded]; + /*self.leftPanel.needToUpdateUI = YES; + [self.leftPanel.view setNeedsLayout]; + [self.leftPanel.view layoutIfNeeded];*/ [self.topAlertView updateView:size.width]; }]; } - (void)resetDrawers { - [self setMasterIsAccessible:self.masterIsAccessible forViewController:self.viewController]; - [self setSupportIsAccessible:self.supportIsAccessible cartIsAccessible:self.cartIsAccessible communityIsAccessible:self.communityIsAccessible closeButtonActionMap:nil forViewController:self.viewController]; + [self setLeftPanelIsAccessible:self.leftPanelIsAccessible forViewController:self.viewController]; + [self setRightPanelIsAccessible:self.rightPanelIsAccessible forViewController:self.viewController]; [self.view setNeedsLayout]; [self.view layoutIfNeeded]; } -- (void)cartWasModified { - - UIViewController *currentDetailViewController = (UIViewController *)[self getCurrentDetailViewController]; - - BOOL cartIsAccessible = [ShopCart sharedCartInstance].showCartIcon; - - //make the shop cart can be dismissed - [MVMCoreDispatchUtility performBlockOnMainThread:^{ - [self setSupportIsAccessible:currentDetailViewController.supportShouldBeAccessible cartIsAccessible:cartIsAccessible communityIsAccessible:currentDetailViewController.communityShouldBeAccessible - closeButtonActionMap:currentDetailViewController.closeButtonActionMap - forViewController:currentDetailViewController]; - self.cartButtonView.itemCount = [ShopCart sharedCartInstance].itemsInCart.count; - if (self.cartButtonView.itemCount > 0) { - self.cartButton.accessibilityLabel = [NSString stringWithFormat:[MVMCoreUIUtility hardcodedStringWithKey:@"cart_items_count"], (long)self.cartButtonView.itemCount]; - } else { - self.cartButton.accessibilityLabel = [MVMCoreUIUtility hardcodedStringWithKey:@"cart_button_acc_label"]; - } - }]; -} - - (UIStatusBarStyle)preferredStatusBarStyle { return self.topAlertView.statusBarStyle; } -#pragma mark - For AdobeTracker +#pragma mark - Getters + +// Returns the desired view or falls back. Hot fix until we can get away from using these functions... ++ (CGRect)getBounds:(UIView *)desiredView { + UIView *view = desiredView ?: [MVMCoreNavigationHandler sharedNavigationHandler].navigationController.view ?: [UIApplication sharedApplication].keyWindow.rootViewController.view; + return view ? view.bounds : [UIScreen mainScreen].bounds; +} + ++ (CGFloat)getDetailViewWidth { + return CGRectGetWidth([self getBounds:[MVMCoreUISession sharedGlobal].splitViewController.mainView]); +} + ++ (CGFloat)getDetailViewHeight { + return CGRectGetHeight([self getBounds:[MVMCoreUISession sharedGlobal].splitViewController.mainView]); +} + ++ (CGFloat)getSupportWidth { + return CGRectGetWidth([MVMCoreUISession sharedGlobal].splitViewController.rightView.bounds); +} + ++ (CGFloat)getApplicationViewWidth { + return CGRectGetWidth([self getBounds:[MVMCoreUISession sharedGlobal].splitViewController.view.superview]); +} + ++ (CGFloat)getApplicationViewMaxSize { + return MAX(CGRectGetWidth([MVMCoreUISession sharedGlobal].splitViewController.view.bounds), CGRectGetHeight([MVMCoreUISession sharedGlobal].splitViewController.view.superview.bounds)); +} - (UIViewController *)getCurrentVisibleController { UIViewController *baseViewController = [MVMCoreNavigationHandler sharedNavigationHandler].viewControllerToPresentOn; @@ -1106,31 +938,15 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; } } -- (void)sentTrackerDatabyLinkName:(NSString *)linkName{ - NSMutableDictionary *button_data = [[NSMutableDictionary alloc] init]; - [button_data setObject:KeyGlobal_Nav forKey:KeyAdobeTrackerActionPrefix]; - [button_data setObject:linkName forKey:KeyAdobeTrackerLinkName]; - if ([self getPageTypeForDetailViewController].length >0) { - [button_data setObject:[self getPageTypeForDetailViewController] forKey:KeyAdobeTrackerPageName]; - } - [[MFAdobeTracker sharedTracker] trackActionData:button_data]; -} - -- (void)voiceOverStatusChanged -{ - DisableAnimations = UIAccessibilityIsVoiceOverRunning(); -} - - #pragma mark - navigation bar - (void)setNavigationIconColor:(nullable UIColor *)color { - - //menu and support does not have navigation controller, so they should not set the color - if ([self.animatedSupportButton respondsToSelector:@selector(setIconColor:)]) { - [self.animatedSupportButton setIconColor:color]; + if ([self.leftPanelButton respondsToSelector:@selector(setIconColor:)]) { + [((UIBarButtonItem *)self.leftPanelButton) setIconColor:color]; + } + if ([self.rightPanelButton respondsToSelector:@selector(setIconColor:)]) { + [((UIBarButtonItem *)self.rightPanelButton) setIconColor:color]; } - [self.cartButtonView setTintColor:color]; } #pragma mark - MVMCoreLoadingOverlayDelegateProtocol @@ -1168,66 +984,4 @@ static NSString * const KeyGlobal_Nav = @"Global_Nav"; self.view.userInteractionEnabled = YES; } -#pragma mark - panels - -- (void)panelWillAppear:(UIViewController *)panel animated:(BOOL)animated { - if ([panel respondsToSelector:@selector(panel:viewWillAppear:)]) { - [panel panel:panel viewWillAppear:animated]; - } else { - [panel viewWillAppear:animated]; - } - UIViewController *controller = [self getCurrentDetailViewController]; - if ([controller.class conformsToProtocol:@protocol(MVMCoreDetailViewProtocol)]) { - UIViewController * protocolController = (UIViewController *)controller; - if ([protocolController respondsToSelector:@selector(panelWillAppear:)]) { - [protocolController panelWillAppear:panel]; - } - } -} - -- (void)panelDidAppear:(UIViewController *)panel animated:(BOOL)animated { - if ([panel respondsToSelector:@selector(panel:viewDidAppear:)]) { - [panel panel:panel viewDidAppear:animated]; - } else { - [panel viewDidAppear:animated]; - } - UIViewController *controller = [self getCurrentDetailViewController]; - if ([controller.class conformsToProtocol:@protocol(MVMCoreDetailViewProtocol)]) { - UIViewController * protocolController = (UIViewController *)controller; - if ([protocolController respondsToSelector:@selector(panelDidAppear:)]) { - [protocolController panelDidAppear:panel]; - } - } -} - -- (void)panelWillDisappear:(UIViewController *)panel animated:(BOOL)animated { - if ([panel respondsToSelector:@selector(panel:viewWillDisappear:)]) { - [panel panel:panel viewWillDisappear:animated]; - } else { - [panel viewWillDisappear:animated]; - } - UIViewController *controller = [self getCurrentDetailViewController]; - if ([controller.class conformsToProtocol:@protocol(MVMCoreDetailViewProtocol)]) { - UIViewController * protocolController = (UIViewController *)controller; - if ([protocolController respondsToSelector:@selector(panelWillDisappear:)]) { - [protocolController panelWillDisappear:panel]; - } - } -} - -- (void)panelDidDisappear:(UIViewController *)panel animated:(BOOL)animated { - if ([panel respondsToSelector:@selector(panel:viewDidDisappear:)]) { - [panel panel:panel viewDidDisappear:animated]; - } else { - [panel viewDidDisappear:animated]; - } - UIViewController *controller = [self getCurrentDetailViewController]; - if ([controller.class conformsToProtocol:@protocol(MVMCoreDetailViewProtocol)]) { - UIViewController * protocolController = (UIViewController *)controller; - if ([protocolController respondsToSelector:@selector(panelDidDisappear:)]) { - [protocolController panelDidDisappear:panel]; - } - } -} - @end diff --git a/MVMCoreUI/MVMCoreUI.h b/MVMCoreUI/MVMCoreUI.h index ac5a28b7..94fb4647 100644 --- a/MVMCoreUI/MVMCoreUI.h +++ b/MVMCoreUI/MVMCoreUI.h @@ -36,9 +36,11 @@ FOUNDATION_EXPORT const unsigned char MVMCoreUIVersionString[]; #import #pragma mark - Containers -#import -#import +#import +#import #import +#import + #import #import diff --git a/MVMCoreUI/Utility/MVMCoreUIUtility.h b/MVMCoreUI/Utility/MVMCoreUIUtility.h index 6e251b54..0a029e58 100644 --- a/MVMCoreUI/Utility/MVMCoreUIUtility.h +++ b/MVMCoreUI/Utility/MVMCoreUIUtility.h @@ -8,6 +8,8 @@ #import +#define fequalwiththreshold(a,b,c) (fabs((a) - (b)) < c) + NS_ASSUME_NONNULL_BEGIN @interface MVMCoreUIUtility : NSObject