You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2014/03/13 20:58:42 UTC
[13/35] git commit: Added show() and hide() to StatusBar API
Added show() and hide() to StatusBar API
Project: http://git-wip-us.apache.org/repos/asf/cordova-statusbar/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-statusbar/commit/7e42f7db
Tree: http://git-wip-us.apache.org/repos/asf/cordova-statusbar/tree/7e42f7db
Diff: http://git-wip-us.apache.org/repos/asf/cordova-statusbar/diff/7e42f7db
Branch: refs/heads/master
Commit: 7e42f7db49778a89d44aefd76aa90d691a850e8a
Parents: c2f13fe
Author: Shazron Abdullah <sh...@apache.org>
Authored: Mon Oct 14 16:47:38 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Oct 14 16:47:38 2013 -0700
----------------------------------------------------------------------
src/ios/CDVStatusBar.h | 3 ++
src/ios/CDVStatusBar.m | 67 +++++++++++++++++++++++++++++++++++++++++----
www/statusbar.js | 8 ++++++
3 files changed, 72 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/7e42f7db/src/ios/CDVStatusBar.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.h b/src/ios/CDVStatusBar.h
index d8cb709..a059e5c 100644
--- a/src/ios/CDVStatusBar.h
+++ b/src/ios/CDVStatusBar.h
@@ -39,6 +39,9 @@
- (void) backgroundColorByName:(CDVInvokedUrlCommand*)command;
- (void) backgroundColorByHexString:(CDVInvokedUrlCommand*)command;
+- (void) hide:(CDVInvokedUrlCommand*)command;
+- (void) show:(CDVInvokedUrlCommand*)command;
+
- (void) _ready:(CDVInvokedUrlCommand*)command;
@end
http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/7e42f7db/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m
index 71dcfe0..4a6efec 100644
--- a/src/ios/CDVStatusBar.m
+++ b/src/ios/CDVStatusBar.m
@@ -46,7 +46,7 @@
NSNumber* newValue = [change objectForKey:NSKeyValueChangeNewKey];
BOOL boolValue = [newValue boolValue];
- [self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;", boolValue? @"true" : @"false" ]];
+ [self.commandDelegate evalJs:[NSString stringWithFormat:@"StatusBar.isVisible = %@;", boolValue? @"false" : @"true" ]];
}
}
@@ -90,18 +90,18 @@
if (!IsAtLeastiOSVersion(@"7.0") || statusBarOverlaysWebView == _statusBarOverlaysWebView) {
return;
}
+
+ CGRect bounds = [[UIScreen mainScreen] bounds];
if (statusBarOverlaysWebView) {
- CGRect bounds = self.viewController.view.bounds;
- self.webView.frame = bounds;
-
[_statusBarBackgroundView removeFromSuperview];
+ self.webView.frame = bounds;
} else {
+
CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
- CGRect bounds = self.viewController.view.bounds;
- bounds.origin.y += statusBarFrame.size.height;
+ bounds.origin.y = statusBarFrame.size.height;
bounds.size.height -= statusBarFrame.size.height;
self.webView.frame = bounds;
@@ -202,6 +202,61 @@
[self _backgroundColorByHexString:value];
}
+
+- (void) hide:(CDVInvokedUrlCommand*)command
+{
+ UIApplication* app = [UIApplication sharedApplication];
+
+ if (!app.isStatusBarHidden)
+ {
+ self.viewController.wantsFullScreenLayout = YES;
+ [app setStatusBarHidden:YES];
+
+ if (IsAtLeastiOSVersion(@"7.0")) {
+ [_statusBarBackgroundView removeFromSuperview];
+ }
+
+ CGRect bounds = [[UIScreen mainScreen] bounds];
+
+ self.viewController.view.frame = bounds;
+ self.webView.frame = bounds;
+
+ }
+}
+
+- (void) show:(CDVInvokedUrlCommand*)command
+{
+ UIApplication* app = [UIApplication sharedApplication];
+
+ if (app.isStatusBarHidden)
+ {
+ BOOL isIOS7 = (IsAtLeastiOSVersion(@"7.0"));
+ self.viewController.wantsFullScreenLayout = isIOS7;
+
+ [app setStatusBarHidden:NO];
+
+ if (isIOS7) {
+ CGRect bounds = [[UIScreen mainScreen] bounds];
+ self.viewController.view.frame = bounds;
+
+ CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
+
+ if (!self.statusBarOverlaysWebView) {
+ bounds.origin.y = statusBarFrame.size.height;
+ bounds.size.height -= statusBarFrame.size.height;
+
+ [self.webView.superview addSubview:_statusBarBackgroundView];
+ }
+
+ self.webView.frame = bounds;
+
+ } else {
+
+ CGRect bounds = [[UIScreen mainScreen] applicationFrame];
+ self.viewController.view.frame = bounds;
+ }
+ }
+}
- (void) dealloc
{
http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/7e42f7db/www/statusbar.js
----------------------------------------------------------------------
diff --git a/www/statusbar.js b/www/statusbar.js
index 6de8bf2..04b894b 100644
--- a/www/statusbar.js
+++ b/www/statusbar.js
@@ -57,6 +57,14 @@ StatusBar.backgroundColorByHexString = function(hexString) {
exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
}
+StatusBar.hide = function() {
+ exec(null, null, "StatusBar", "hide", []);
+}
+
+StatusBar.show = function() {
+ exec(null, null, "StatusBar", "show", []);
+}
+
StatusBar.isVisible = true;
module.exports = StatusBar;