소스 검색

improv. rename

Marino Faggiana 8 년 전
부모
커밋
9fba108071
1개의 변경된 파일36개의 추가작업 그리고 0개의 파일을 삭제
  1. 36 0
      iOSClient/Main/CCMain.m

+ 36 - 0
iOSClient/Main/CCMain.m

@@ -512,6 +512,18 @@
     return ([[[alertView textFieldAtIndex:0] text] length]>0)?YES:NO;
 }
 
+- (void)alertTextFieldDidChange:(UITextField *)sender
+{
+    UIAlertController *alertController = (UIAlertController *)self.presentedViewController;
+    
+    if (alertController)
+    {
+        UITextField *fileName = alertController.textFields.firstObject;
+        UIAlertAction *okAction = alertController.actions.lastObject;
+        okAction.enabled = fileName.text.length > 0;
+    }
+}
+
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Graphic Window =====
 #pragma --------------------------------------------------------------------------------------------
@@ -4271,6 +4283,7 @@
                                         // close swipe
                                         [self setEditing:NO animated:YES];
                                         
+                                        /*
                                         //chiediamo il nome del file
                                         UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"_rename_",nil) message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"_cancel_",nil) otherButtonTitles:NSLocalizedString(@"_save_", nil), nil];
                                         [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput];
@@ -4278,6 +4291,29 @@
                                         UITextField *textField = [alertView textFieldAtIndex:0];
                                         textField.text = _metadata.fileNamePrint;
                                         [alertView show];
+                                        */
+                                        
+                                        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"_rename_",nil) message:nil preferredStyle:UIAlertControllerStyleAlert];
+                                        
+                                        [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
+                                             textField.placeholder = _metadata.fileNamePrint;
+                                        }];
+                                        
+                                        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_cancel_",nil) style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
+                                            NSLog(@"Cancel action");
+                                        }];
+                                        
+                                        UIAlertAction *okAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"_ok_", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
+                                            
+                                            UITextField *fileName = alertController.textFields.firstObject;
+                                            
+                                            [self renameFile:_metadata fileName:fileName.text];
+                                        }];
+                                        
+                                        okAction.enabled = NO;
+
+                                        [alertController addAction:cancelAction];
+                                        [alertController addAction:okAction];
                                     }];
         }