Selaa lähdekoodia

new share extension

marinofaggiana 3 vuotta sitten
vanhempi
commit
3d485eae09

+ 64 - 34
Share/MainInterface.storyboard

@@ -43,7 +43,7 @@
                                         </constraints>
                                     </view>
                                     <tableView clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="eU0-LW-AnG">
-                                        <rect key="frame" x="10" y="71" width="394" height="249"/>
+                                        <rect key="frame" x="10" y="70" width="394" height="220"/>
                                         <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                         <prototypes>
                                             <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="none" indentationWidth="10" reuseIdentifier="Cell" rowHeight="50" id="6Kt-n0-i8J">
@@ -103,46 +103,74 @@
                                             <outlet property="delegate" destination="VYq-xA-D35" id="DAj-hF-SRY"/>
                                         </connections>
                                     </tableView>
-                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="create folder" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WHW-J5-8gq">
-                                        <rect key="frame" x="10" y="38" width="72.333333333333329" height="13.333333333333336"/>
-                                        <fontDescription key="fontDescription" type="system" pointSize="12"/>
-                                        <nil key="textColor"/>
-                                        <nil key="highlightedColor"/>
-                                    </label>
-                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="1xT-vl-sQp">
-                                        <rect key="frame" x="175" y="330" width="64" height="30"/>
-                                        <state key="normal" title="save files"/>
-                                        <connections>
-                                            <action selector="actionUpload:" destination="VYq-xA-D35" eventType="touchUpInside" id="ENy-P1-SDo"/>
-                                        </connections>
-                                    </button>
-                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="USb-OF-Gaq">
-                                        <rect key="frame" x="31.333333333333329" y="7" width="30" height="30"/>
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Tbe-Jp-I8U">
+                                        <rect key="frame" x="10" y="10" width="394" height="50"/>
+                                        <subviews>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="create folder" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WHW-J5-8gq">
+                                                <rect key="frame" x="287.33333333333331" y="14.999999999999998" width="96.666666666666686" height="20.333333333333329"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                <nil key="textColor"/>
+                                                <nil key="highlightedColor"/>
+                                            </label>
+                                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="R3X-g5-ZFs">
+                                                <rect key="frame" x="10" y="10" width="30" height="30"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="width" constant="30" id="9Qc-Ji-5yh"/>
+                                                    <constraint firstAttribute="height" constant="30" id="UUM-06-R5m"/>
+                                                </constraints>
+                                            </imageView>
+                                        </subviews>
+                                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                                         <constraints>
-                                            <constraint firstAttribute="height" constant="30" id="5HP-Gs-tLd"/>
-                                            <constraint firstAttribute="width" constant="30" id="NUe-Vv-dOz"/>
+                                            <constraint firstAttribute="height" constant="50" id="Py5-lr-dJD"/>
+                                            <constraint firstItem="WHW-J5-8gq" firstAttribute="centerY" secondItem="Tbe-Jp-I8U" secondAttribute="centerY" id="ccx-II-bpQ"/>
+                                            <constraint firstItem="R3X-g5-ZFs" firstAttribute="centerY" secondItem="Tbe-Jp-I8U" secondAttribute="centerY" id="mJt-qE-buH"/>
+                                            <constraint firstAttribute="trailing" secondItem="WHW-J5-8gq" secondAttribute="trailing" constant="10" id="oqd-Ag-7wU"/>
+                                            <constraint firstItem="R3X-g5-ZFs" firstAttribute="leading" secondItem="Tbe-Jp-I8U" secondAttribute="leading" constant="10" id="qgl-VD-5v8"/>
                                         </constraints>
