Jelajahi Sumber

new view share

marinofaggiana 5 tahun lalu
induk
melakukan
13d07f50dd
2 mengubah file dengan 19 tambahan dan 6 penghapusan
  1. 16 6
      iOSClient/Share/NCShare.swift
  2. 3 0
      iOSClient/Share/NCShareLinkMenuView.xib

+ 16 - 6
iOSClient/Share/NCShare.swift

@@ -291,7 +291,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
     }
     
     func tapMenu(with tableShare: tableShare?, sender: Any) {
-        NCShareCommon.sharedInstance.openViewMenuShareLink(view: self.view, height: height, tableShare: tableShare)
+        NCShareCommon.sharedInstance.openViewMenuShareLink(view: self.view, height: height, tableShare: tableShare, metadata: metadata!)
     }
     
     func reloadData() {
@@ -459,7 +459,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
     }
     
     func loadData(idRemoteShared: Int) {
-        self.tableShare = NCManageDatabase.sharedInstance.getTableShare(account: metadata!.account, idRemoteShared: idRemoteShared)
+        tableShare = NCManageDatabase.sharedInstance.getTableShare(account: metadata!.account, idRemoteShared: idRemoteShared)
         
         // Allow editing
         if tableShare != nil && tableShare!.permissions > 1 {
@@ -511,6 +511,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
     @IBAction func switchAllowEditingChanged(sender: UISwitch) {
         
         guard let tableShare = self.tableShare else { return }
+        
         var permission = 0
         if sender.isOn {
             permission = 3
@@ -522,9 +523,17 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: permission, expirationTime: nil, hideDownload: tableShare.hideDownload)
     }
     
+    @IBAction func switchHideDownloadChanged(sender: UISwitch) {
+        
+        guard let tableShare = self.tableShare else { return }
+        
+        let networking = NCShareNetworking.init(account: metadata!.account, activeUrl: appDelegate.activeUrl,  view: self, delegate: self)
+        networking.updateShare(idRemoteShared: tableShare.idRemoteShared, password: nil, permission: 0, expirationTime: nil, hideDownload: sender.isOn)
+    }
+    
     // delegate networking
     
-    func readShareCompleted(account: String, errorCode: Int) {
+    func readShareCompleted() {
         loadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
     }
     
@@ -566,7 +575,7 @@ class NCShareCommon: NSObject {
         return image
     }
     
-    func openViewMenuShareLink(view: UIView, height: CGFloat, tableShare: tableShare?) {
+    func openViewMenuShareLink(view: UIView, height: CGFloat, tableShare: tableShare?, metadata: tableMetadata) {
         
         let globalPoint = view.superview?.convert(view.frame.origin, to: nil)
         
@@ -576,6 +585,7 @@ class NCShareCommon: NSObject {
         
         let shareLinkMenuView = Bundle.main.loadNibNamed("NCShareLinkMenuView", owner: self, options: nil)?.first as? NCShareLinkMenuView
         shareLinkMenuView?.addTap(view: viewWindow)
+        shareLinkMenuView?.metadata = metadata
         shareLinkMenuView?.loadData(idRemoteShared: tableShare?.idRemoteShared ?? 0)
         let shareLinkMenuViewX = view.bounds.width - (shareLinkMenuView?.frame.width)! - 40 + globalPoint!.x
         var shareLinkMenuViewY = height + 10 + globalPoint!.y
@@ -642,7 +652,7 @@ class NCShareNetworking: NSObject {
             } else {
                 self.appDelegate.messageNotification("_share_", description: message, visible: true, delay: TimeInterval(k_dismissAfterSecond), type: TWMessageBarMessageType.error, errorCode: errorCode)
             }
-            self.delegate?.readShareCompleted(account: account!, errorCode: errorCode)
+            self.delegate?.readShareCompleted()
         })
     }
     
@@ -687,7 +697,7 @@ class NCShareNetworking: NSObject {
 }
 
 protocol NCShareNetworkingDelegate {
-    func readShareCompleted(account: String, errorCode: Int)
+    func readShareCompleted()
     func shareCompleted(metadata: tableMetadata, errorCode: Int)
     func unShareCompleted(account: String, idRemoteShared: Int, errorCode: Int)
     func updateShareError(idRemoteShared: Int)

+ 3 - 0
iOSClient/Share/NCShareLinkMenuView.xib

@@ -32,6 +32,9 @@
                 </label>
                 <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="UIn-eq-hkP">
                     <rect key="frame" x="10" y="61" width="51" height="31"/>
+                    <connections>
+                        <action selector="switchHideDownloadChangedWithSender:" destination="iN0-l3-epB" eventType="valueChanged" id="ZUj-2h-gQC"/>
+                    </connections>
                 </switch>
                 <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Hide download" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="KXo-cP-gkc">
                     <rect key="frame" x="69" y="69" width="241" height="15"/>