فهرست منبع

new view share

marinofaggiana 5 سال پیش
والد
کامیت
3ef39a2948
3فایلهای تغییر یافته به همراه157 افزوده شده و 1 حذف شده
  1. 4 0
      Nextcloud.xcodeproj/project.pbxproj
  2. 62 1
      iOSClient/Share/NCShare.swift
  3. 91 0
      iOSClient/Share/NCShareUserCell.xib

+ 4 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -327,6 +327,7 @@
 		F76673ED22C901F6007ED366 /* FileProviderDomain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76673EC22C901F5007ED366 /* FileProviderDomain.swift */; };
 		F76673EE22C901F6007ED366 /* FileProviderDomain.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76673EC22C901F5007ED366 /* FileProviderDomain.swift */; };
 		F76673F022C90434007ED366 /* FileProviderUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76673EF22C90433007ED366 /* FileProviderUtility.swift */; };
+		F769453C22E9CFFF000A798A /* NCShareUserCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F769453B22E9CFFF000A798A /* NCShareUserCell.xib */; };
 		F76B3CCE1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
 		F76B3CCF1EAE01BD00921AC9 /* NCBrand.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */; };
 		F76C6F8E21943C8C0063591B /* NCActionSheetHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = F76C6F8D21943C8C0063591B /* NCActionSheetHeader.swift */; };
@@ -1106,6 +1107,7 @@
 		F76344761BF259A800188725 /* synchronizedcrypto.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = synchronizedcrypto.gif; sourceTree = "<group>"; };
 		F76673EC22C901F5007ED366 /* FileProviderDomain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileProviderDomain.swift; sourceTree = "<group>"; };
 		F76673EF22C90433007ED366 /* FileProviderUtility.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FileProviderUtility.swift; sourceTree = "<group>"; };
+		F769453B22E9CFFF000A798A /* NCShareUserCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCShareUserCell.xib; sourceTree = "<group>"; };
 		F76B3CCD1EAE01BD00921AC9 /* NCBrand.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCBrand.swift; sourceTree = "<group>"; };
 		F76C3B831C6388BC00DC4301 /* CCGraphics.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGraphics.h; sourceTree = "<group>"; };
 		F76C3B841C6388BC00DC4301 /* CCGraphics.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCGraphics.m; sourceTree = "<group>"; };
@@ -1753,6 +1755,7 @@
 				F73CB3B122E072A000AD728E /* NCShareHeaderView.xib */,
 				F700510022DF63AC003A3356 /* NCShare.storyboard */,
 				F787704E22E7019900F287A9 /* NCShareLinkCell.xib */,
+				F769453B22E9CFFF000A798A /* NCShareUserCell.xib */,
 				F7DFAA8922E22EF100FC4527 /* NCShareLinkMenuView.xib */,
 				F700510422DF6A89003A3356 /* NCShare.swift */,
 			);
@@ -3260,6 +3263,7 @@
 				F7F54CF91E5B14C700E19C62 /* PlayButtonOverlayLargeTap@3x.png in Resources */,
 				F7D4233D1F0596AC009C9782 /* Reader-Button-N@3x.png in Resources */,
 				F73B4EF21F470D9100BBEE4B /* EUCTWFreq.tab in Resources */,
+				F769453C22E9CFFF000A798A /* NCShareUserCell.xib in Resources */,
 				F700222C1EC479840080073F /* Custom.xcassets in Resources */,
 				F758B45A212C564000515F55 /* Scan.storyboard in Resources */,
 				F77B0EFE1D118A16002130FE /* CCUploadFromOtherUpp.storyboard in Resources */,

+ 62 - 1
iOSClient/Share/NCShare.swift

