public globalLeftPanel/globalRightPanel

This commit is contained in:
Xinlei(Ryan) Pan 2020-01-21 11:58:08 -05:00
parent 5b92e64507
commit 8816a06fe5
2 changed files with 19 additions and 29 deletions

View File

@ -24,8 +24,12 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
@interface MVMCoreUISplitViewController : UIViewController
// Reference to the panels.
@property (nullable, weak, nonatomic, readonly) UIViewController <MVMCoreUIPanelProtocol> *leftPanel;
@property (nullable, weak, nonatomic, readonly) UIViewController <MVMCoreUIPanelProtocol> *rightPanel;
@property (nullable, weak, nonatomic) UIViewController <MVMCoreUIPanelProtocol> *leftPanel;
@property (nullable, weak, nonatomic) UIViewController <MVMCoreUIPanelProtocol> *rightPanel;
// For keeping
@property (nullable, strong, nonatomic) UIViewController <MVMCoreUIPanelProtocol> *globalLeftPanel;
@property (nullable, strong, nonatomic) UIViewController <MVMCoreUIPanelProtocol> *globalRightPanel;
// Can be of protocol MVMCoreUIPanelButtonProtocol
@property (nullable, strong, nonatomic) UIBarButtonItem *leftPanelButton;
@ -79,6 +83,9 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
// contains speicaly logic to set the icon color
- (void)setNavigationIconColor:(nullable UIColor *)color;
///create right and left panel. if left and right panel is already created, will replace them
- (void)createPanels;
/// Updates the panels that are used.
- (void)setupPanels;
@ -120,10 +127,6 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
- (nullable UIViewController <MVMCoreUIPanelProtocol> *)createLeftPanelViewController;
- (nullable UIViewController <MVMCoreUIPanelProtocol> *)createRightPanelViewController;
//replace gloabl panel
- (void)updateGlobalLeftPanelViewController:(nullable UIViewController <MVMCoreUIPanelProtocol> *)leftPanelController;
- (void)updateGlobalRightPanelViewController:(nullable UIViewController <MVMCoreUIPanelProtocol> *)rightPanelController;
// subclass to change image of back button
- (nullable UIImage *)imageForBackButton;

View File

@ -44,12 +44,6 @@ typedef NS_OPTIONS(NSInteger, MFExtendedDrawer) {
@property (weak, nonatomic) UIView *leftPanelSeparator;
@property (weak, nonatomic) UIView *rightPanelSeparator;
// For keeping
@property (strong, nonatomic, readwrite) UIViewController <MVMCoreUIPanelProtocol> *globalLeftPanel;
@property (strong, nonatomic, readwrite) UIViewController <MVMCoreUIPanelProtocol> *globalRightPanel;
@property (weak, nonatomic, readwrite) UIViewController <MVMCoreUIPanelProtocol> *leftPanel;
@property (weak, nonatomic, readwrite) UIViewController <MVMCoreUIPanelProtocol> *rightPanel;
@property (weak, nonatomic, readwrite) NavigationController *navigationController;
// A view that covers the detail view when the master is out.
@ -114,14 +108,6 @@ CGFloat const PanelAnimationDuration = 0.2;
return nil;
}
- (void)updateGlobalLeftPanelViewController:(nullable UIViewController <MVMCoreUIPanelProtocol> *)leftPanelController {
self.globalLeftPanel = leftPanelController;
}
- (void)updateGlobalRightPanelViewController:(nullable UIViewController <MVMCoreUIPanelProtocol> *)rightPanelController {
self.globalRightPanel = rightPanelController;
}
- (nullable NSArray <UIBarButtonItem *>*)additionalLeftButtons {
return nil;
}
@ -366,7 +352,7 @@ CGFloat const PanelAnimationDuration = 0.2;
}
- (void)showLeftPanelAnimated:(BOOL)animated explict:(BOOL)explict {
if (!self.globalLeftPanel) {
if (!self.leftPanel) {
return;
}
[MVMCoreDispatchUtility performBlockOnMainThread:^{
@ -523,9 +509,6 @@ CGFloat const PanelAnimationDuration = 0.2;
}
- (void)hideRightPanelAnimated:(BOOL)animated checkingForOtherExtendedDrawers:(BOOL)checkingForOtherExtendedDrawers {
if (!self.globalRightPanel) {
return;
}
[MVMCoreDispatchUtility performBlockOnMainThread:^{
if (self.mainViewTrailing.constant > .1) {
if (checkingForOtherExtendedDrawers && self.explictlyShowingPanel == self.rightPanel) {
@ -565,7 +548,7 @@ CGFloat const PanelAnimationDuration = 0.2;
}
- (void)showRightPanelAnimated:(BOOL)animated explict:(BOOL)explict {
if (!self.globalRightPanel) {
if (!self.rightPanel) {
return;
}
[MVMCoreDispatchUtility performBlockOnMainThread:^{
@ -786,6 +769,13 @@ CGFloat const PanelAnimationDuration = 0.2;
}
}
- (void)createPanels {
// Create panels
self.globalLeftPanel = [self createLeftPanelViewController];
self.globalRightPanel = [self createRightPanelViewController];
[self setupPanels];
}
- (void)setupPanels {
[self forceHideBothDrawers];
[self setupLeftPanel];
@ -882,10 +872,7 @@ CGFloat const PanelAnimationDuration = 0.2;
[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;
// Create panels
self.globalLeftPanel = [self createLeftPanelViewController];
self.globalRightPanel = [self createRightPanelViewController];
[self setupPanels];
[self createPanels];
}
- (void)viewDidLoad {