cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject [01/35] git commit: Added statusbar plugin.
Date Thu, 13 Mar 2014 19:58:30 GMT
Repository: cordova-statusbar
Updated Branches:
  refs/heads/master [created] bdbaf1295


Added statusbar plugin.

This controls whether the statusbar overlays the webview in iOS 7, as well as allows changing
of the statusbar styles.


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

Branch: refs/heads/master
Commit: 512a1388c65fc099b56c0a40e6c63458b2d029eb
Parents: 
Author: Shazron Abdullah <shazron@apache.org>
Authored: Fri Oct 4 18:03:18 2013 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Fri Oct 4 18:03:18 2013 -0700

----------------------------------------------------------------------
 plugin.xml             |  38 ++++++++++++++++
 src/ios/CDVStatusBar.h |  38 ++++++++++++++++
 src/ios/CDVStatusBar.m | 108 ++++++++++++++++++++++++++++++++++++++++++++
 www/statusbar.js       |  57 +++++++++++++++++++++++
 4 files changed, 241 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/512a1388/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
new file mode 100644
index 0000000..ad69b14
--- /dev/null
+++ b/plugin.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
+    xmlns:rim="http://www.blackberry.com/ns/widgets"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    id="org.apache.cordova.statusbar"
+    version="0.1.0">
+    <name>StatusBar</name>
+    <description>Cordova StatusBar Plugin</description>
+    <license>Apache 2.0</license>
+    <keywords>cordova,statusbar</keywords>
+
+	<engines>
+		<engine name="cordova" version=">=3.0.0" />
+	</engines>
+
+    <js-module src="www/statusbar.js" name="statusbar">
+    	<clobbers target="window.StatusBar" />
+    </js-module>
+
+    <!-- ios -->
+    <platform name="ios">
+        <config-file target="config.xml" parent="/*">
+            <feature name="StatusBar">
+                <param name="ios-package" value="CDVStatusBar" onload="true" />
+            </feature>
+        </config-file>
+        
+        <config-file target="*-Info.plist" parent="UIViewControllerBasedStatusBarAppearance"
>
+        	<key>UIViewControllerBasedStatusBarAppearance</key>
+            <false/>
+        </config-file>        
+
+        <header-file src="src/ios/CDVStatusBar.h" />
+        <source-file src="src/ios/CDVStatusBar.m" />
+    </platform>
+
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/512a1388/src/ios/CDVStatusBar.h
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.h b/src/ios/CDVStatusBar.h
new file mode 100644
index 0000000..298b3f5
--- /dev/null
+++ b/src/ios/CDVStatusBar.h
@@ -0,0 +1,38 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+ 
+ http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+#import <Cordova/CDVPlugin.h>
+#import <Cordova/CDVInvokedUrlCommand.h>
+
+@interface CDVStatusBar : CDVPlugin {
+    @protected
+    BOOL _statusBarOverlaysWebView;
+}
+
+@property (atomic, assign) BOOL statusBarOverlaysWebView;
+
+- (void) statusBarOverlaysWebView:(CDVInvokedUrlCommand*)command;
+
+- (void) styleDefault:(CDVInvokedUrlCommand*)command;
+- (void) styleLightContent:(CDVInvokedUrlCommand*)command;
+- (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command;
+- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command;
+
+
+@end

http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/512a1388/src/ios/CDVStatusBar.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVStatusBar.m b/src/ios/CDVStatusBar.m
new file mode 100644
index 0000000..9fe4632
--- /dev/null
+++ b/src/ios/CDVStatusBar.m
@@ -0,0 +1,108 @@
+/*
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+ 
+ http://www.apache.org/licenses/LICENSE-2.0
+ 
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ */
+
+/* 
+ NOTE: plugman/cordova cli should have already installed this,
+ but you need the value UIViewControllerBasedStatusBarAppearance
+ in your Info.plist as well to set the styles in iOS 7
+ */
+
+#import "CDVStatusBar.h"
+
+@implementation CDVStatusBar
+
+- (id)settingForKey:(NSString*)key
+{
+    return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
+}
+
+- (void)pluginInitialize
+{
+    _statusBarOverlaysWebView = YES; // default
+    
+    NSString* setting  = @"StatusBarOverlaysWebView";
+    if ([self settingForKey:setting]) {
+        self.statusBarOverlaysWebView = [(NSNumber*)[self settingForKey:setting] boolValue];
+    }
+}
+
+- (void) setStatusBarOverlaysWebView:(BOOL)statusBarOverlaysWebView
+{
+    // we only care about the latest iOS version or a change in setting
+    if (!IsAtLeastiOSVersion(@"7.0") || statusBarOverlaysWebView == _statusBarOverlaysWebView)
{
+        return;
+    }
+    
+    if (statusBarOverlaysWebView) {
+        
+        CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
+        CGRect bounds = self.viewController.view.bounds;
+        bounds.origin.y = 0;
+        bounds.size.height += statusBarFrame.size.height;
+        
+        self.webView.frame = bounds;
+
+    } else {
+        CGRect statusBarFrame = [UIApplication sharedApplication].statusBarFrame;
+        CGRect bounds = self.viewController.view.bounds;
+        bounds.origin.y += statusBarFrame.size.height;
+        bounds.size.height -= statusBarFrame.size.height;
+        
+        self.webView.frame = bounds;
+    }
+    
+    _statusBarOverlaysWebView = statusBarOverlaysWebView;
+}
+
+- (BOOL) statusBarOverlaysWebView
+{
+    return _statusBarOverlaysWebView;
+}
+
+- (void) statusBarOverlaysWebView:(CDVInvokedUrlCommand*)command
+{
+    id value = [command.arguments objectAtIndex:0];
+    if (!([value isKindOfClass:[NSNumber class]])) {
+        value = [NSNumber numberWithBool:YES];
+    }
+    
+    self.statusBarOverlaysWebView = [value boolValue];
+}
+
+- (void) styleDefault:(CDVInvokedUrlCommand*)command
+{
+    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
+}
+
+- (void) styleLightContent:(CDVInvokedUrlCommand*)command
+{
+    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
+}
+
+- (void) styleBlackTranslucent:(CDVInvokedUrlCommand*)command
+{
+    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
+}
+
+- (void) styleBlackOpaque:(CDVInvokedUrlCommand*)command
+{
+    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
+}
+
+@end

http://git-wip-us.apache.org/repos/asf/cordova-statusbar/blob/512a1388/www/statusbar.js
----------------------------------------------------------------------
diff --git a/www/statusbar.js b/www/statusbar.js
new file mode 100644
index 0000000..4f1886a
--- /dev/null
+++ b/www/statusbar.js
@@ -0,0 +1,57 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+// var argscheck = require('cordova/argscheck'),
+//     utils = require('cordova/utils'),
+//     exec = require('cordova/exec');
+
+(function() {
+   
+var exec = cordova.require('cordova/exec')
+
+var StatusBar = function() {
+};
+
+StatusBar.statusBarOverlaysWebView = function(doOverlay) {
+    exec(null, null, "StatusBar", "statusBarOverlaysWebView", [doOverlay]);
+};
+
+StatusBar.styleDefault = function() {
+    exec(null, null, "StatusBar", "styleDefault", []);
+};
+
+StatusBar.styleLightContent = function() {
+    exec(null, null, "StatusBar", "styleLightContent", []);
+};
+
+StatusBar.styleBlackTranslucent = function() {
+    exec(null, null, "StatusBar", "styleBlackTranslucent", []);
+};
+
+StatusBar.styleBlackOpaque = function() {
+    exec(null, null, "StatusBar", "styleBlackOpaque", []);
+};
+
+StatusBar.isVisible = true;
+
+window.StatusBar = StatusBar;
+
+})();
\ No newline at end of file


Mime
View raw message