@@ -229,7 +229,7 @@ class NCShareComments: UIViewController {
 
 // MARK: - Share
 
-class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDelegate, NCShareNetworkingDelegate {
+class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDelegate, NCShareUserCellDelegate, NCShareNetworkingDelegate {
     
     @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint!
     @IBOutlet weak var searchField: UITextField!
@@ -264,6 +264,7 @@ class NCShare: UIViewController, UIGestureRecognizerDelegate, NCShareLinkCellDel
         tableView.allowsSelection = false
         
         tableView.register(UINib.init(nibName: "NCShareLinkCell", bundle: nil), forCellReuseIdentifier: "cellLink")
+        tableView.register(UINib.init(nibName: "NCShareUserCell", bundle: nil), forCellReuseIdentifier: "cellUser")
         
         NotificationCenter.default.addObserver(self, selector: #selector(self.reloadData), name: NSNotification.Name(rawValue: "reloadDataNCShare"), object: nil)
         
@@ -378,6 +379,13 @@ extension NCShare: UITableViewDataSource {
                 cell.delegate = self
                 return cell
             }
+        } else {
+            if let cell = tableView.dequeueReusableCell(withIdentifier: "cellUser", for: indexPath) as? NCShareUserCell {
+                cell.tableShare = tableShare
+                cell.delegate = self
+                cell.labelTitle.text = tableShare.shareWith
+                return cell
+            }
         }
         
         return UITableViewCell()
@@ -419,6 +427,30 @@ protocol NCShareLinkCellDelegate {
     func tapMenu(with tableShare: tableShare?, sender: Any)
 }
 
+class NCShareUserCell: UITableViewCell {
+    
+    @IBOutlet weak var imageItem: UIImageView!
+    @IBOutlet weak var labelTitle: UILabel!
+    @IBOutlet weak var labelCanEdit: UILabel!
+    @IBOutlet weak var switchCanEdit: UISwitch!
+    @IBOutlet weak var buttonMenu: UIButton!
+    
+    var tableShare: tableShare?
+    var delegate: NCShareUserCellDelegate?
+    
+    override func awakeFromNib() {
+        super.awakeFromNib()
+        
+        switchCanEdit.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
+        switchCanEdit.onTintColor = NCBrandColor.sharedInstance.brand
+        labelCanEdit.text = NSLocalizedString("_share_permission_edit_", comment: "")
+        buttonMenu.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "shareMenu"), width:100, height: 100, color: UIColor.gray), for: .normal)
+    }
+}
+
+protocol NCShareUserCellDelegate {
+}
+
 // MARK: - ShareLinkMenuView
 
 class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkingDelegate, FSCalendarDelegate, FSCalendarDelegateAppearance {
@@ -472,9 +504,13 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
         layer.shadowOpacity = 0.2
         
         switchAllowEditing.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
+        switchAllowEditing.onTintColor = NCBrandColor.sharedInstance.brand
         switchHideDownload.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
+        switchHideDownload.onTintColor = NCBrandColor.sharedInstance.brand
         switchPasswordProtect.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
+        switchPasswordProtect.onTintColor = NCBrandColor.sharedInstance.brand
         switchSetExpirationDate.transform = CGAffineTransform(scaleX: 0.75, y: 0.75)
+        switchSetExpirationDate.onTintColor = NCBrandColor.sharedInstance.brand
         
         fieldSetExpirationDate.inputView = UIView()
 
@@ -798,6 +834,31 @@ 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
+    }
 }
 
 // --------------------------------------------------------------------------------------------

+ 91 - 0
iOSClient/Share/NCShareUserCell.xib