-                                        <state key="normal" image="folder"/>
-                                        <connections>
-                                            <action selector="actionCreateFolder:" destination="VYq-xA-D35" eventType="touchUpInside" id="VKJ-l5-aU0"/>
-                                        </connections>
-                                    </button>
+                                    </view>
+                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kHU-CI-3gI">
+                                        <rect key="frame" x="10" y="300" width="394" height="50"/>
+                                        <subviews>
+                                            <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="save files" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="ka7-SC-ac5">
+                                                <rect key="frame" x="313.66666666666669" y="14.999999999999998" width="70.333333333333314" height="20.333333333333329"/>
+                                                <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                <nil key="textColor"/>
+                                                <nil key="highlightedColor"/>
+                                            </label>
+                                            <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Gok-do-ydQ">
+                                                <rect key="frame" x="10" y="10" width="30" height="30"/>
+                                                <constraints>
+                                                    <constraint firstAttribute="height" constant="30" id="hof-u1-w4Q"/>
+                                                    <constraint firstAttribute="width" constant="30" id="n6T-Di-HBC"/>
+                                                </constraints>
+                                            </imageView>
+                                        </subviews>
+                                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
+                                        <constraints>
+                                            <constraint firstItem="Gok-do-ydQ" firstAttribute="leading" secondItem="kHU-CI-3gI" secondAttribute="leading" constant="10" id="3bo-Wd-s5E"/>
+                                            <constraint firstAttribute="height" constant="50" id="6xq-PW-8Ay"/>
+                                            <constraint firstItem="Gok-do-ydQ" firstAttribute="centerY" secondItem="kHU-CI-3gI" secondAttribute="centerY" id="P9O-Ts-odZ"/>
+                                            <constraint firstAttribute="trailing" secondItem="ka7-SC-ac5" secondAttribute="trailing" constant="10" id="nYi-0s-5Qo"/>
+                                            <constraint firstItem="ka7-SC-ac5" firstAttribute="centerY" secondItem="kHU-CI-3gI" secondAttribute="centerY" id="u7t-cL-zFA"/>
+                                        </constraints>
+                                    </view>
                                 </subviews>
                                 <color key="backgroundColor" systemColor="systemGray6Color"/>
                                 <constraints>
-                                    <constraint firstItem="eU0-LW-AnG" firstAttribute="top" secondItem="LAs-iQ-u1X" secondAttribute="bottom" constant="70" id="14j-96-VwG"/>
+                                    <constraint firstItem="Tbe-Jp-I8U" firstAttribute="top" secondItem="FaV-kz-PEs" secondAttribute="top" constant="10" id="4im-Bh-Rf7"/>
                                     <constraint firstAttribute="height" constant="390" id="50u-lA-AUo"/>
-                                    <constraint firstAttribute="bottom" secondItem="1xT-vl-sQp" secondAttribute="bottom" constant="30" id="7vg-42-5oO"/>
+                                    <constraint firstAttribute="trailing" secondItem="kHU-CI-3gI" secondAttribute="trailing" constant="10" id="8id-Gf-ki5"/>
+                                    <constraint firstAttribute="trailing" secondItem="Tbe-Jp-I8U" secondAttribute="trailing" constant="10" id="9O7-wg-OlH"/>
                                     <constraint firstItem="eU0-LW-AnG" firstAttribute="leading" secondItem="FaV-kz-PEs" secondAttribute="leading" constant="10" id="E40-Ul-MEV"/>
-                                    <constraint firstItem="WHW-J5-8gq" firstAttribute="leading" secondItem="FaV-kz-PEs" secondAttribute="leading" constant="10" id="FQu-Xp-l7a"/>
-                                    <constraint firstItem="WHW-J5-8gq" firstAttribute="top" secondItem="USb-OF-Gaq" secondAttribute="bottom" constant="1" id="KVN-cR-x3K"/>
-                                    <constraint firstItem="USb-OF-Gaq" firstAttribute="centerX" secondItem="WHW-J5-8gq" secondAttribute="centerX" id="Vbh-0w-Bvo"/>
-                                    <constraint firstItem="1xT-vl-sQp" firstAttribute="centerX" secondItem="FaV-kz-PEs" secondAttribute="centerX" id="bUe-Dp-BNI"/>
+                                    <constraint firstItem="eU0-LW-AnG" firstAttribute="top" secondItem="Tbe-Jp-I8U" secondAttribute="bottom" constant="10" id="Iwl-0n-oDz"/>
                                     <constraint firstItem="LAs-iQ-u1X" firstAttribute="leading" secondItem="FaV-kz-PEs" secondAttribute="leading" id="dr0-zN-pwa"/>
