Browse Source

Fix share permission UI/UX

- add cancel warning
- rm back button (in favour of cancel)
- automatic row height (for `noteCell`)
- rm `sharingNote` for cleaner UI

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 năm trước cách đây
mục cha
commit
573dd731ba

+ 19 - 2
iOSClient/Share/Advanced/NCShareAdvancePermission.swift

@@ -28,13 +28,25 @@ import CloudKit
 
 class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDelegate, NCShareDetail {
     func dismissShareAdvanceView(shouldSave: Bool) {
-        defer { navigationController?.popViewController(animated: true) }
-        guard shouldSave else { return }
+        guard shouldSave else {
+            let alert = UIAlertController(
+                title: NSLocalizedString("_cancel_request_", comment: ""),
+                message: NSLocalizedString("_discard_changes_info_", comment: ""),
+                preferredStyle: .alert)
+            alert.addAction(UIAlertAction(
+                title: NSLocalizedString("_discard_changes_", comment: ""),
+                style: .destructive,
+                handler: { _ in self.navigationController?.popViewController(animated: true) }))
+            alert.addAction(UIAlertAction(title: NSLocalizedString("_continue_editing_", comment: ""), style: .default))
+            self.present(alert, animated: true)
+            return
+        }
         if isNewShare {
             networking?.createShare(option: share)
         } else {
             networking?.updateShare(option: share)
         }
+        navigationController?.popViewController(animated: true)
     }
 
     var share: NCTableShareable!
@@ -46,7 +58,11 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg
     override func viewDidLoad() {
         super.viewDidLoad()
         self.shareConfig = NCShareConfig(parentMetadata: metadata, share: share)
+
+        tableView.estimatedRowHeight = tableView.rowHeight
+        tableView.rowHeight = UITableView.automaticDimension
         self.setNavigationTitle()
+        self.navigationItem.hidesBackButton = true
         if #available(iOS 13.0, *) {
             // disbale pull to dimiss
             isModalInPresentation = true
@@ -115,6 +131,7 @@ class NCShareAdvancePermission: UITableViewController, NCShareAdvanceFotterDeleg
             noteCell.detailTextLabel?.text = NSLocalizedString("_share_reshare_restricted_", comment: "")
             noteCell.detailTextLabel?.isEnabled = false
             noteCell.isUserInteractionEnabled = false
+            noteCell.detailTextLabel?.numberOfLines = 0
             return noteCell
         }
         if let cell = cell as? NCShareDateCell { cell.onReload = tableView.reloadData }

+ 2 - 4
iOSClient/Share/Advanced/NCShareNewUserAddComment.swift

@@ -29,7 +29,6 @@ class NCShareNewUserAddComment: UIViewController, NCShareDetail {
 
     @IBOutlet weak var headerContainerView: UIView!
     @IBOutlet weak var sharingLabel: UILabel!
-    @IBOutlet weak var sharingNote: UILabel!
     @IBOutlet weak var noteTextField: UITextView!
 
     let contentInsets: CGFloat = 16
@@ -45,8 +44,7 @@ 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)
 
-        sharingLabel.text = NSLocalizedString("_sharing_", comment: "")
-        sharingNote.text = NSLocalizedString("_share_note_recipient_", comment: "")
+        sharingLabel.text = NSLocalizedString("_share_note_recipient_", comment: "")
 
         noteTextField.textContainerInset = UIEdgeInsets(top: contentInsets, left: contentInsets, bottom: contentInsets, right: contentInsets)
         noteTextField.text = share.note
@@ -60,7 +58,7 @@ 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

+ 2 - 11
iOSClient/Share/NCShare.storyboard

@@ -180,14 +180,8 @@
                                             <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="YMG-hf-HEX">
                                                 <rect key="frame" x="0.0" y="200" width="414" height="536"/>
                                                 <subviews>
-                                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="_share_note_recipient_" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3yF-lL-GwU">
-                                                        <rect key="frame" x="16" y="56.333333333333314" width="161.66666666666666" height="18"/>
-                                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
-                                                        <color key="textColor" red="0.59999999999999998" green="0.59999999999999998" blue="0.59999999999999998" alpha="1" colorSpace="calibratedRGB"/>
-                                                        <nil key="highlightedColor"/>
-                                                    </label>
                                                     <textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" canCancelContentTouches="NO" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="VT0-1l-5HI">
-                                                        <rect key="frame" x="16" y="106.33333333333329" width="382" height="377.66666666666674"/>
+                                                        <rect key="frame" x="16" y="60.333333333333286" width="382" height="423.66666666666674"/>
                                                         <color key="backgroundColor" systemColor="secondarySystemBackgroundColor"/>
                                                         <constraints>
                                                             <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="100" id="wqE-G9-M95"/>
@@ -214,15 +208,13 @@
                                                 </subviews>
                                                 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                                 <constraints>
-                                                    <constraint firstItem="3yF-lL-GwU" firstAttribute="leading" secondItem="YMG-hf-HEX" secondAttribute="leading" constant="16" id="3yQ-Gl-Co9"/>
                                                     <constraint firstItem="vkm-Pe-6qd" firstAttribute="leading" secondItem="YMG-hf-HEX" secondAttribute="leading" constant="16" id="Auk-mC-Mie"/>
-                                                    <constraint firstItem="VT0-1l-5HI" firstAttribute="top" secondItem="3yF-lL-GwU" secondAttribute="bottom" constant="31.999999999999972" id="EpF-os-G1u"/>
                                                     <constraint firstAttribute="bottom" secondItem="VT0-1l-5HI" secondAttribute="bottom" priority="100" constant="52" id="FYk-Lv-5f6"/>
                                                     <constraint firstItem="vkm-Pe-6qd" firstAttribute="top" secondItem="YMG-hf-HEX" secondAttribute="top" constant="24" id="L0w-Cz-uK2"/>
                                                     <constraint firstAttribute="trailing" secondItem="VT0-1l-5HI" secondAttribute="trailing" constant="16" id="TgX-1J-iTO"/>
                                                     <constraint firstItem="VT0-1l-5HI" firstAttribute="leading" secondItem="YMG-hf-HEX" secondAttribute="leading" constant="16" id="gEq-qv-UTR"/>
+                                                    <constraint firstItem="VT0-1l-5HI" firstAttribute="top" secondItem="vkm-Pe-6qd" secondAttribute="bottom" constant="16" id="ghe-aR-N1L"/>
                                                     <constraint firstAttribute="height" constant="536" id="oYk-ib-hVx"/>
-                                                    <constraint firstItem="3yF-lL-GwU" firstAttribute="top" secondItem="vkm-Pe-6qd" secondAttribute="bottom" constant="12" id="qtk-si-To3"/>
                                                 </constraints>
                                             </view>
                                         </subviews>
@@ -254,7 +246,6 @@
                         <outlet property="headerContainerView" destination="qVy-Qr-W7j" id="LaE-WS-v1X"/>
                         <outlet property="noteTextField" destination="VT0-1l-5HI" id="Ilz-T9-5BL"/>
                         <outlet property="sharingLabel" destination="vkm-Pe-6qd" id="NVy-Ug-ipx"/>
-                        <outlet property="sharingNote" destination="3yF-lL-GwU" id="2Ur-N2-Jto"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="LJ3-hs-98b" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>

+ 3 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -22,6 +22,7 @@
 
 "_cancel_"                  = "Cancel";
 "_tap_to_cancel_"           = "Tap to cancel";
+"_cancel_request_"          = "Do you want to cancel?";
 "_upload_file_"             = "Upload file";
 "_accessibility_add_upload_" = "Add and upload";
 "_download_file_"           = "Download file";
@@ -82,6 +83,7 @@
 "_remove_"                  = "Remove";
 "_file_not_found_"          = "File not found";
 "_continue_"                = "Continue";
+"_continue_editing_"        = "Continue editing";
 "_continue_request_"        = "Do you want to continue?";
 "_auto_upload_folder_"      = "Auto upload";
 "_gallery_"                 = "Gallery";
@@ -809,6 +811,7 @@
 "_save_as_copy_"            = "Save as copy";
 "_discard_changes_"         = "Close and discard changes";
 "_message_disable_overwrite_livephoto_" = "This image is a Live Photo, overwrite will not be possible";
+"_discard_changes_info_"    = "Your changes will be discarded.";
 "_delete_files_desc_"       = "Delete files to free up space";
 "_delete_old_files_"        = "Delete all files older than";
 "_never_"                   = "Never";