@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="cellUser" rowHeight="90" id="qJF-Yc-gKE" customClass="NCShareUserCell" customModule="Nextcloud" customModuleProvider="target">
+            <rect key="frame" x="0.0" y="0.0" width="600" height="90"/>
+            <autoresizingMask key="autoresizingMask"/>
+            <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="qJF-Yc-gKE" id="3Oe-gU-3Nk">
+                <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">
+                        <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>
+                    </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"/>
+                        <constraints>
+                            <constraint firstAttribute="width" constant="150" id="4Oa-yZ-HZK"/>
+                            <constraint firstAttribute="height" constant="18" id="iet-xr-SX6"/>
+                        </constraints>
+                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                        <color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                        <nil key="highlightedColor"/>
+                    </label>
+                    <switch opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" contentHorizontalAlignment="center" contentVerticalAlignment="center" on="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1Ju-M3-Ea4">
+                        <rect key="frame" x="418" y="29.5" width="49" height="31"/>
+                        <constraints>
+                            <constraint firstAttribute="height" constant="31" id="Yxu-hy-A7m"/>
+                            <constraint firstAttribute="width" constant="47" id="jeg-tb-g7e"/>
+                        </constraints>
+                    </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"/>
+                        <constraints>
+                            <constraint firstAttribute="height" constant="21" id="WZK-ND-Vl1"/>
+                            <constraint firstAttribute="width" constant="80" id="guh-u2-aXB"/>
+                        </constraints>
+                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                        <nil key="textColor"/>
+                        <nil key="highlightedColor"/>
+                    </label>
+                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="J1z-RG-U4A" userLabel="ButtonMenu">
+                        <rect key="frame" x="570" y="35" width="20" height="20"/>
+                        <constraints>
+                            <constraint firstAttribute="height" constant="20" id="G48-LB-BsD"/>
+                            <constraint firstAttribute="width" constant="20" id="vLI-cJ-Jqx"/>
+                        </constraints>
+                        <state key="normal" image="shareMenu"/>
+                    </button>
+                </subviews>
+                <constraints>
+                    <constraint firstItem="otH-mT-7Z4" firstAttribute="leading" secondItem="qDs-UG-Mn7" secondAttribute="trailing" constant="10" id="7o5-Rj-6lV"/>
+                    <constraint firstItem="otH-mT-7Z4" firstAttribute="centerY" secondItem="3Oe-gU-3Nk" secondAttribute="centerY" id="JNE-HJ-E36"/>
+                    <constraint firstItem="QXZ-ax-nlQ" firstAttribute="leading" secondItem="1Ju-M3-Ea4" secondAttribute="trailing" constant="10" id="JOV-hM-J9e"/>
+                    <constraint firstItem="qDs-UG-Mn7" firstAttribute="leading" secondItem="3Oe-gU-3Nk" secondAttribute="leading" constant="5" id="KOm-wo-CBa"/>
+                    <constraint firstItem="J1z-RG-U4A" firstAttribute="leading" secondItem="QXZ-ax-nlQ" secondAttribute="trailing" constant="15" id="N3c-Vr-0Vq"/>
+                    <constraint firstItem="1Ju-M3-Ea4" firstAttribute="centerY" secondItem="3Oe-gU-3Nk" secondAttribute="centerY" id="Se0-y9-Dgs"/>
+                    <constraint firstItem="J1z-RG-U4A" firstAttribute="centerY" secondItem="3Oe-gU-3Nk" secondAttribute="centerY" id="TvQ-yn-L5w"/>
+                    <constraint firstItem="qDs-UG-Mn7" firstAttribute="centerY" secondItem="3Oe-gU-3Nk" secondAttribute="centerY" id="ZrD-Aw-xkx"/>
+                    <constraint firstItem="QXZ-ax-nlQ" firstAttribute="centerY" secondItem="3Oe-gU-3Nk" secondAttribute="centerY" id="apA-j5-MyE"/>
+                    <constraint firstAttribute="trailing" secondItem="J1z-RG-U4A" secondAttribute="trailing" constant="10" id="pQA-B9-MM5"/>
+                </constraints>
+            </tableViewCellContentView>
+            <connections>
+                <outlet property="buttonMenu" destination="J1z-RG-U4A" id="g71-Us-VMl"/>
+                <outlet property="imageItem" destination="qDs-UG-Mn7" id="cRP-ne-dd0"/>
+                <outlet property="labelCanEdit" destination="QXZ-ax-nlQ" id="7Fw-B4-eo4"/>
+                <outlet property="labelTitle" destination="otH-mT-7Z4" id="qxQ-kL-P3H"/>
+                <outlet property="switchCanEdit" destination="1Ju-M3-Ea4" id="TvH-ZH-KWR"/>
+            </connections>
+            <point key="canvasLocation" x="97.599999999999994" y="276.1619190404798"/>
+        </tableViewCell>
+    </objects>
+    <resources>
+        <image name="circle" width="329" height="329"/>
+        <image name="shareMenu" width="329" height="329"/>
+    </resources>
+</document>