You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/05/17 03:52:04 UTC
[02/21] ios commit: [CB-3405] InAppBrowser option to hide bottom bar
with Done/History buttons
[CB-3405] InAppBrowser option to hide bottom bar with Done/History buttons
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/f9f50d38
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/f9f50d38
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/f9f50d38
Branch: refs/heads/3.0.0
Commit: f9f50d38f1f1344f07fd67f4cd117dcf645299d5
Parents: 8fce674
Author: Shazron Abdullah <sh...@apache.org>
Authored: Wed May 15 16:01:59 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed May 15 16:01:59 2013 -0700
----------------------------------------------------------------------
CordovaLib/Classes/CDVInAppBrowser.h | 2 +
CordovaLib/Classes/CDVInAppBrowser.m | 119 +++++++++++++++++++++++++----
2 files changed, 106 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f9f50d38/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.h b/CordovaLib/Classes/CDVInAppBrowser.h
index 765326a..c1aa61a 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.h
+++ b/CordovaLib/Classes/CDVInAppBrowser.h
@@ -60,6 +60,7 @@
- (void)close;
- (void)navigateTo:(NSURL*)url;
- (void)showLocationBar:(BOOL)show;
+- (void)showToolBar:(BOOL)show;
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent;
@@ -68,6 +69,7 @@
@interface CDVInAppBrowserOptions : NSObject {}
@property (nonatomic, assign) BOOL location;
+@property (nonatomic, assign) BOOL toolbar;
@property (nonatomic, copy) NSString* presentationstyle;
@property (nonatomic, copy) NSString* transitionstyle;
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/f9f50d38/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
index b03d1fe..dfc231d 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/CordovaLib/Classes/CDVInAppBrowser.m
@@ -103,6 +103,7 @@
CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
[self.inAppBrowserViewController showLocationBar:browserOptions.location];
+ [self.inAppBrowserViewController showToolBar:browserOptions.toolbar];
// Set Presentation Style
UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default
@@ -469,30 +470,117 @@
- (void)showLocationBar:(BOOL)show
{
- CGRect addressLabelFrame = self.addressLabel.frame;
- BOOL locationBarVisible = (addressLabelFrame.size.height > 0);
+ CGRect toolbarFrame = self.toolbar.frame;
+ CGRect locationbarFrame = self.addressLabel.frame;
+
+ BOOL toolbarVisible = !self.toolbar.hidden;
// prevent double show/hide
- if (locationBarVisible == show) {
+ if (show == !(self.addressLabel.hidden)) {
return;
}
if (show) {
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= FOOTER_HEIGHT;
- self.webView.frame = webViewBounds;
+ self.addressLabel.hidden = NO;
+
+ if (toolbarVisible) {
+ // toolBar at the bottom, leave as is
+ // put locationBar on top of the toolBar
+
+ CGRect webViewBounds = self.view.bounds;
+ webViewBounds.size.height -= FOOTER_HEIGHT;
+ self.webView.frame = webViewBounds;
+
+ locationbarFrame.origin.y = webViewBounds.size.height;
+ self.addressLabel.frame = locationbarFrame;
+ } else {
+ // no toolBar, so put locationBar at the bottom
+
+ CGRect webViewBounds = self.view.bounds;
+ webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
+ self.webView.frame = webViewBounds;
- CGRect addressLabelFrame = self.addressLabel.frame;
- addressLabelFrame.size.height = LOCATIONBAR_HEIGHT;
- self.addressLabel.frame = addressLabelFrame;
+ locationbarFrame.origin.y = webViewBounds.size.height;
+ self.addressLabel.frame = locationbarFrame;
+ }
} else {
- CGRect webViewBounds = self.view.bounds;
- webViewBounds.size.height -= TOOLBAR_HEIGHT;
- self.webView.frame = webViewBounds;
+ self.addressLabel.hidden = YES;
+
+ if (toolbarVisible) {
+ // locationBar is on top of toolBar, hide locationBar
- CGRect addressLabelFrame = self.addressLabel.frame;
- addressLabelFrame.size.height = 0;
- self.addressLabel.frame = addressLabelFrame;
+ // webView take up whole height less toolBar height
+ CGRect webViewBounds = self.view.bounds;
+ webViewBounds.size.height -= TOOLBAR_HEIGHT;
+ self.webView.frame = webViewBounds;
+ } else {
+ // no toolBar, expand webView to screen dimensions
+
+ CGRect webViewBounds = self.view.bounds;
+ self.webView.frame = webViewBounds;
+ }
+ }
+}
+
+- (void)showToolBar:(BOOL)show
+{
+ CGRect toolbarFrame = self.toolbar.frame;
+ CGRect locationbarFrame = self.addressLabel.frame;
+
+ BOOL locationbarVisible = !self.addressLabel.hidden;
+
+ // prevent double show/hide
+ if (show == !(self.toolbar.hidden)) {
+ return;
+ }
+
+ if (show) {
+ self.toolbar.hidden = NO;
+
+ if (locationbarVisible) {
+ // locationBar at the bottom, move locationBar up
+ // put toolBar at the bottom
+
+ CGRect webViewBounds = self.view.bounds;
+ webViewBounds.size.height -= FOOTER_HEIGHT;
+ self.webView.frame = webViewBounds;
+
+ locationbarFrame.origin.y = webViewBounds.size.height;
+ self.addressLabel.frame = locationbarFrame;
+
+ toolbarFrame.origin.y = (webViewBounds.size.height + LOCATIONBAR_HEIGHT);
+ self.toolbar.frame = toolbarFrame;
+ } else {
+ // no locationBar, so put toolBar at the bottom
+
+ CGRect webViewBounds = self.view.bounds;
+ webViewBounds.size.height -= TOOLBAR_HEIGHT;
+ self.webView.frame = webViewBounds;
+
+ toolbarFrame.origin.y = webViewBounds.size.height;
+ self.toolbar.frame = toolbarFrame;
+ }
+ } else {
+ self.toolbar.hidden = YES;
+
+ if (locationbarVisible) {
+ // locationBar is on top of toolBar, hide toolBar
+ // put locationBar at the bottom
+
+ // webView take up whole height less locationBar height
+ CGRect webViewBounds = self.view.bounds;
+ webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
+ self.webView.frame = webViewBounds;
+
+ // move locationBar down
+ locationbarFrame.origin.y = webViewBounds.size.height;
+ self.addressLabel.frame = locationbarFrame;
+ } else {
+ // no locationBar, expand webView to screen dimensions
+
+ CGRect webViewBounds = self.view.bounds;
+ self.webView.frame = webViewBounds;
+ }
}
}
@@ -655,6 +743,7 @@
if (self = [super init]) {
// default values
self.location = YES;
+ self.toolbar = YES;
self.enableviewportscale = NO;
self.mediaplaybackrequiresuseraction = NO;