瀏覽代碼

dev share

marinofaggiana 5 年之前
父節點
當前提交
e89877fe01
共有 3 個文件被更改,包括 51 次插入29 次删除
  1. 2 2
      iOSClient/Share/NCShare.storyboard
  2. 36 25
      iOSClient/Share/NCShare.swift
  3. 13 2
      iOSClient/Share/NCShareUserCell.xib

+ 2 - 2
iOSClient/Share/NCShare.storyboard

@@ -88,7 +88,7 @@
                                         <state key="normal" image="arrowRight"/>
                                     </button>
                                     <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="c94-b9-Sim">
-                                        <rect key="frame" x="0.0" y="120" width="404" height="488"/>
+                                        <rect key="frame" x="0.0" y="118" width="404" height="490"/>
                                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                     </tableView>
                                     <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="8Cj-cK-AKZ">
@@ -131,7 +131,7 @@
                                 <constraints>
                                     <constraint firstItem="f5j-bG-pbj" firstAttribute="centerY" secondItem="iSO-mc-0TB" secondAttribute="centerY" id="8Aa-Tz-QVA"/>
                                     <constraint firstAttribute="trailing" secondItem="c94-b9-Sim" secondAttribute="trailing" id="BtN-cJ-TTc"/>
-                                    <constraint firstItem="c94-b9-Sim" firstAttribute="top" secondItem="iSO-mc-0TB" secondAttribute="bottom" constant="70" id="Co6-l6-HiT"/>
+                                    <constraint firstItem="c94-b9-Sim" firstAttribute="top" secondItem="iSO-mc-0TB" secondAttribute="bottom" constant="68" id="Co6-l6-HiT"/>
                                     <constraint firstItem="f5j-bG-pbj" firstAttribute="leading" secondItem="iSO-mc-0TB" secondAttribute="trailing" constant="10" id="GBQ-j9-3mM"/>
                                     <constraint firstItem="SQW-aQ-ydN" firstAttribute="centerY" secondItem="8Cj-cK-AKZ" secondAttribute="centerY" id="LtS-8d-L7a"/>
                                     <constraint firstItem="Qek-aQ-NjE" firstAttribute="centerY" secondItem="8Cj-cK-AKZ" secondAttribute="centerY" id="NYZ-hc-SBk"/>

+ 36 - 25
iOSClient/Share/NCShare.swift

@@ -307,6 +307,10 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         NCShareCommon.sharedInstance.copyLink(tableShare: tableShare, viewController: self)
     }
     
+    func switchCanEdit(with tableShare: tableShare?, switch: Bool, sender: Any) {
+        print("x")
+    }
+    
     func tapMenu(with tableShare: tableShare?, sender: Any) {
         let views = NCShareCommon.sharedInstance.openViewMenuShareLink(view: self.view, tableShare: tableShare, metadata: metadata!)
         shareLinkMenuView = views.shareLinkMenuView
@@ -384,6 +388,7 @@ extension NCShare: UITableViewDataSource {
                 cell.tableShare = tableShare
                 cell.delegate = self
                 cell.labelTitle.text = tableShare.shareWith
+                NCShareCommon.sharedInstance.downloadAvatar(user: tableShare.shareWith, cell: cell)
                 return cell
             }
         }
@@ -446,9 +451,15 @@ class NCShareUserCell: UITableViewCell {
         labelCanEdit.text = NSLocalizedString("_share_permission_edit_", comment: "")
         buttonMenu.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "shareMenu"), width:100, height: 100, color: UIColor.gray), for: .normal)
     }
+    
+    // Can edit
+    @IBAction func switchCanEditChanged(sender: UISwitch) {
+        delegate?.switchCanEdit(with: tableShare, switch: sender.isOn, sender: sender)
+    }
 }
 
 protocol NCShareUserCellDelegate {
+    func switchCanEdit(with tableShare: tableShare?, switch: Bool, sender: Any)
 }
 
 // MARK: - ShareLinkMenuView
@@ -755,6 +766,31 @@ class NCShareCommon: NSObject {
         return image
     }
     
