update code based on comments
This commit is contained in:
parent
9278ad75ea
commit
89427b1b7a
@ -31,7 +31,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
- (BOOL)isOverridingLeftButton;
|
- (BOOL)isOverridingLeftButton;
|
||||||
|
|
||||||
//return desired status bar style based on different View Controller
|
//return desired status bar style based on different View Controller
|
||||||
- (UIStatusBarStyle)panelPreferredStatusBarStyle;
|
- (UIStatusBarStyle)defaultStatusBarStyle;
|
||||||
|
- (nullable UIColor *)defaultStatusBarBackgroundColor;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@ -107,6 +107,7 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) {
|
|||||||
|
|
||||||
// return subviewcontrollers' prefer status bar style
|
// return subviewcontrollers' prefer status bar style
|
||||||
- (UIStatusBarStyle)getDefaultStatusBarStyle;
|
- (UIStatusBarStyle)getDefaultStatusBarStyle;
|
||||||
|
- (nullable UIColor *)getDefaultStatusBarBackgroundColor;
|
||||||
|
|
||||||
#pragma mark - Main Subclassables
|
#pragma mark - Main Subclassables
|
||||||
|
|
||||||
|
|||||||
@ -881,9 +881,7 @@ CGFloat const PanelAnimationDuration = 0.2;
|
|||||||
return self.topAlertView.statusBarStyle;
|
return self.topAlertView.statusBarStyle;
|
||||||
} else {
|
} else {
|
||||||
UIStatusBarStyle style = [self getDefaultStatusBarStyle];
|
UIStatusBarStyle style = [self getDefaultStatusBarStyle];
|
||||||
if (self.topAlertView.statusBarStyle != style) {
|
[self.topAlertView resetDefaultStatusBarStyle:style backgroundColor:[self getDefaultStatusBarBackgroundColor]];
|
||||||
[self.topAlertView resetStatusBar];
|
|
||||||
}
|
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -891,13 +889,23 @@ CGFloat const PanelAnimationDuration = 0.2;
|
|||||||
- (UIStatusBarStyle)getDefaultStatusBarStyle {
|
- (UIStatusBarStyle)getDefaultStatusBarStyle {
|
||||||
UIViewController *viewController = [self getCurrentDetailViewController];
|
UIViewController *viewController = [self getCurrentDetailViewController];
|
||||||
if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]
|
if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)]
|
||||||
&& [viewController respondsToSelector:@selector(panelPreferredStatusBarStyle)]
|
&& [viewController respondsToSelector:@selector(defaultStatusBarStyle)]
|
||||||
&& [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) panelPreferredStatusBarStyle]) {
|
&& [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarStyle]) {
|
||||||
return [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) panelPreferredStatusBarStyle];
|
return [((UIViewController <MVMCoreUIDetailViewProtocol> *)viewController) defaultStatusBarStyle];
|
||||||
}
|
}
|
||||||
return UIStatusBarStyleDefault;
|
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
|
#pragma mark - Getters
|
||||||
|
|
||||||
// Returns the desired view or falls back. Hot fix until we can get away from using these functions...
|
// Returns the desired view or falls back. Hot fix until we can get away from using these functions...
|
||||||
|
|||||||
@ -42,7 +42,7 @@
|
|||||||
- (void)collapseStatusBarView;
|
- (void)collapseStatusBarView;
|
||||||
|
|
||||||
//reset status bar color to default based on splitview
|
//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.
|
// Can be subclassed for custom views.
|
||||||
- (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id <MVMCoreTopAlertAnimationDelegateProtocol>)animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor;
|
- (nonnull MVMCoreUITopAlertBaseView *)topAlertViewForTopAlertObject:(nullable MVMCoreTopAlertObject *)topAlertObject animationDelegate:(nonnull id <MVMCoreTopAlertAnimationDelegateProtocol>)animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor;
|
||||||
|
|||||||
@ -46,6 +46,9 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
|
|||||||
@property (weak, nonatomic) MVMCoreUITopAlertExpandableView *topAlertClearspotView;
|
@property (weak, nonatomic) MVMCoreUITopAlertExpandableView *topAlertClearspotView;
|
||||||
@property (strong, nonatomic) NSString *time;
|
@property (strong, nonatomic) NSString *time;
|
||||||
|
|
||||||
|
@property (nonatomic, assign) UIStatusBarStyle defaultStatusBarStyle;
|
||||||
|
@property (nonatomic, strong) UIColor *defaultStatusBarBackgroundColor;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation MVMCoreUITopAlertView
|
@implementation MVMCoreUITopAlertView
|
||||||
@ -204,7 +207,7 @@ NSString * const MFAccTopAlertClosed = @"Top alert notification is closed.";
|
|||||||
completionHandler(finished);
|
completionHandler(finished);
|
||||||
weakSelf.topAlertObject = nil;
|
weakSelf.topAlertObject = nil;
|
||||||
[MVMCoreDispatchUtility performBlockOnMainThread:^{
|
[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 {
|
- (void)resetDefaultStatusBarStyle:(UIStatusBarStyle)style backgroundColor:(UIColor *)backgroundColor {
|
||||||
UIStatusBarStyle style = [[MVMCoreUISplitViewController mainSplitViewController] getDefaultStatusBarStyle];
|
self.defaultStatusBarStyle = style;
|
||||||
UIColor *backgroundColor = style == UIStatusBarStyleDefault ? [UIColor whiteColor] : [UIColor blackColor];
|
self.defaultStatusBarBackgroundColor = backgroundColor;
|
||||||
[self setStatusBarColor:backgroundColor statusBarStyle:style];
|
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
|
@end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user