cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [04/35] git commit: Added ability to set statusbar background color by hex string.
Date Thu, 13 Mar 2014 19:58:33 GMT
Added ability to set statusbar background color by hex string.



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

Branch: refs/heads/master
Commit: 058c6b71cc45b9fa29579fece2a30fc384ea1b35
Parents: da275b5
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

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


http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/058c6b71/src/ios/CDVStatusBar.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.h b/src/ios/CDVStatusBar.h
index 124128e..3c9d573 100644
--- a/src/ios/CDVStatusBar.h
+++ b/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-statusbar/blob/058c6b71/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m
index e2a660c..7a301b8 100644
--- a/src/ios/CDVStatusBar.m
+++ b/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-statusbar/blob/058c6b71/www/statusbar.js
----------------------------------------------------------------------
diff --git a/www/statusbar.js b/www/statusbar.js
index 6a2ca9e..b570881 100644
--- a/www/statusbar.js
+++ b/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