cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [03/35] git commit: Added statusbar background, including API to change its background color
Date Thu, 13 Mar 2014 23:14:16 GMT
Added statusbar background, including API to change its background color



Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/commit/da275b57
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/tree/da275b57
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/diff/da275b57

Branch: refs/heads/dev
Commit: da275b579fbb3642635d0777082f7b96ae003e20
Parents: 2e15c9c
Author: Shazron Abdullah <shazron@apache.org>
Authored: Sun Oct 6 00:47:33 2013 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Sun Oct 6 00:47:33 2013 -0700

----------------------------------------------------------------------
 src/ios/CDVStatusBar.h |  3 +++
 src/ios/CDVStatusBar.m | 22 ++++++++++++++++++++++
 www/statusbar.js       |  4 ++++
 3 files changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/da275b57/src/ios/CDVStatusBar.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.h b/src/ios/CDVStatusBar.h
index 298b3f5..124128e 100644
--- a/src/ios/CDVStatusBar.h
+++ b/src/ios/CDVStatusBar.h
@@ -23,6 +23,8 @@
 @interface CDVStatusBar : CDVPlugin {
     @protected
     BOOL _statusBarOverlaysWebView;
+    @protected
+    UIView* _statusBarBackgroundView;
 }
 
 @property (atomic, assign) BOOL statusBarOverlaysWebView;
@@ -34,5 +36,6 @@
 - (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command;
 - (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command;
 
+- (void) statusBarBackgroundColorByName:(CDVInvokedUrlCommand*)command;
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/da275b57/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m
index 9fe4632..e2a660c 100644
--- a/src/ios/CDVStatusBar.m
+++ b/src/ios/CDVStatusBar.m
@@ -36,6 +36,11 @@
 {
     _statusBarOverlaysWebView = YES; // default
     
+    CGRect frame = [[UIApplication sharedApplication] statusBarFrame];
+    
+    _statusBarBackgroundView = [[UIView alloc] initWithFrame:frame];
+    _statusBarBackgroundView.backgroundColor = [UIColor blackColor];
+    
     NSString* setting  = @"StatusBarOverlaysWebView";
     if ([self settingForKey:setting]) {
         self.statusBarOverlaysWebView = [(NSNumber*)[self settingForKey:setting] boolValue];
@@ -57,6 +62,8 @@
         bounds.size.height += statusBarFrame.size.height;
         
         self.webView.frame = bounds;
+        
+        [_statusBarBackgroundView removeFromSuperview];
 
     } else {
         CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
@@ -65,6 +72,8 @@
         bounds.size.height -= statusBarFrame.size.height;
         
         self.webView.frame = bounds;
+        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
+        [self.webView.superview addSubview:_statusBarBackgroundView];
     }
     
     _statusBarOverlaysWebView = statusBarOverlaysWebView;
@@ -105,4 +114,17 @@
     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
 }
 
+- (void) statusBarBackgroundColorByName:(CDVInvokedUrlCommand*)command
+{
+    id value = [command.arguments objectAtIndex:0];
+    if (!([value isKindOfClass:[NSString class]])) {
+        value = @"black";
+    }
+    
+    SEL selector = NSSelectorFromString([value stringByAppendingString:@"Color"]);
+    if ([UIColor respondsToSelector:selector]) {
+        _statusBarBackgroundView.backgroundColor = [UIColor performSelector:selector];
+    }
+}
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugin-statusbar/blob/da275b57/www/statusbar.js
----------------------------------------------------------------------
diff --git a/www/statusbar.js b/www/statusbar.js
index 8c461bd..6a2ca9e 100644
--- a/www/statusbar.js
+++ b/www/statusbar.js
@@ -46,6 +46,10 @@ StatusBar.styleBlackOpaque = function() {
     exec(null, null, "StatusBar", "styleBlackOpaque", []);
 };
 
+StatusBar.statusBarBackgroundColorByName = function(colorname) {
+    exec(null, null, "StatusBar", "statusBarBackgroundColorByName", [colorname]);
+}
+
 // TODO:
 StatusBar.isVisible = true;
 


Mime
View raw message