You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2015/10/20 02:16:10 UTC

[1/2] cordova-plugin-dialogs git commit: CB-9347 - fix to allow to stack multiple UIAlertControllers

Repository: cordova-plugin-dialogs
Updated Branches:
  refs/heads/master fb994515f -> 7fd94a1f3


CB-9347 - fix to allow to stack multiple UIAlertControllers

Now you can stack multiple UIAlertControllers

I had to add a 0.5s delay in case the user tries to present a new
UIAlertController while one is currently being presented (on presenting
animation)


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/98d3e90c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/98d3e90c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/98d3e90c

Branch: refs/heads/master
Commit: 98d3e90cd3b4879bed06c655dc9641107037c678
Parents: fb99451
Author: Julio César <jc...@gmail.com>
Authored: Thu Jul 16 19:10:06 2015 +0200
Committer: Julio César <jc...@gmail.com>
Committed: Thu Jul 16 19:10:06 2015 +0200

----------------------------------------------------------------------
 src/ios/CDVNotification.m | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/98d3e90c/src/ios/CDVNotification.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVNotification.m b/src/ios/CDVNotification.m
index 1581ad3..f96d0d5 100644
--- a/src/ios/CDVNotification.m
+++ b/src/ios/CDVNotification.m
@@ -23,6 +23,7 @@
 #define DIALOG_TYPE_PROMPT @"prompt"
 
 static void soundCompletionCallback(SystemSoundID ssid, void* data);
+static NSMutableArray *alertList = nil;
 
 @implementation CDVNotification
 
@@ -94,9 +95,22 @@ static void soundCompletionCallback(SystemSoundID ssid, void* data);
             }];
         }
         
+        if(!alertList)
+            alertList = [[NSMutableArray alloc] init];
+        [alertList addObject:alertController];
+        dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * ([alertList count]-1)/2);
         
-        
-        [self.viewController presentViewController:alertController animated:YES completion:nil];
+        dispatch_after(delay, dispatch_get_main_queue(), ^(void){
+            
+            UIViewController *presentingViewController = self.viewController;
+            while(presentingViewController.presentedViewController != nil)
+            {
+                presentingViewController = presentingViewController.presentedViewController;
+            }
+            [presentingViewController presentViewController:alertController animated:YES completion:^{
+                [alertList removeObject:alertController];
+            }];
+        });
         
     } else {
 #endif


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[2/2] cordova-plugin-dialogs git commit: CB-9347 - fix to allow to stack multiple UIAlertControllers

Posted by pu...@apache.org.
CB-9347 - fix to allow to stack multiple UIAlertControllers

Deleted the 0,5 seconds delay, now it presents the next
UIAlertController (if any) on the presentViewController completion
block


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/7fd94a1f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/7fd94a1f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/7fd94a1f

Branch: refs/heads/master
Commit: 7fd94a1f337433c956b9d21d57e89ee64c1be65e
Parents: 98d3e90
Author: Julio César <jc...@gmail.com>
Authored: Fri Jul 17 17:04:04 2015 +0200
Committer: Julio César <jc...@gmail.com>
Committed: Fri Jul 17 17:04:04 2015 +0200

----------------------------------------------------------------------
 src/ios/CDVNotification.m | 34 ++++++++++++++++++++++------------
 1 file changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/7fd94a1f/src/ios/CDVNotification.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVNotification.m b/src/ios/CDVNotification.m
index f96d0d5..b10cb03 100644
--- a/src/ios/CDVNotification.m
+++ b/src/ios/CDVNotification.m
@@ -98,19 +98,10 @@ static NSMutableArray *alertList = nil;
         if(!alertList)
             alertList = [[NSMutableArray alloc] init];
         [alertList addObject:alertController];
-        dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC * ([alertList count]-1)/2);
         
-        dispatch_after(delay, dispatch_get_main_queue(), ^(void){
-            
-            UIViewController *presentingViewController = self.viewController;
-            while(presentingViewController.presentedViewController != nil)
-            {
-                presentingViewController = presentingViewController.presentedViewController;
-            }
-            [presentingViewController presentViewController:alertController animated:YES completion:^{
-                [alertList removeObject:alertController];
-            }];
-        });
+        if ([alertList count]==1) {
+            [self presentAlertcontroller];
+        }
         
     } else {
 #endif
@@ -225,6 +216,25 @@ static void soundCompletionCallback(SystemSoundID  ssid, void* data) {
     playBeep([count intValue]);
 }
 
+-(UIViewController *)getTopPresentedViewController {
+    UIViewController *presentingViewController = self.viewController;
+    while(presentingViewController.presentedViewController != nil)
+    {
+        presentingViewController = presentingViewController.presentedViewController;
+    }
+    return presentingViewController;
+}
+
+-(void)presentAlertcontroller {
+    
+    [self.getTopPresentedViewController presentViewController:[alertList firstObject] animated:YES completion:^{
+        [alertList removeObject:[alertList firstObject]];
+        if ([alertList count]>0) {
+            [self presentAlertcontroller];
+        }
+    }];
+    
+}
 
 @end
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org