Browse Source

new view share (comments)

marinofaggiana 5 years ago
parent
commit
c862fdcb40

+ 1 - 1
iOSClient/CCGlobal.h

@@ -81,7 +81,7 @@
 
 // Database Realm
 #define k_databaseDefault                               @"nextcloud.realm"
-#define k_databaseSchemaVersion                         63
+#define k_databaseSchemaVersion                         64
 
 // Intro selector
 #define k_intro_login                                   0

+ 1 - 1
iOSClient/Database/NCDatabase.swift

@@ -211,7 +211,7 @@ class tableComments: Object {
     @objc dynamic var actorDisplayName = ""
     @objc dynamic var actorId = ""
     @objc dynamic var actorType = ""
-    @objc dynamic var creationDateTime: NSDate? = nil
+    @objc dynamic var creationDateTime = NSDate()
     @objc dynamic var fileID = ""
     @objc dynamic var isUnread: Bool = false
     @objc dynamic var message = ""

+ 35 - 7
iOSClient/Share/NCShare.storyboard

@@ -56,27 +56,53 @@
                                 <rect key="frame" x="0.0" y="244" width="409" height="618"/>
                                 <subviews>
                                     <textField opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="249" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" clearButtonMode="always" translatesAutoresizingMaskIntoConstraints="NO" id="j5C-gO-XF8">
-                                        <rect key="frame" x="10" y="10" width="389" height="30"/>
+                                        <rect key="frame" x="55" y="60" width="344" height="30"/>
                                         <constraints>
                                             <constraint firstAttribute="height" constant="30" id="Cia-Ws-3fQ"/>
                                         </constraints>
-                                        <nil key="textColor"/>
-                                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                         <textInputTraits key="textInputTraits"/>
                                     </textField>
-                                    <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="none" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="DFs-4t-iWX">
-                                        <rect key="frame" x="5" y="50" width="404" height="558"/>
+                                    <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="DFs-4t-iWX">
+                                        <rect key="frame" x="5" y="100" width="404" height="508"/>
                                         <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                        <color key="separatorColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                     </tableView>
+                                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="avatar" translatesAutoresizingMaskIntoConstraints="NO" id="Oca-tA-DgS" customClass="NCAvatar" customModule="Nextcloud" customModuleProvider="target">
+                                        <rect key="frame" x="10" y="10" width="40" height="40"/>
+                                        <constraints>
+                                            <constraint firstAttribute="width" constant="40" id="COd-nn-6gK"/>
+                                            <constraint firstAttribute="height" constant="40" id="cp1-OV-zK5"/>
+                                        </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="user" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9sc-sV-YF1">
+                                        <rect key="frame" x="60" y="21.5" width="337" height="17"/>
+                                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                                        <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
                                 </subviews>
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <constraints>
                                     <constraint firstItem="DFs-4t-iWX" firstAttribute="top" secondItem="j5C-gO-XF8" secondAttribute="bottom" constant="10" id="2W4-MV-Q3t"/>
-                                    <constraint firstItem="j5C-gO-XF8" firstAttribute="top" secondItem="jzJ-Ra-l4b" secondAttribute="top" constant="10" id="FVU-Ra-LGp"/>
+                                    <constraint firstItem="9sc-sV-YF1" firstAttribute="centerY" secondItem="Oca-tA-DgS" secondAttribute="centerY" id="IAl-P4-FDb"/>
+                                    <constraint firstItem="9sc-sV-YF1" firstAttribute="leading" secondItem="Oca-tA-DgS" secondAttribute="trailing" constant="10" id="JLb-OL-NAh"/>
                                     <constraint firstItem="DFs-4t-iWX" firstAttribute="leading" secondItem="jzJ-Ra-l4b" secondAttribute="leading" constant="5" id="JN4-2m-lYt"/>
-                                    <constraint firstItem="j5C-gO-XF8" firstAttribute="leading" secondItem="jzJ-Ra-l4b" secondAttribute="leading" constant="10" id="TyF-h2-Kf2"/>
+                                    <constraint firstItem="Oca-tA-DgS" firstAttribute="top" secondItem="jzJ-Ra-l4b" secondAttribute="top" constant="10" id="Nix-3m-Pph"/>
+                                    <constraint firstItem="j5C-gO-XF8" firstAttribute="leading" secondItem="jzJ-Ra-l4b" secondAttribute="leading" constant="55" id="TyF-h2-Kf2"/>
+                                    <constraint firstItem="Oca-tA-DgS" firstAttribute="leading" secondItem="jzJ-Ra-l4b" secondAttribute="leading" constant="10" id="UkL-iB-zOb"/>
+                                    <constraint firstItem="j5C-gO-XF8" firstAttribute="top" secondItem="Oca-tA-DgS" secondAttribute="bottom" constant="10" id="Xe1-ck-SGj"/>
                                     <constraint firstAttribute="trailing" secondItem="DFs-4t-iWX" secondAttribute="trailing" id="ZcL-Ph-LOK"/>
                                     <constraint firstAttribute="trailing" secondItem="j5C-gO-XF8" secondAttribute="trailing" constant="10" id="baS-fH-yjJ"/>
+                                    <constraint firstAttribute="trailing" secondItem="9sc-sV-YF1" secondAttribute="trailing" constant="12" id="ds7-kh-lTP"/>
                                     <constraint firstAttribute="bottom" secondItem="DFs-4t-iWX" secondAttribute="bottom" constant="10" id="ghq-O1-zbF"/>
                                 </constraints>
                             </view>
@@ -91,6 +117,8 @@
                         <viewLayoutGuide key="safeArea" id="j3W-IW-lzW"/>
                     </view>
                     <connections>
+                        <outlet property="imageItem" destination="Oca-tA-DgS" id="4s1-hB-7aX"/>
+                        <outlet property="labelUser" destination="9sc-sV-YF1" id="JDY-BT-xob"/>
                         <outlet property="newCommentField" destination="j5C-gO-XF8" id="bYE-r4-F6m"/>
                         <outlet property="tableView" destination="DFs-4t-iWX" id="oU5-M6-jh0"/>
                         <outlet property="viewContainerConstraint" destination="vgD-mh-dz8" id="CC9-oG-uiP"/>

+ 24 - 2
iOSClient/Share/NCShareComments.swift

@@ -27,6 +27,8 @@ class NCShareComments: UIViewController, NCShareCommentsCellDelegate {
    
     @IBOutlet weak var viewContainerConstraint: NSLayoutConstraint!
     @IBOutlet weak var tableView: UITableView!
+    @IBOutlet weak var imageItem: UIImageView!
+    @IBOutlet weak var labelUser: UILabel!
     @IBOutlet weak var newCommentField: UITextField!
 
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
@@ -41,7 +43,6 @@ class NCShareComments: UIViewController, NCShareCommentsCellDelegate {
         
         tableView.dataSource = self
         tableView.delegate = self
-        tableView.separatorColor = NCBrandColor.sharedInstance.seperator
         tableView.tableFooterView = UIView()
         tableView.rowHeight = UITableView.automaticDimension
         tableView.estimatedRowHeight = tableView.bounds.height
@@ -50,7 +51,26 @@ class NCShareComments: UIViewController, NCShareCommentsCellDelegate {
         tableView.register(UINib.init(nibName: "NCShareCommentsCell", bundle: nil), forCellReuseIdentifier: "cell")
 
         newCommentField.placeholder = NSLocalizedString("_new_comment_", comment: "")
-
+        
+        // Display Name user & Quota
+        guard let tabAccount = NCManageDatabase.sharedInstance.getAccountActive() else {
+            return
+        }
+        
+        if tabAccount.displayName.isEmpty {
+            labelUser.text = tabAccount.user
+        }
+        else{
+            labelUser.text = tabAccount.displayName
+        }
+        
+        let fileNameLocalPath = CCUtility.getDirectoryUserData() + "/" + CCUtility.getStringUser(appDelegate.activeUser, activeUrl: appDelegate.activeUrl) + "-" + appDelegate.activeUser + ".png"
+        if FileManager.default.fileExists(atPath: fileNameLocalPath) {
+            if let image = UIImage(contentsOfFile: fileNameLocalPath) {
+                imageItem.image = image
+            }
+        }
+        
         reloadData()
     }
     
@@ -134,6 +154,8 @@ extension NCShareComments: UITableViewDataSource {
             }
             // Username
             cell.labelUser.text = tableComments.actorDisplayName
+            // Date
+            cell.labelDate.text = CCUtility.dateDiff(tableComments.creationDateTime as Date)
             // Message
             cell.labelMessage.text = tableComments.message
             

+ 15 - 15
iOSClient/Share/NCShareCommentsCell.xib

@@ -11,15 +11,15 @@
     <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="cell" id="qJF-Yc-gKE" customClass="NCShareCommentsCell" customModule="Nextcloud" customModuleProvider="target">
-            <rect key="frame" x="0.0" y="0.0" width="600" height="90"/>
+        <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="cell" rowHeight="122" id="qJF-Yc-gKE" customClass="NCShareCommentsCell" customModule="Nextcloud" customModuleProvider="target">
+            <rect key="frame" x="0.0" y="0.0" width="600" height="122"/>
             <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"/>
+                <rect key="frame" x="0.0" y="0.0" width="600" height="121.5"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
                     <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="10" width="40" height="40"/>
+                        <rect key="frame" x="5" y="15" width="40" height="40"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="40" id="8et-YH-T1D"/>
                             <constraint firstAttribute="width" constant="40" id="GNY-Va-SIJ"/>
@@ -34,27 +34,27 @@
                         </userDefinedRuntimeAttributes>
                     </imageView>
                     <label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="user" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="otH-mT-7Z4" userLabel="labelTitle">
-                        <rect key="frame" x="55" y="21" width="30" height="18"/>
+                        <rect key="frame" x="55" y="26" width="28.5" height="18"/>
                         <constraints>
                             <constraint firstAttribute="width" relation="lessThanOrEqual" constant="200" id="4Oa-yZ-HZK"/>
                             <constraint firstAttribute="height" constant="18" id="iet-xr-SX6"/>
                         </constraints>
-                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
                         <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <nil key="highlightedColor"/>
                     </label>
                     <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="date" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QXZ-ax-nlQ">
-                        <rect key="frame" x="510" y="21" width="80" height="18"/>
+                        <rect key="frame" x="470" y="26" width="120" height="18"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="18" id="WZK-ND-Vl1"/>
-                            <constraint firstAttribute="width" constant="80" id="guh-u2-aXB"/>
+                            <constraint firstAttribute="width" constant="120" id="guh-u2-aXB"/>
                         </constraints>
-                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
                         <color key="textColor" white="0.66666666666666663" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <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="95" y="20" width="20" height="20"/>
+                        <rect key="frame" x="93.5" y="25" width="20" height="20"/>
                         <constraints>
                             <constraint firstAttribute="height" constant="20" id="G48-LB-BsD"/>
                             <constraint firstAttribute="width" constant="20" id="vLI-cJ-Jqx"/>
@@ -62,11 +62,11 @@
                         <state key="normal" image="shareMenu"/>
                     </button>
                     <label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="message" lineBreakMode="middleTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mNK-Zq-pFW" userLabel="labelTitle">
-                        <rect key="frame" x="55" y="58" width="540" height="21.5"/>
+                        <rect key="frame" x="55" y="63" width="540" height="43.5"/>
                         <constraints>
                             <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="15" id="tAu-Ct-G3J"/>
                         </constraints>
-                        <fontDescription key="fontDescription" type="system" pointSize="15"/>
+                        <fontDescription key="fontDescription" type="system" pointSize="14"/>
                         <nil key="highlightedColor"/>
                     </label>
                 </subviews>
@@ -77,8 +77,8 @@
                     <constraint firstItem="otH-mT-7Z4" firstAttribute="leading" secondItem="qDs-UG-Mn7" secondAttribute="trailing" constant="10" id="7o5-Rj-6lV"/>
                     <constraint firstAttribute="trailing" secondItem="mNK-Zq-pFW" secondAttribute="trailing" constant="5" id="A2t-sl-Uer"/>
                     <constraint firstItem="QXZ-ax-nlQ" firstAttribute="centerY" secondItem="qDs-UG-Mn7" secondAttribute="centerY" id="DzK-Ps-SiV"/>
-                    <constraint firstItem="qDs-UG-Mn7" firstAttribute="top" secondItem="3Oe-gU-3Nk" secondAttribute="top" constant="10" id="FAO-D8-MXo"/>
-                    <constraint firstAttribute="bottom" secondItem="mNK-Zq-pFW" secondAttribute="bottom" constant="10" id="H9H-lE-Gg1"/>
+                    <constraint firstItem="qDs-UG-Mn7" firstAttribute="top" secondItem="3Oe-gU-3Nk" secondAttribute="top" constant="15" id="FAO-D8-MXo"/>
+                    <constraint firstAttribute="bottom" secondItem="mNK-Zq-pFW" secondAttribute="bottom" constant="15" id="H9H-lE-Gg1"/>
                     <constraint firstItem="otH-mT-7Z4" firstAttribute="centerY" secondItem="qDs-UG-Mn7" secondAttribute="centerY" id="KO4-0R-wdL" userLabel="labelTitle.centerY = ImageItem.centerY"/>
                     <constraint firstItem="qDs-UG-Mn7" firstAttribute="leading" secondItem="3Oe-gU-3Nk" secondAttribute="leading" constant="5" id="KOm-wo-CBa"/>
                     <constraint firstItem="mNK-Zq-pFW" firstAttribute="top" secondItem="qDs-UG-Mn7" secondAttribute="bottom" constant="8" id="ndh-x5-eXA"/>
@@ -92,7 +92,7 @@
                 <outlet property="labelMessage" destination="mNK-Zq-pFW" id="oRf-8F-Pwu"/>
                 <outlet property="labelUser" destination="otH-mT-7Z4" id="Wf0-PX-Vrq"/>
             </connections>
-            <point key="canvasLocation" x="97.599999999999994" y="276.1619190404798"/>
+            <point key="canvasLocation" x="97.599999999999994" y="290.55472263868069"/>
         </tableViewCell>
     </objects>
     <resources>