cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cordova-plugin-dialogs] jcesarmobile commented on a change in pull request #138: breaking(ios): remove CDVAlertView
Date Wed, 01 Jul 2020 17:05:49 GMT

jcesarmobile commented on a change in pull request #138:
URL: https://github.com/apache/cordova-plugin-dialogs/pull/138#discussion_r448501129



##########
File path: src/ios/CDVNotification.m
##########
@@ -39,100 +39,49 @@ @implementation CDVNotification
  */
 - (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSArray*)buttons
defaultText:(NSString*)defaultText callbackId:(NSString*)callbackId dialogType:(NSString*)dialogType
 {
-    
     int count = (int)[buttons count];
-#ifdef __IPHONE_8_0
-    if (NSClassFromString(@"UIAlertController")) {
-        
-        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:message preferredStyle:UIAlertControllerStyleAlert];
-        
-        if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.3) {
-            
-            CGRect alertFrame = [UIScreen mainScreen].applicationFrame;
-            
-            if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]))
{
-                // swap the values for the app frame since it is now in landscape
-                CGFloat temp = alertFrame.size.width;
-                alertFrame.size.width = alertFrame.size.height;
-                alertFrame.size.height = temp;
-            }
-            
-            alertController.view.frame =  alertFrame;
-        }
 
-        __weak CDVNotification* weakNotif = self;
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
message:message preferredStyle:UIAlertControllerStyleAlert];
 
-        for (int n = 0; n < count; n++) {
-            [alertController addAction:[UIAlertAction actionWithTitle:[buttons objectAtIndex:n]
-                                                                style:UIAlertActionStyleDefault
-                                                              handler:^(UIAlertAction * action)
-            {
-                CDVPluginResult* result;
+    __weak CDVNotification* weakNotif = self;
 
-                if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT])
-                {
-                    NSString* value0 = [[alertController.textFields objectAtIndex:0] text];
-                    NSDictionary* info = @{
-                        @"buttonIndex":@(n + 1),
-                        @"input1":(value0 ? value0 : [NSNull null])
-                    };
-                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
-                }
-                else
-                {
-                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)(n
 + 1)];
-                }
+    for (int n = 0; n < count; n++) {
+        [alertController addAction:[UIAlertAction actionWithTitle:[buttons objectAtIndex:n]
+                                                            style:UIAlertActionStyleDefault
+                                                          handler:^(UIAlertAction * action)
+        {
+            CDVPluginResult* result;
 
-                [weakNotif.commandDelegate sendPluginResult:result callbackId:callbackId];
-            }]];
-        }
-        
-        if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) {
-            
-            [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField)
{
-                textField.text = defaultText;
-            }];
-        }
-        
-        if(!alertList)
-            alertList = [[NSMutableArray alloc] init];
-        [alertList addObject:alertController];
-        
-        if ([alertList count]==1) {
-            [self presentAlertcontroller];
-        }
-        
-    }
-    else
-    {
-#endif
+            if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT])
+            {
+                NSString* value0 = [[alertController.textFields objectAtIndex:0] text];
+                NSDictionary* info = @{
+                    @"buttonIndex":@(n + 1),
+                    @"input1":(value0 ? value0 : [NSNull null])
+                };
+                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
+            }
+            else
+            {
+                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)(n
 + 1)];
+            }
 
-        CDVAlertView* alertView = [[CDVAlertView alloc]
-                                   initWithTitle:title
-                                   message:message
-                                   delegate:self
-                                   cancelButtonTitle:nil
-                                   otherButtonTitles:nil];
-        
-        alertView.callbackId = callbackId;
-        
-        
-        
-        for (int n = 0; n < count; n++) {
-            [alertView addButtonWithTitle:[buttons objectAtIndex:n]];
-        }
+            [weakNotif.commandDelegate sendPluginResult:result callbackId:callbackId];
+        }]];
+    }
+    if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) {
         
-        if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) {
-            alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
-            UITextField* textField = [alertView textFieldAtIndex:0];
+        [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
             textField.text = defaultText;
-        }
-        
-        [alertView show];
-#ifdef __IPHONE_8_0
+        }];
+    }
+    if(!alertList)
+        alertList = [[NSMutableArray alloc] init];
+    [alertList addObject:alertController];

Review comment:
       added them, doesn't look off now, right?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



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


Mime
View raw message