Selaa lähdekoodia

rename new view

marinofaggiana 4 vuotta sitten
vanhempi
commit
6d6962b019
1 muutettua tiedostoa jossa 14 lisäystä ja 5 poistoa
  1. 14 5
      iOSClient/Main/Rename file/NCRenameFile.swift

+ 14 - 5
iOSClient/Main/Rename file/NCRenameFile.swift

@@ -9,7 +9,7 @@
 import Foundation
 import NCCommunication
 
-class NCRenameFile: UIViewController {
+class NCRenameFile: UIViewController, UITextFieldDelegate {
 
     @IBOutlet weak var titleLabel: UILabel!
     @IBOutlet weak var separatorHeightContraint: NSLayoutConstraint!
@@ -30,8 +30,15 @@ class NCRenameFile: UIViewController {
         
         if let metadata = self.metadata {
                 
+            titleLabel.text = NSLocalizedString("_rename_file_", comment: "")
+            separatorHeightContraint.constant = 0.3
+            
             fileNameWithoutExt.text = metadata.fileNameWithoutExt
+            fileNameWithoutExt.delegate = self
+            fileNameWithoutExt.becomeFirstResponder()
+            
             ext.text = metadata.ext
+            ext.delegate = self
 
             if metadata.directory {
                 
@@ -57,14 +64,11 @@ class NCRenameFile: UIViewController {
             }
         }
                 
-        titleLabel.text = NSLocalizedString("_rename_file_", comment: "")
-        separatorHeightContraint.constant = 0.3
-        
         cancelButton.setTitle(NSLocalizedString("_cancel_", comment: ""), for: .normal)
         cancelButton.setTitleColor(.gray, for: .normal)
         cancelButton.layer.cornerRadius = 15
         cancelButton.layer.masksToBounds = true
-        cancelButton.layer.backgroundColor =  NCBrandColor.shared.graySoft.withAlphaComponent(0.3).cgColor
+        cancelButton.layer.backgroundColor =  NCBrandColor.shared.graySoft.withAlphaComponent(0.2).cgColor
         cancelButton.layer.borderWidth = 0.3
         cancelButton.layer.borderColor = UIColor.gray.cgColor
         
@@ -83,6 +87,11 @@ class NCRenameFile: UIViewController {
         }
     }
     
+    func textFieldShouldReturn(_ textField: UITextField) -> Bool {
+        textField.resignFirstResponder()
+        return true
+    }
+    
     // MARK: - Action
     
     @IBAction func cancel(_ sender: Any) {