update code based on comments

This commit is contained in:
panxi 2019-04-16 11:46:53 -04:00
parent 9278ad75ea
commit 89427b1b7a
5 changed files with 34 additions and 13 deletions

View File

@ -31,7 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isOverridingLeftButton;
//return desired status bar style based on different View Controller
- (UIStatusBarStyle)panelPreferredStatusBarStyle;
- (UIStatusBarStyle)defaultStatusBarStyle;
- (nullable UIColor *)defaultStatusBarBackgroundColor;
@end

View File

@ -107,6 +107,7 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
// return subviewcontrollers' prefer status bar style
- (UIStatusBarStyle)getDefaultStatusBarStyle;
- (nullable UIColor *)getDefaultStatusBarBackgroundColor;
#pragma mark - Main Subclassables

View File

@ -881,9 +881,7 @@ CGFloat const PanelAnimationDuration = 0.2;
return self.topAlertView.statusBarStyle;
} else {
UIStatusBarStyle style = [self getDefaultStatusBarStyle];
if (self.topAlertView.statusBarStyle != style) {
[self.topAlertView resetStatusBar];
}
[self.topAlertView resetDefaultStatusBarStyle:style backgroundColor:[self getDefaultStatusBarBackgroundColor]];
return style;
}
}
@ -891,13 +889,23 @@ CGFloat const PanelAnimationDuration = 0.2;
- (UIStatusBarStyle)getDefaultStatusBarStyle {
UIViewController *viewController = [self getCurrentDetailViewController];
if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]
&& [viewController respondsToSelector:@selector(panelPreferredStatusBarStyle)]
&& [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) panelPreferredStatusBarStyle]) {
return [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) panelPreferredStatusBarStyle];
&& [viewController respondsToSelector:@selector(defaultStatusBarStyle)]
&& [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarStyle]) {
return [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarStyle];
}
return UIStatusBarStyleDefault;
}
- (UIColor *)getDefaultStatusBarBackgroundColor {
UIViewController *viewController = [self getCurrentDetailViewController];
if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]
&& [viewController respondsToSelector:@selector(defaultStatusBarBackgroundColor)]
&& [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarBackgroundColor]) {
return [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarBackgroundColor];
}
return nil;
}
#pragma mark - Getters
// Returns the desired view or falls back. Hot fix until we can get away from using these functions...

View File

@ -42,7 +42,7 @@
- (void)collapseStatusBarView;
//reset status bar color to default based on splitview
- (void)resetStatusBar;
- (void)resetDefaultStatusBarStyle:(UIStatusBarStyle)style backgroundColor:(nullable UIColor *)backgroundColor;
// Can be subclassed for custom views.
- (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id <MVMCoreTopAlertAnimationDelegateProtocol>)animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor;

View File

@ -46,6 +46,9 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
@property (weak, nonatomic) MVMCoreUITopAlertExpandableView *topAlertClearspotView;
@property (strong, nonatomic) NSString *time;
@property (nonatomic, assign) UIStatusBarStyle defaultStatusBarStyle;
@property (nonatomic, strong) UIColor *defaultStatusBarBackgroundColor;
@end
@implementation MVMCoreUITopAlertView
@ -204,7 +207,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
completionHandler(finished);
weakSelf.topAlertObject = nil;
[MVMCoreDispatchUtility performBlockOnMainThread:^{
[weakSelf resetStatusBar];
[weakSelf resetDefaultStatusBarStyle:weakSelf.defaultStatusBarStyle backgroundColor:weakSelf.defaultStatusBarBackgroundColor];
}];
}];
}];
@ -244,10 +247,18 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
}];
}
- (void)resetStatusBar {
UIStatusBarStyle style = [[MVMCoreUISplitViewController mainSplitViewController] getDefaultStatusBarStyle];
UIColor *backgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor];
[self setStatusBarColor:backgroundColor statusBarStyle:style];
- (void)resetDefaultStatusBarStyle:(UIStatusBarStyle)style backgroundColor:(UIColor *)backgroundColor {
self.defaultStatusBarStyle = style;
self.defaultStatusBarBackgroundColor = backgroundColor;
if (!backgroundColor) {
self.defaultStatusBarBackgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor];
}
if (!self.topAlertObject) {
//style or color doens't match the current default value
if (style != self.statusBarStyle || !CGColorEqualToColor(self.defaultStatusBarBackgroundColor.CGColor, self.statusBarView.backgroundColor.CGColor)) {
[self setStatusBarColor:self.defaultStatusBarBackgroundColor statusBarStyle:style];
}
}
}
@end