Browse Source

Optimize `UIAlertController.password` + small fixes

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 2 years ago
parent
commit
79c0a219dd

+ 2 - 2
iOSClient/Extensions/UIAlertController+Extension.swift

@@ -81,8 +81,8 @@ extension UIAlertController {
         return alertController
     }
 
-    static func sharePassword(completion: @escaping (String?) -> Void) -> UIAlertController {
-        return .withTextField(titleKey: "_enforce_password_protection_", textFieldConfiguration: { textField in
+    static func password(titleKey: String, completion: @escaping (String?) -> Void) -> UIAlertController {
+        return .withTextField(titleKey: titleKey, textFieldConfiguration: { textField in
             textField.isSecureTextEntry = true
             textField.placeholder = NSLocalizedString("_password_", comment: "")
         }, completion: completion)

+ 1 - 1
iOSClient/Extensions/UIToolbar+Extension.swift

@@ -21,7 +21,7 @@
 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 //
 
-import Foundation
+import UIKit
 
 extension UIToolbar {
     static func toolbar(onClear: (() -> Void)?, completion: @escaping () -> Void) -> UIToolbar {

+ 1 - 4
iOSClient/Share/Advanced/NCShareAdvancePermission.swift

@@ -141,10 +141,7 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg
                 tableView.reloadData()
                 return
             }
-            let alertController = UIAlertController.withTextField(titleKey: "_share_password_") { textField in
-                textField.placeholder = NSLocalizedString("_password_", comment: "")
-                textField.isSecureTextEntry = true
-            } completion: { password in
+            let alertController = UIAlertController.password(titleKey: "_share_password_") { password in
                 self.share.password = password ?? ""
                 tableView.reloadData()
             }

+ 1 - 1
iOSClient/Share/Advanced/NCShareCells.swift

@@ -255,7 +255,7 @@ class NCShareToggleCell: UITableViewCell {
     }
 }
 
-open class NCShareDateCell: UITableViewCell {
+class NCShareDateCell: UITableViewCell {
     let picker = UIDatePicker()
     let textField = UITextField()
 

+ 11 - 11
iOSClient/Share/Advanced/NCShareNewUserAddComment.swift

@@ -45,17 +45,6 @@ class NCShareNewUserAddComment: UIViewController, NCShareDetail {
         NotificationCenter.default.addObserver(self, selector: #selector(adjustForKeyboard), name: UIResponder.keyboardWillHideNotification, object: nil)
         NotificationCenter.default.addObserver(self, selector: #selector(adjustForKeyboard), name: UIResponder.keyboardWillChangeFrameNotification, object: nil)
 
-        guard let headerView = (Bundle.main.loadNibNamed("NCShareAdvancePermissionHeader", owner: self, options: nil)?.first as? NCShareAdvancePermissionHeader) else { return }
-        headerContainerView.addSubview(headerView)
-        headerView.frame = headerContainerView.frame
-        headerView.translatesAutoresizingMaskIntoConstraints = false
-        headerView.topAnchor.constraint(equalTo: headerContainerView.topAnchor).isActive = true
-        headerView.bottomAnchor.constraint(equalTo: headerContainerView.bottomAnchor).isActive = true
-        headerView.leftAnchor.constraint(equalTo: headerContainerView.leftAnchor).isActive = true
-        headerView.rightAnchor.constraint(equalTo: headerContainerView.rightAnchor).isActive = true
-
-        headerView.setupUI(with: metadata)
-
         sharingLabel.text = NSLocalizedString("_sharing_", comment: "")
         sharingNote.text = NSLocalizedString("_share_note_recipient_", comment: "")
 
@@ -71,6 +60,17 @@ class NCShareNewUserAddComment: UIViewController, NCShareDetail {
         }
 
         noteTextField.inputAccessoryView = toolbar
+        
+        guard let headerView = (Bundle.main.loadNibNamed("NCShareAdvancePermissionHeader", owner: self, options: nil)?.first as? NCShareAdvancePermissionHeader) else { return }
+        headerContainerView.addSubview(headerView)
+        headerView.frame = headerContainerView.frame
+        headerView.translatesAutoresizingMaskIntoConstraints = false
+        headerView.topAnchor.constraint(equalTo: headerContainerView.topAnchor).isActive = true
+        headerView.bottomAnchor.constraint(equalTo: headerContainerView.bottomAnchor).isActive = true
+        headerView.leftAnchor.constraint(equalTo: headerContainerView.leftAnchor).isActive = true
+        headerView.rightAnchor.constraint(equalTo: headerContainerView.rightAnchor).isActive = true
+
+        headerView.setupUI(with: metadata)
     }
 
     override func viewWillDisappear(_ animated: Bool) {

+ 1 - 1
iOSClient/Share/NCShare.swift

@@ -201,7 +201,7 @@ class NCShare: UIViewController, NCShareNetworkingDelegate, NCSharePagingContent
               shareType == NCShareCommon.shared.SHARE_TYPE_LINK || shareType == NCShareCommon.shared.SHARE_TYPE_EMAIL
         else { return completion(nil) }
 
-        self.present(UIAlertController.sharePassword(completion: completion), animated: true)
+        self.present(UIAlertController.password(titleKey: "_enforce_password_protection_", completion: completion), animated: true)
     }
 
     // MARK: - NCShareNetworkingDelegate