+                                    <constraint firstItem="kHU-CI-3gI" firstAttribute="leading" secondItem="FaV-kz-PEs" secondAttribute="leading" constant="10" id="dtw-q4-l5s"/>
+                                    <constraint firstItem="kHU-CI-3gI" firstAttribute="top" secondItem="eU0-LW-AnG" secondAttribute="bottom" constant="10" id="ecC-SY-AEU"/>
                                     <constraint firstItem="LAs-iQ-u1X" firstAttribute="top" secondItem="FaV-kz-PEs" secondAttribute="top" id="gvj-gm-XbO"/>
-                                    <constraint firstItem="WHW-J5-8gq" firstAttribute="top" secondItem="FaV-kz-PEs" secondAttribute="top" constant="38" id="lWV-vn-0kj"/>
+                                    <constraint firstItem="Tbe-Jp-I8U" firstAttribute="leading" secondItem="FaV-kz-PEs" secondAttribute="leading" constant="10" id="nB1-9c-DmY"/>
                                     <constraint firstAttribute="trailing" secondItem="eU0-LW-AnG" secondAttribute="trailing" constant="10" id="qQA-Ix-Ge1"/>
-                                    <constraint firstAttribute="bottom" secondItem="eU0-LW-AnG" secondAttribute="bottom" constant="70" id="r6E-QV-nj7"/>
+                                    <constraint firstAttribute="bottom" secondItem="eU0-LW-AnG" secondAttribute="bottom" constant="100" id="r6E-QV-nj7"/>
                                     <constraint firstAttribute="trailing" secondItem="LAs-iQ-u1X" secondAttribute="trailing" id="v8j-JB-2Io"/>
                                 </constraints>
                             </view>
@@ -171,12 +199,15 @@
                         <outlet property="collectionView" destination="0HI-k1-SD0" id="xme-mG-bnz"/>
                         <outlet property="commandView" destination="FaV-kz-PEs" id="s91-n4-PKE"/>
                         <outlet property="commandViewHeightConstraint" destination="50u-lA-AUo" id="ygm-ah-cHw"/>
-                        <outlet property="createFolderButton" destination="USb-OF-Gaq" id="mHT-mC-VL1"/>
+                        <outlet property="createFolderImage" destination="R3X-g5-ZFs" id="klm-3T-tiU"/>
                         <outlet property="createFolderLabel" destination="WHW-J5-8gq" id="N93-Bs-sc9"/>
+                        <outlet property="createFolderView" destination="Tbe-Jp-I8U" id="W59-Hm-lCw"/>
                         <outlet property="separatorHeightConstraint" destination="wOp-so-23c" id="r8x-LQ-sxb"/>
                         <outlet property="separatorView" destination="LAs-iQ-u1X" id="53E-lW-30T"/>
                         <outlet property="tableView" destination="eU0-LW-AnG" id="mLD-VN-uyz"/>
-                        <outlet property="uploadButton" destination="1xT-vl-sQp" id="POZ-yK-W9P"/>
+                        <outlet property="uploadImage" destination="Gok-do-ydQ" id="lZa-JZ-LCk"/>
+                        <outlet property="uploadLabel" destination="ka7-SC-ac5" id="yTg-qK-MjJ"/>
+                        <outlet property="uploadView" destination="kHU-CI-3gI" id="Iok-Qb-nGR"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="vH8-UY-9MN" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -245154,7 +245185,6 @@ AOAtrADgLa4A4C2wAOAtsgDgP1IA4D9XAOA/ZADgP2cA4D90AOA/eQDgP4EA4D+EAOA/iQDgP5EAAAAA
 AAAEAQAAAAAAAABoAAAAAAAAAAAAAAAAAOA/lA
 </mutableData>
         </image>
-        <image name="folder" width="300" height="300"/>
         <image name="pencil" width="16" height="16"/>
         <systemColor name="separatorColor">
             <color red="0.23529411764705882" green="0.23529411764705882" blue="0.2627450980392157" alpha="0.28999999999999998" colorSpace="custom" customColorSpace="sRGB"/>

+ 29 - 11
Share/NCShareExtension.swift

@@ -33,10 +33,15 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
     @IBOutlet weak var commandView: UIView!
     @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint!
     @IBOutlet weak var commandViewHeightConstraint: NSLayoutConstraint!
