marinofaggiana 5 жил өмнө
parent
commit
46ec9a0852

+ 12 - 4
iOSClient/Share/NCShare.swift

@@ -172,8 +172,16 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         
         guard let items = items else { return }
         
-        let appearance = DropDown.appearance()
         let dropDown = DropDown()
+        let appearance = DropDown.appearance()
+        
+        appearance.backgroundColor = .white
+        appearance.cornerRadius = 10
+        appearance.shadowColor = UIColor(white: 0.6, alpha: 1)
+        appearance.shadowOpacity = 0.9
+        appearance.shadowRadius = 25
+        appearance.animationduration = 0.25
+        appearance.textColor = .darkGray
         
         if #available(iOS 11.0, *) {
             appearance.setupMaskedCorners([.layerMaxXMaxYCorner, .layerMinXMaxYCorner])
@@ -181,12 +189,12 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         
         dropDown.dataSource = items.map {$0.name}
         dropDown.anchorView = searchField
-        dropDown.bottomOffset = CGPoint(x: 0, y: searchField.bounds.height)
+        dropDown.bottomOffset = CGPoint(x: 0, y: searchField.bounds.height + 2)
         
         dropDown.cellNib = UINib(nibName: "NCShareUserDropDownCell", bundle: nil)
         dropDown.customCellConfiguration = { (index: Index, item: String, cell: DropDownCell) -> Void in
             guard let cell = cell as? NCShareUserDropDownCell else { return }
-            //cell.displayName.text = item
+            NCShareCommon.sharedInstance.downloadAvatar(user: item, cell: cell)
         }
         
         dropDown.selectionAction = { [weak self] (index, item) in
@@ -332,5 +340,5 @@ protocol NCShareUserCellDelegate {
 
 class NCShareUserDropDownCell: DropDownCell {
     
-    @IBOutlet weak var logoImageView: UIImageView!
+    @IBOutlet weak var imageItem: UIImageView!
 }

+ 25 - 0
iOSClient/Share/NCShareCommon.swift

@@ -22,6 +22,7 @@
 
 import Foundation
 import FSCalendar
+import DropDown
 
 class NCShareCommon: NSObject {
     @objc static let sharedInstance: NCShareCommon = {
@@ -69,6 +70,30 @@ class NCShareCommon: NSObject {
         }
     }
     
+    func downloadAvatar(user: String, cell: NCShareUserDropDownCell) {
+        
+        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)

+ 22 - 10
iOSClient/Share/NCShareUserDropDownCell.xib

@@ -12,14 +12,26 @@
         <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
         <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="NCShareUserDropDownCell" customModule="Nextcloud" customModuleProvider="target">
-            <rect key="frame" x="0.0" y="0.0" width="210" height="40"/>
+            <rect key="frame" x="0.0" y="0.0" width="359" height="50"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
-                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="logo_0" translatesAutoresizingMaskIntoConstraints="NO" id="wwI-k5-kbU">
-                    <rect key="frame" x="8" y="12" width="16" height="16"/>
+                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="wwI-k5-kbU" customClass="NCAvatar" customModule="Nextcloud" customModuleProvider="target">
+                    <rect key="frame" x="10" y="10" width="30" height="30"/>
+                    <constraints>
+                        <constraint firstAttribute="width" constant="30" id="BIA-ab-frd"/>
+                        <constraint firstAttribute="height" constant="30" id="Umd-E3-3hN"/>
+                    </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" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="optionLabel" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VIB-Xt-ckX">
-                    <rect key="frame" x="32" y="9" width="90" height="21"/>
+                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Name" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VIB-Xt-ckX">
+                    <rect key="frame" x="50" y="9" width="45" height="31"/>
                     <fontDescription key="fontDescription" type="system" pointSize="17"/>
                     <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                     <nil key="highlightedColor"/>
@@ -29,21 +41,21 @@
             <constraints>
                 <constraint firstAttribute="bottom" secondItem="VIB-Xt-ckX" secondAttribute="bottom" constant="10" id="0zj-tF-bzC"/>
                 <constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="VIB-Xt-ckX" secondAttribute="trailing" constant="8" id="OSg-Aj-BFF"/>
-                <constraint firstItem="VIB-Xt-ckX" firstAttribute="leading" secondItem="wwI-k5-kbU" secondAttribute="trailing" constant="8" id="aUx-ZS-D4Q"/>
+                <constraint firstItem="VIB-Xt-ckX" firstAttribute="leading" secondItem="wwI-k5-kbU" secondAttribute="trailing" constant="10" id="aUx-ZS-D4Q"/>
                 <constraint firstItem="VIB-Xt-ckX" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" constant="9" id="fWz-fu-Ghl"/>
                 <constraint firstItem="wwI-k5-kbU" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="oNR-Ox-93x"/>
-                <constraint firstItem="wwI-k5-kbU" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="8" id="xPu-SG-9dw"/>
+                <constraint firstItem="wwI-k5-kbU" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="10" id="xPu-SG-9dw"/>
             </constraints>
             <nil key="simulatedStatusBarMetrics"/>
             <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
             <connections>
-                <outlet property="logoImageView" destination="wwI-k5-kbU" id="DFj-ka-K8K"/>
+                <outlet property="imageItem" destination="wwI-k5-kbU" id="SMZ-ie-2Ak"/>
                 <outlet property="optionLabel" destination="VIB-Xt-ckX" id="swX-Pi-eTf"/>
             </connections>
-            <point key="canvasLocation" x="515" y="409"/>
+            <point key="canvasLocation" x="632.79999999999995" y="412.89355322338832"/>
         </view>
     </objects>
     <resources>
-        <image name="logo_0" width="20" height="20"/>
+        <image name="avatar" width="25" height="25"/>
     </resources>
 </document>