diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h index 5eeafc9f..acb56ad1 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUIDetailViewProtocol.h @@ -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 diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h index 88b61188..0d4c9ea4 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.h @@ -107,6 +107,7 @@ typedef NS_ENUM(NSInteger, MFNumberOfDrawers) { // return subviewcontrollers' prefer status bar style - (UIStatusBarStyle)getDefaultStatusBarStyle; +- (nullable UIColor *)getDefaultStatusBarBackgroundColor; #pragma mark - Main Subclassables diff --git a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m index dd76cc92..7f34de85 100644 --- a/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m +++ b/MVMCoreUI/Containers/SplitViewController/MVMCoreUISplitViewController.m @@ -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 *)viewController) panelPreferredStatusBarStyle]) { - return [((UIViewController *)viewController) panelPreferredStatusBarStyle]; + && [viewController respondsToSelector:@selector(defaultStatusBarStyle)] + && [((UIViewController *)viewController) defaultStatusBarStyle]) { + return [((UIViewController *)viewController) defaultStatusBarStyle]; } return UIStatusBarStyleDefault; } +- (UIColor *)getDefaultStatusBarBackgroundColor { + UIViewController *viewController = [self getCurrentDetailViewController]; + if ([viewController conformsToProtocol:@protocol(MVMCoreUIDetailViewProtocol)] + && [viewController respondsToSelector:@selector(defaultStatusBarBackgroundColor)] + && [((UIViewController *)viewController) defaultStatusBarBackgroundColor]) { + return [((UIViewController *)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... diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h index f4de6d5b..ac5219b0 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.h @@ -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 )animationDelegate statusBarColor:(UIColor *_Nullable *_Nullable)statusBarColor; diff --git a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m index a582638c..3d2fb626 100644 --- a/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m +++ b/MVMCoreUI/TopAlert/MVMCoreUITopAlertView.m @@ -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