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 2013/01/15 00:41:34 UTC

ios commit: [CB-2063] InAppBrowser - support iPad presentation style, iOS transition styles

Updated Branches:
  refs/heads/master 6fe1f3d8e -> 66945320a


[CB-2063] InAppBrowser - support iPad presentation style, iOS transition styles


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

Branch: refs/heads/master
Commit: 66945320aaf8cfe6d297570ace85aad7d6f5ba74
Parents: 6fe1f3d
Author: Shazron Abdullah <sh...@apache.org>
Authored: Fri Dec 14 16:11:46 2012 -0800
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Mon Jan 14 15:41:23 2013 -0800

----------------------------------------------------------------------
 CordovaLib/Classes/CDVInAppBrowser.h |    2 +
 CordovaLib/Classes/CDVInAppBrowser.m |   38 ++++++++++++++++++++++++++--
 2 files changed, 37 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/66945320/CordovaLib/Classes/CDVInAppBrowser.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.h b/CordovaLib/Classes/CDVInAppBrowser.h
index 51199ed..fb3d485 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.h
+++ b/CordovaLib/Classes/CDVInAppBrowser.h
@@ -66,6 +66,8 @@
 @interface CDVInAppBrowserOptions : NSObject {}
 
 @property (nonatomic, assign) BOOL location;
+@property (nonatomic, copy) NSString* presentationstyle;
+@property (nonatomic, copy) NSString* transitionstyle;
 
 + (CDVInAppBrowserOptions*)parseOptions:(NSString*)options;
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/66945320/CordovaLib/Classes/CDVInAppBrowser.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInAppBrowser.m b/CordovaLib/Classes/CDVInAppBrowser.m
index 22fd1fc..df36026 100644
--- a/CordovaLib/Classes/CDVInAppBrowser.m
+++ b/CordovaLib/Classes/CDVInAppBrowser.m
@@ -103,6 +103,28 @@
     CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
     [self.inAppBrowserViewController showLocationBar:browserOptions.location];
 
+    // Set Presentation Style
+    UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default
+    if (browserOptions.presentationstyle != nil) {
+        if ([browserOptions.presentationstyle isEqualToString:@"pagesheet"]) {
+            presentationStyle = UIModalPresentationPageSheet;
+        } else if ([browserOptions.presentationstyle isEqualToString:@"formsheet"]) {
+            presentationStyle = UIModalPresentationFormSheet;
+        }
+    }
+    self.inAppBrowserViewController.modalPresentationStyle = presentationStyle;
+
+    // Set Transition Style
+    UIModalTransitionStyle transitionStyle = UIModalTransitionStyleCoverVertical; // default
+    if (browserOptions.transitionstyle != nil) {
+        if ([browserOptions.transitionstyle isEqualToString:@"fliphorizontal"]) {
+            transitionStyle = UIModalTransitionStyleFlipHorizontal;
+        } else if ([browserOptions.transitionstyle isEqualToString:@"crossdissolve"]) {
+            transitionStyle = UIModalTransitionStyleCrossDissolve;
+        }
+    }
+    self.inAppBrowserViewController.modalTransitionStyle = transitionStyle;
+
     if (self.viewController.modalViewController != self.inAppBrowserViewController) {
         [self.viewController presentModalViewController:self.inAppBrowserViewController animated:YES];
     }
@@ -478,12 +500,22 @@
 
         if ([keyvalue count] == 2) {
             NSString* key = [[keyvalue objectAtIndex:0] lowercaseString];
-            NSString* value = [keyvalue objectAtIndex:1];
-            BOOL valueBool = [[value lowercaseString] isEqualToString:@"yes"];
+            NSString* value = [[keyvalue objectAtIndex:1] lowercaseString];
+
+            BOOL isBoolean = [value isEqualToString:@"yes"] || [value isEqualToString:@"no"];
+            NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
+            [numberFormatter setAllowsFloats:YES];
+            BOOL isNumber = [numberFormatter numberFromString:value] != nil;
 
             // set the property according to the key name
             if ([obj respondsToSelector:NSSelectorFromString(key)]) {
-                [obj setValue:[NSNumber numberWithBool:valueBool] forKey:key];
+                if (isNumber) {
+                    [obj setValue:[numberFormatter numberFromString:value] forKey:key];
+                } else if (isBoolean) {
+                    [obj setValue:[NSNumber numberWithBool:[value isEqualToString:@"yes"]] forKey:key];
+                } else {
+                    [obj setValue:value forKey:key];
+                }
             }
         }
     }