-    @IBOutlet weak var createFolderButton: UIButton!
+    
+    @IBOutlet weak var createFolderView: UIView!
+    @IBOutlet weak var createFolderImage: UIImageView!
     @IBOutlet weak var createFolderLabel: UILabel!
-    @IBOutlet weak var uploadButton: UIButton!
 
+    @IBOutlet weak var uploadView: UIView!
+    @IBOutlet weak var uploadImage: UIImageView!
+    @IBOutlet weak var uploadLabel: UILabel!
+    
     // -------------------------------------------------------------
     var titleCurrentFolder = NCBrandOptions.shared.brand
     var serverUrl = ""
@@ -126,17 +131,30 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
         // Empty
         emptyDataSet = NCEmptyDataSet.init(view: collectionView, offset: -100, delegate: self)
         
+        // Command view
         commandView.backgroundColor = commandViewColor
-        separatorHeightConstraint.constant = 0.3
         separatorView.backgroundColor = separatorColor
+        separatorHeightConstraint.constant = 0.3
+        
+        // Table view
         tableView.separatorColor = separatorColor
-        //tableView.layer.borderColor = separatorColor.cgColor
-        //tableView.layer.borderWidth = 0
-        tableView.layer.cornerRadius = 10.0
+        tableView.layer.cornerRadius = 10
         tableView.tableFooterView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 0, height: 1)))
+
+        // Create folder
+        createFolderView.layer.cornerRadius = 10
+        createFolderImage.image = UIImage(named: "folder")?.image(color: labelColor, size: 15)
         createFolderLabel.text = NSLocalizedString("_create_folder_", comment: "")
-        uploadButton.setTitle(NSLocalizedString("_save_files_", comment: ""), for: .normal)
-        
+        let createFolderGesture = UITapGestureRecognizer(target: self, action:  #selector(actionCreateFolder))
+        createFolderView.addGestureRecognizer(createFolderGesture)
+        
+        // Upload
+        uploadView.layer.cornerRadius = 10
+        uploadImage.image = UIImage(named: "folder")?.image(color: labelColor, size: 15)
+        uploadLabel.text = NSLocalizedString("_save_files_", comment: "")
+        let uploadGesture = UITapGestureRecognizer(target: self, action:  #selector(actionUpload))
+        uploadView.addGestureRecognizer(uploadGesture)
+                
         // LOG
         let levelLog = CCUtility.getLogLevel()
         let isSimulatorOrTestFlight = NCUtility.shared.isSimulatorOrTestFlight()
@@ -308,7 +326,7 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
         extensionContext?.completeRequest(returningItems: extensionContext?.inputItems, completionHandler: nil)
     }
     
-    @IBAction func actionCreateFolder(_ sender: UIButton) {
+    @objc func actionCreateFolder() {
         
         let alertController = UIAlertController(title: NSLocalizedString("_create_folder_", comment: ""), message:"", preferredStyle: .alert)
         
@@ -332,7 +350,7 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
         self.present(alertController, animated: true, completion:nil)
     }
     
-    @IBAction func actionUpload(_ sender: UIButton) {
+    @objc func actionUpload() {
         
         if let fileName = filesName.first {
             
@@ -356,7 +374,7 @@ class NCShareExtension: UIViewController, NCListCellDelegate, NCEmptyDataSetDele
                     NCUtility.shared.stopActivityIndicator()
                     
                     if errorCode == 0 {
-                        self.actionUpload(UIButton())
+                        self.actionUpload()
                     } else {
                         self.extensionContext?.completeRequest(returningItems: self.extensionContext?.inputItems, completionHandler: nil)
                     }

+ 1 - 2
iOSClient/Utility/NCPopupViewController.swift

@@ -1,7 +1,7 @@
 //
 //  NCPopupViewController.swift
 //
-//  Based on  EzPopup by Huy Nguyen
+//  Based on EzPopup by Huy Nguyen
 //  Modified by Marino Faggiana for Nextcloud progect.
 //
 //  Author Marino Faggiana <marino.faggiana@nextcloud.com>
@@ -23,7 +23,6 @@ import UIKit
 
 public protocol NCPopupViewControllerDelegate: class {
     
-    // It is called when pop up is dismissed by tap outside
     func popupViewControllerDidDismissByTapGesture(_ sender: NCPopupViewController)
 }