Browse Source

view share

marinofaggiana 5 years ago
parent
commit
fc21fb807d
2 changed files with 24 additions and 2 deletions
  1. 18 2
      iOSClient/Share/NCShare.swift
  2. 6 0
      iOSClient/Share/NCShareLinkMenuView.xib

+ 18 - 2
iOSClient/Share/NCShare.swift

@@ -454,7 +454,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
 
     public let width: CGFloat = 250
-    public let height: CGFloat = 470
+    public let height: CGFloat = 440
     private var tableShare: tableShare?
     public var metadata: tableMetadata?
     
@@ -546,6 +546,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         }
     }
     
+    // Allow editing
     @IBAction func switchAllowEditingChanged(sender: UISwitch) {
         
         guard let tableShare = self.tableShare else { return }
@@ -561,6 +562,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
+    // Hide download
     @IBAction func switchHideDownloadChanged(sender: UISwitch) {
         
         guard let tableShare = self.tableShare else { return }
@@ -569,14 +571,16 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: nil, expirationTime: nil, hideDownload: sender.isOn)
     }
     
+    // Password protect
     @IBAction func switchPasswordProtectChanged(sender: UISwitch) {
         
         guard let tableShare = self.tableShare else { return }
         
         if sender.isOn {
             fieldPasswordProtect.isEnabled = true
-            fieldPasswordProtect.text = tableShare.shareWith
+            fieldPasswordProtect.text = ""
             buttonSendPasswordProtect.isEnabled = true
+            fieldPasswordProtect.becomeFirstResponder()
         } else {
             let networking = NCShareNetworking.init(account: metadata!.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
             networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: "", permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
@@ -594,6 +598,11 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: fieldPasswordProtect.text, permission: 0, note: nil, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
+    @IBAction func fieldPasswordProtectDidEndOnExit(textField: UITextField) {
+        buttonSendPasswordProtect(sender: UIButton())
+    }
+    
+    // Set expiration date
     @IBAction func switchSetExpirationDate(sender: UISwitch) {
         
         guard let tableShare = self.tableShare else { return }
@@ -614,6 +623,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         viewWindowCalendar = calendar.viewWindow
     }
     
+    // Note to recipient
     @IBAction func buttonSendNoteToRecipient(sender: UIButton) {
         
         fieldNoteToRecipient.endEditing(true)
@@ -625,6 +635,11 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, note: fieldNoteToRecipient.text, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
+    @IBAction func fieldNoteToRecipientDidEndOnExit(textField: UITextField) {
+        buttonSendNoteToRecipient(sender: UIButton())
+    }
+    
+    // Delete share link
     @IBAction func buttonDeleteShareLink(sender: UIButton) {
         
         guard let tableShare = self.tableShare else { return }
@@ -633,6 +648,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         networking.unShare(idRemoteShared: tableShare.idRemoteShared)
     }
     
+    // Add another link
     @IBAction func buttonAddAnotherLink(sender: UIButton) {
         
         let networking = NCShareNetworking.init(account: metadata!.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)

+ 6 - 0
iOSClient/Share/NCShareLinkMenuView.xib

@@ -79,6 +79,9 @@
                     <nil key="textColor"/>
                     <fontDescription key="fontDescription" type="system" pointSize="13"/>
                     <textInputTraits key="textInputTraits" secureTextEntry="YES" textContentType="password"/>
+                    <connections>
+                        <action selector="fieldPasswordProtectDidEndOnExitWithTextField:" destination="iN0-l3-epB" eventType="editingDidEndOnExit" id="2PO-wf-bHs"/>
+                    </connections>
                 </textField>
                 <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="dB8-1M-WZr">
                     <rect key="frame" x="10" y="195" width="51" height="31"/>
@@ -139,6 +142,9 @@
                     <nil key="textColor"/>
                     <fontDescription key="fontDescription" type="system" pointSize="14"/>
                     <textInputTraits key="textInputTraits"/>
+                    <connections>
+                        <action selector="fieldNoteToRecipientDidEndOnExitWithTextField:" destination="iN0-l3-epB" eventType="editingDidEndOnExit" id="Z9v-qs-dp4"/>
+                    </connections>
                 </textField>
                 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="trash" translatesAutoresizingMaskIntoConstraints="NO" id="hr8-Qe-xD0" userLabel="Image Delete Share Link">
                     <rect key="frame" x="13" y="358" width="25" height="25"/>