cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [17/40] git commit: Added ability to set statusbar background color by hex string.
Date Mon, 04 Nov 2013 22:05:31 GMT
Added ability to set statusbar background color by hex string.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugins/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugins/commit/9b6c3c8a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugins/tree/9b6c3c8a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugins/diff/9b6c3c8a

Branch: refs/heads/master
Commit: 9b6c3c8abaca735805baea057c2b3105e45e0a4f
Parents: c019e95
Author: Shazron Abdullah <shazron@apache.org>
Authored: Sun Oct 6 01:18:06 2013 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Sun Oct 6 01:18:06 2013 -0700

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


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/9b6c3c8a/statusbar/src/ios/CDVStatusBar.h
----------------------------------------------------------------------
diff --git a/statusbar/src/ios/CDVStatusBar.h b/statusbar/src/ios/CDVStatusBar.h
index 124128e..3c9d573 100644
--- a/statusbar/src/ios/CDVStatusBar.h
+++ b/statusbar/src/ios/CDVStatusBar.h
@@ -37,5 +37,6 @@
 - (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command;
 
 - (void) statusBarBackgroundColorByName:(CDVInvokedUrlCommand*)command;
+- (void) statusBarBackgroundColorByHexString:(CDVInvokedUrlCommand*)command;
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/9b6c3c8a/statusbar/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/statusbar/src/ios/CDVStatusBar.m b/statusbar/src/ios/CDVStatusBar.m
index e2a660c..7a301b8 100644
--- a/statusbar/src/ios/CDVStatusBar.m
+++ b/statusbar/src/ios/CDVStatusBar.m
@@ -127,4 +127,24 @@
     }
 }
 
+- (void) statusBarBackgroundColorByHexString:(CDVInvokedUrlCommand*)command
+{
+    NSString* value = [command.arguments objectAtIndex:0];
+    if (!([value isKindOfClass:[NSString class]])) {
+        value = @"#000000";
+    }
+    
+    if (![value hasPrefix:@"#"] || [value length] < 7) {
+        return;
+    }
+    
+    unsigned int rgbValue = 0;
+    NSScanner* scanner = [NSScanner scannerWithString:value];
+    [scanner setScanLocation:1];
+    [scanner scanHexInt:&rgbValue];
+    
+    _statusBarBackgroundView.backgroundColor = [UIColor colorWithRed:((rgbValue & 0xFF0000)
>> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0
alpha:1.0];
+}
+
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/9b6c3c8a/statusbar/www/statusbar.js
----------------------------------------------------------------------
diff --git a/statusbar/www/statusbar.js b/statusbar/www/statusbar.js
index 6a2ca9e..b570881 100644
--- a/statusbar/www/statusbar.js
+++ b/statusbar/www/statusbar.js
@@ -50,6 +50,10 @@ StatusBar.statusBarBackgroundColorByName = function(colorname) {
     exec(null, null, "StatusBar", "statusBarBackgroundColorByName", [colorname]);
 }
 
+StatusBar.statusBarBackgroundColorByHexString = function(hexString) {
+    exec(null, null, "StatusBar", "statusBarBackgroundColorByHexString", [hexString]);
+}
+
 // TODO:
 StatusBar.isVisible = true;
 


Mime
View raw message