cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [27/40] git commit: Implement StatusBar.isVisible
Date Mon, 04 Nov 2013 22:05:41 GMT
Implement StatusBar.isVisible


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

Branch: refs/heads/master
Commit: 9d5b7a8bd31406ad4c7ce80536a4c0693448bf61
Parents: a381e82
Author: Shazron Abdullah <shazron@apache.org>
Authored: Mon Oct 7 17:53:04 2013 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Mon Oct 7 17:53:04 2013 -0700

----------------------------------------------------------------------
 statusbar/README.md              | 17 ++++++++++++++++-
 statusbar/src/ios/CDVStatusBar.h |  2 ++
 statusbar/src/ios/CDVStatusBar.m | 24 ++++++++++++++++++++++++
 statusbar/www/statusbar.js       |  4 +++-
 4 files changed, 45 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/9d5b7a8b/statusbar/README.md
----------------------------------------------------------------------
diff --git a/statusbar/README.md b/statusbar/README.md
index 9863f11..94ca746 100644
--- a/statusbar/README.md
+++ b/statusbar/README.md
@@ -21,7 +21,7 @@ Methods
 Properties
 --------
 
-- StatusBar.isVisible (TODO: not implemented yet)
+- StatusBar.isVisible
 
 Permissions
 -----------
@@ -144,6 +144,21 @@ Supported Platforms
 
 - iOS
 
+StatusBar.isVisible
+=================
+
+Read this property to see if the statusbar is visible or not.
+
+    if (StatusBar.isVisible) {
+    	// do something
+    }
+
+
+Supported Platforms
+-------------------
+
+- iOS
+
 
 
     
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/9d5b7a8b/statusbar/src/ios/CDVStatusBar.h
----------------------------------------------------------------------
diff --git a/statusbar/src/ios/CDVStatusBar.h b/statusbar/src/ios/CDVStatusBar.h
index f2ce759..d8cb709 100644
--- a/statusbar/src/ios/CDVStatusBar.h
+++ b/statusbar/src/ios/CDVStatusBar.h
@@ -39,4 +39,6 @@
 - (void) backgroundColorByName:(CDVInvokedUrlCommand*)command;
 - (void) backgroundColorByHexString:(CDVInvokedUrlCommand*)command;
 
+- (void) _ready:(CDVInvokedUrlCommand*)command;
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/9d5b7a8b/statusbar/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/statusbar/src/ios/CDVStatusBar.m b/statusbar/src/ios/CDVStatusBar.m
index da4ae57..71dcfe0 100644
--- a/statusbar/src/ios/CDVStatusBar.m
+++ b/statusbar/src/ios/CDVStatusBar.m
@@ -40,8 +40,21 @@
     }
 }
 
+- (void)observeValueForKeyPath:(NSString*)keyPath ofObject:(id)object change:(NSDictionary*)change
context:(void*)context
+{
+    if ([keyPath isEqual:@"statusBarHidden"]) {
+        NSNumber* newValue = [change objectForKey:NSKeyValueChangeNewKey];
+        BOOL boolValue = [newValue boolValue];
+
+        [self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;",
boolValue? @"true" : @"false" ]];
+    }
+}
+
 - (void)pluginInitialize
 {
+    // observe the statusBarHidden property
+    [[UIApplication sharedApplication] addObserver:self forKeyPath:@"statusBarHidden" options:NSKeyValueObservingOptionNew
context:NULL];
+    
     _statusBarOverlaysWebView = YES; // default
     
     CGRect frame = [[UIApplication sharedApplication] statusBarFrame];
@@ -65,6 +78,12 @@
     }
 }
 
+- (void) _ready:(CDVInvokedUrlCommand*)command
+{
+    // set the initial value
+    [self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;",
[UIApplication sharedApplication].statusBarHidden? @"false" : @"true" ]];
+}
+
 - (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
 {
     // we only care about the latest iOS version or a change in setting
@@ -184,5 +203,10 @@
     [self _backgroundColorByHexString:value];
 }
 
+- (void) dealloc
+{
+    [[UIApplication sharedApplication] removeObserver:self forKeyPath:@"statusBarHidden"];
+}
+
 
 @end

http://git-wip-us.apache.org/repos/asf/cordova-plugins/blob/9d5b7a8b/statusbar/www/statusbar.js
----------------------------------------------------------------------
diff --git a/statusbar/www/statusbar.js b/statusbar/www/statusbar.js
index a2a8249..6de8bf2 100644
--- a/statusbar/www/statusbar.js
+++ b/statusbar/www/statusbar.js
@@ -23,6 +23,9 @@ var argscheck = require('cordova/argscheck'),
     utils = require('cordova/utils'),
     exec = require('cordova/exec');
 
+// prime it
+exec(null, null, "StatusBar", "_ready", []);
+
 var StatusBar = function() {
 };
 
@@ -54,7 +57,6 @@ StatusBar.backgroundColorByHexString = function(hexString) {
     exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
 }
 
-// TODO:
 StatusBar.isVisible = true;
 
 module.exports = StatusBar;


Mime
View raw message