diff --git a/plugin.xml b/plugin.xml index fcc9560b..71592a16 100644 --- a/plugin.xml +++ b/plugin.xml @@ -61,7 +61,7 @@ - + diff --git a/src/ios/CDVStatusBar.h b/src/ios/CDVStatusBar.h index 93650b1e..ad02de63 100644 --- a/src/ios/CDVStatusBar.h +++ b/src/ios/CDVStatusBar.h @@ -35,6 +35,7 @@ - (void) overlaysWebView:(CDVInvokedUrlCommand*)command; - (void) styleDefault:(CDVInvokedUrlCommand*)command; +- (void) styleDarkContent:(CDVInvokedUrlCommand*)command; - (void) styleLightContent:(CDVInvokedUrlCommand*)command; - (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command; - (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command; diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m index ce87653b..038f0385 100644 --- a/src/ios/CDVStatusBar.m +++ b/src/ios/CDVStatusBar.m @@ -316,6 +316,8 @@ - (void) setStatusBarStyle:(NSString*)statusBarStyle [self styleDefault:nil]; } else if ([lcStatusBarStyle isEqualToString:@"lightcontent"]) { [self styleLightContent:nil]; + } else if ([lcStatusBarStyle isEqualToString:@"darkcontent"]) { + [self styleDarkContent:nil]; } else if ([lcStatusBarStyle isEqualToString:@"blacktranslucent"]) { [self styleBlackTranslucent:nil]; } else if ([lcStatusBarStyle isEqualToString:@"blackopaque"]) { @@ -325,12 +327,12 @@ - (void) setStatusBarStyle:(NSString*)statusBarStyle - (void) styleDefault:(CDVInvokedUrlCommand*)command { - if (@available(iOS 13.0, *)) { - // TODO - Replace with UIStatusBarStyleDarkContent once Xcode 10 support is dropped - [self setStyleForStatusBar:3]; - } else { - [self setStyleForStatusBar:UIStatusBarStyleDefault]; - } + [self setStyleForStatusBar:UIStatusBarStyleDefault]; +} + +- (void) styleDarkContent:(CDVInvokedUrlCommand*)command +{ + [self setStyleForStatusBar:UIStatusBarStyleDarkContent]; } - (void) styleLightContent:(CDVInvokedUrlCommand*)command diff --git a/tests/tests.js b/tests/tests.js index dee2eb1b..bc295f55 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -50,6 +50,9 @@ exports.defineAutoTests = function () { expect(window.StatusBar.styleDefault).toBeDefined(); expect(typeof window.StatusBar.styleDefault).toBe('function'); + expect(window.StatusBar.styleDarkContent).toBeDefined(); + expect(typeof window.StatusBar.styleDarkContent).toBe('function'); + expect(window.StatusBar.styleLightContent).toBeDefined(); expect(typeof window.StatusBar.styleLightContent).toBe('function'); diff --git a/types/index.d.ts b/types/index.d.ts index 608f989e..0ae2f0c4 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -25,10 +25,15 @@ interface StatusBar { overlaysWebView(isOverlay: boolean): void; /** - * Use the default statusbar (dark text, for light backgrounds). + * Automatically chooses light or dark content based on the user interface style */ styleDefault(): void; + /** + * Use the darkContent statusbar (dark text, for light backgrounds). + */ + styleDarkContent(): void; + /** * Use the lightContent statusbar (light text, for dark backgrounds). */ @@ -78,4 +83,4 @@ interface StatusBar { isVisible: boolean; } -declare var StatusBar: StatusBar; \ No newline at end of file +declare var StatusBar: StatusBar; diff --git a/www/statusbar.js b/www/statusbar.js index 4654f657..39c84dac 100644 --- a/www/statusbar.js +++ b/www/statusbar.js @@ -53,7 +53,7 @@ var StatusBar = { }, styleDefault: function () { - // dark text ( to be used on a light background ) + // automatically chooses light or dark content based on the user interface style exec(null, null, 'StatusBar', 'styleDefault', []); }, @@ -61,6 +61,11 @@ var StatusBar = { // light text ( to be used on a dark background ) exec(null, null, 'StatusBar', 'styleLightContent', []); }, + + styleDarkContent: function () { + // dark text ( to be used on a light background ) + exec(null, null, 'StatusBar', 'styleDarkContent', []); + }, styleBlackTranslucent: function () { console.warn('styleBlackTranslucent is deprecated and will be removed in next major release, use styleLightContent');