+    func downloadAvatar(user: String, cell: NCShareUserCell) {
+        
+        let appDelegate = UIApplication.shared.delegate as! AppDelegate
+        let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.activeUser, activeUrl: appDelegate.activeUrl) + "-" + user + ".png"
+        
+        if FileManager.default.fileExists(atPath: fileNameLocalPath) {
+            if let image = UIImage(contentsOfFile: fileNameLocalPath) {
+                cell.imageItem.image = image
+            }
+        } else {
+            DispatchQueue.global().async {
+                let url = appDelegate.activeUrl + k_avatar + user + "/128"
+                let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
+                OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
+                    if errorCode == 0 {
+                        do {
+                            try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
+                        } catch { return }
+                        cell.imageItem.image = UIImage(data: data!)
+                    }
+                })
+            }
+        }
+    }
+    
     func openViewMenuShareLink(view: UIView, tableShare: tableShare?, metadata: tableMetadata) -> (shareLinkMenuView: NCShareLinkMenuView, viewWindow: UIView) {
         
         let globalPoint = view.superview?.convert(view.frame.origin, to: nil)
@@ -834,31 +870,6 @@ class NCShareCommon: NSObject {
             viewController.present(activityVC, animated: true, completion: nil)
         }
     }
-    
-    func downloadAvatar(user: String) -> UIImage? {
-        
-        let appDelegate = UIApplication.shared.delegate as! AppDelegate
-        let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.activeUser, activeUrl: appDelegate.activeUrl) + "-" + user + ".png"
-        
-        if FileManager.default.fileExists(atPath: fileNameLocalPath) {
-            return UIImage(contentsOfFile: fileNameLocalPath)
-        } else {
-            DispatchQueue.global().async {
-                let url = appDelegate.activeUrl + k_avatar + user + "/128"
-                let encodedString = url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
-                OCNetworking.sharedManager()?.downloadContents(ofUrl: encodedString, completion: { (data, message, errorCode) in
-                    if errorCode == 0 {
-                        do {
-                            try data!.write(to: NSURL(fileURLWithPath: fileNameLocalPath) as URL, options: .atomic)
-                        } catch { return }
-                        //cell.avatar.image = UIImage(data: data!)
-                    }
-                })
-            }
-        }
-        
-        return nil
-    }
 }
 
 // --------------------------------------------------------------------------------------------

+ 13 - 2
iOSClient/Share/NCShareUserCell.xib

@@ -18,12 +18,20 @@
                 <rect key="frame" x="0.0" y="0.0" width="600" height="89.5"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" image="circle" translatesAutoresizingMaskIntoConstraints="NO" id="qDs-UG-Mn7" userLabel="ImageItem">
+                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="qDs-UG-Mn7" userLabel="ImageItem" customClass="NCAvatar" customModule="Nextcloud" customModuleProvider="target">
                         <rect key="frame" x="5" y="25" width="40" height="40"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="40" id="8et-YH-T1D"/>
                             <constraint firstAttribute="width" constant="40" id="GNY-Va-SIJ"/>
                         </constraints>
+                        <userDefinedRuntimeAttributes>
+                            <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                <integer key="value" value="1"/>
+                            </userDefinedRuntimeAttribute>
+                            <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                <color key="value" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                            </userDefinedRuntimeAttribute>
+                        </userDefinedRuntimeAttributes>
                     </imageView>
                     <label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="shareWith" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="otH-mT-7Z4" userLabel="labelTitle">
                         <rect key="frame" x="55" y="36" width="150" height="18"/>
@@ -41,6 +49,9 @@
                             <constraint firstAttribute="height" constant="31" id="Yxu-hy-A7m"/>
                             <constraint firstAttribute="width" constant="47" id="jeg-tb-g7e"/>
                         </constraints>
+                        <connections>
+                            <action selector="switchCanEditChangedWithSender:" destination="qJF-Yc-gKE" eventType="valueChanged" id="0c2-af-6CQ"/>
+                        </connections>
                     </switch>
                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Can edit" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QXZ-ax-nlQ">
                         <rect key="frame" x="475" y="34.5" width="80" height="21"/>
@@ -85,7 +96,7 @@
         </tableViewCell>
     </objects>
     <resources>
-        <image name="circle" width="329" height="329"/>
+        <image name="avatar" width="25" height="25"/>
         <image name="shareMenu" width="329" height="329"/>
     </resources>
 </document>