marinofaggiana 4 лет назад
Родитель
Сommit
568be7f7f8

+ 9 - 31
iOSClient/Main/Menu/NCCollectionViewCommon+Menu.swift

@@ -224,38 +224,16 @@ extension NCCollectionViewCommon {
                     icon: UIImage(named: "rename")!.image(color: NCBrandColor.shared.icon, size: 50),
                     action: { menuAction in
                         
-                        if let navigationController = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() {
-                            navigationController.modalPresentationStyle = UIModalPresentationStyle.formSheet
-                            if let viewController = (navigationController as! UINavigationController).topViewController as? NCRenameFile {
-                                viewController.metadata = metadata
-                                self.present(navigationController, animated: true)
-                            }
-                        }
-                        
-                        /*
-                        let alertController = UIAlertController(title: NSLocalizedString("_rename_", comment: ""), message: nil, preferredStyle: .alert)
-                        
-                        alertController.addTextField { (textField) in
-                            textField.text = metadata.fileNameView
-                        }
-
-                        let cancelAction = UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: nil)
+                        if let viewController = UIStoryboard(name: "NCRenameFile", bundle: nil).instantiateInitialViewController() as? NCRenameFile {
+                            
+                            viewController.modalPresentationStyle = .overCurrentContext
+                            viewController.modalTransitionStyle = .crossDissolve
+                            viewController.preferredContentSize = CGSize(width: 300, height: 300)
 
-                        let okAction = UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { action in
-                            if let fileNameNew = alertController.textFields?.first?.text {
-                                NCNetworking.shared.renameMetadata(metadata, fileNameNew: fileNameNew, urlBase: appDelegate.urlBase, viewController: self) { (errorCode, errorDescription) in
-                                    if errorCode != 0 {
-                                        NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.error, errorCode: errorCode)
-                                    }
-                                }
-                            }
-                        })
-
-                        alertController.addAction(cancelAction)
-                        alertController.addAction(okAction)
-
-                        self.present(alertController, animated: true, completion: nil)
-                        */
+                            viewController.metadata = metadata
+                            
+                            self.present(viewController, animated: true)
+                        }
                     }
                 )
             )

+ 25 - 23
iOSClient/Main/Rename file/NCRenameFile.storyboard

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="rXH-Df-P31">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="V0q-CP-xMJ">
     <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
         <deployment identifier="iOS"/>
@@ -18,19 +18,19 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="t26-3S-4T4">
-                                <rect key="frame" x="132" y="138" width="150" height="150"/>
+                                <rect key="frame" x="132" y="94" width="150" height="150"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="150" id="PaU-P7-coi"/>
                                     <constraint firstAttribute="height" constant="150" id="s6R-ay-3Ui"/>
                                 </constraints>
                             </imageView>
                             <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Ny2-wR-rxo">
-                                <rect key="frame" x="20" y="322" width="304" height="34"/>
+                                <rect key="frame" x="20" y="278" width="304" height="34"/>
                                 <fontDescription key="fontDescription" type="system" pointSize="14"/>
                                 <textInputTraits key="textInputTraits"/>
                             </textField>
                             <textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Q9G-gl-Fkc">
-                                <rect key="frame" x="334" y="322" width="60" height="34"/>
+                                <rect key="frame" x="334" y="278" width="60" height="34"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="60" id="6ga-cj-dYT"/>
                                 </constraints>
@@ -38,7 +38,7 @@
                                 <textInputTraits key="textInputTraits"/>
                             </textField>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="FOZ-fs-k7i">
-                                <rect key="frame" x="324" y="328.5" width="10" height="21"/>
+                                <rect key="frame" x="324" y="284.5" width="10" height="21"/>
                                 <constraints>
                                     <constraint firstAttribute="width" constant="10" id="T5K-dj-AdT"/>
                                 </constraints>
@@ -46,52 +46,54 @@
                                 <nil key="textColor"/>
                                 <nil key="highlightedColor"/>
                             </label>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="W5y-aT-UlI">
+                                <rect key="frame" x="20" y="352" width="48" height="30"/>
+                                <state key="normal" title="Cancel"/>
+                                <connections>
+                                    <action selector="cancel:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="2u6-re-dJy"/>
+                                </connections>
+                            </button>
+                            <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="hcV-V0-eZB">
+                                <rect key="frame" x="338" y="352" width="56" height="30"/>
+                                <state key="normal" title="Rename"/>
+                                <connections>
+                                    <action selector="rename:" destination="V0q-CP-xMJ" eventType="touchUpInside" id="9tx-AQ-q6X"/>
+                                </connections>
+                            </button>
                         </subviews>
                         <viewLayoutGuide key="safeArea" id="1c1-7Q-WMG"/>
                         <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                         <constraints>
                             <constraint firstItem="Ny2-wR-rxo" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" constant="20" id="0xL-8c-oLT"/>
                             <constraint firstItem="t26-3S-4T4" firstAttribute="top" secondItem="1c1-7Q-WMG" secondAttribute="top" constant="50" id="1rN-dK-Q8e"/>
+                            <constraint firstItem="W5y-aT-UlI" firstAttribute="top" secondItem="Ny2-wR-rxo" secondAttribute="bottom" constant="40" id="96v-2U-wZv"/>
                             <constraint firstItem="Q9G-gl-Fkc" firstAttribute="leading" secondItem="FOZ-fs-k7i" secondAttribute="trailing" id="9XT-FO-xYu"/>
                             <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="Ny2-wR-rxo" secondAttribute="trailing" constant="90" id="BZO-yF-B1w"/>
                             <constraint firstItem="Ny2-wR-rxo" firstAttribute="top" secondItem="t26-3S-4T4" secondAttribute="bottom" constant="34" id="Ggg-Yg-PBS"/>
+                            <constraint firstItem="hcV-V0-eZB" firstAttribute="top" secondItem="Q9G-gl-Fkc" secondAttribute="bottom" constant="40" id="UMC-zV-sZD"/>
                             <constraint firstItem="Q9G-gl-Fkc" firstAttribute="centerY" secondItem="Ny2-wR-rxo" secondAttribute="centerY" id="ZYX-EF-MUc"/>
                             <constraint firstItem="FOZ-fs-k7i" firstAttribute="centerY" secondItem="Ny2-wR-rxo" secondAttribute="centerY" id="bRG-fN-OJB"/>
                             <constraint firstItem="t26-3S-4T4" firstAttribute="centerX" secondItem="1c1-7Q-WMG" secondAttribute="centerX" id="gjy-i8-K5B"/>
+                            <constraint firstItem="1c1-7Q-WMG" firstAttribute="trailing" secondItem="hcV-V0-eZB" secondAttribute="trailing" constant="20" id="heW-2p-hLJ"/>
+                            <constraint firstItem="W5y-aT-UlI" firstAttribute="leading" secondItem="1c1-7Q-WMG" secondAttribute="leading" constant="20" id="kw6-l5-CAR"/>
                             <constraint firstItem="FOZ-fs-k7i" firstAttribute="leading" secondItem="Ny2-wR-rxo" secondAttribute="trailing" id="zTq-r2-mRv"/>
                         </constraints>
                     </view>
                     <navigationItem key="navigationItem" id="Zon-2j-rsc"/>
                     <connections>
+                        <outlet property="cancelButton" destination="W5y-aT-UlI" id="P9l-o1-miU"/>
                         <outlet property="ext" destination="Q9G-gl-Fkc" id="YeW-bU-cMx"/>
                         <outlet property="fileNameWithoutExt" destination="Ny2-wR-rxo" id="2Wq-hO-cwc"/>
                         <outlet property="fileNameWithoutExtTrailingContraint" destination="BZO-yF-B1w" id="OBT-Ha-an7"/>
                         <outlet property="point" destination="FOZ-fs-k7i" id="InG-ZA-GpE"/>
                         <outlet property="previewFile" destination="t26-3S-4T4" id="aOo-XG-pom"/>
+                        <outlet property="renameButton" destination="hcV-V0-eZB" id="YGX-pw-OGW"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="qdm-Cl-C5l" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
             </objects>
             <point key="canvasLocation" x="1453.6231884057972" y="134.59821428571428"/>
         </scene>
-        <!--Navigation Controller-->
-        <scene sceneID="EGj-56-21I">
-            <objects>
-                <navigationController automaticallyAdjustsScrollViewInsets="NO" id="rXH-Df-P31" sceneMemberID="viewController">
-                    <toolbarItems/>
-                    <navigationBar key="navigationBar" contentMode="scaleToFill" id="9bE-0s-QH7">
-                        <rect key="frame" x="0.0" y="44" width="414" height="44"/>
-                        <autoresizingMask key="autoresizingMask"/>
-                    </navigationBar>
-                    <nil name="viewControllers"/>
-                    <connections>
-                        <segue destination="V0q-CP-xMJ" kind="relationship" relationship="rootViewController" id="ATN-i9-4Qs"/>
-                    </connections>
-                </navigationController>
-                <placeholder placeholderIdentifier="IBFirstResponder" id="Sp0-R6-fUP" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
-            </objects>
-            <point key="canvasLocation" x="543.47826086956525" y="134.59821428571428"/>
-        </scene>
     </scenes>
     <resources>
         <systemColor name="systemBackgroundColor">

+ 5 - 8
iOSClient/Main/Rename file/NCRenameFile.swift

@@ -12,12 +12,12 @@ import NCCommunication
 class NCRenameFile: UIViewController {
 
     @IBOutlet weak var previewFile: UIImageView!
-    
     @IBOutlet weak var fileNameWithoutExt: UITextField!
     @IBOutlet weak var point: UILabel!
     @IBOutlet weak var ext: UITextField!
-
     @IBOutlet weak var fileNameWithoutExtTrailingContraint: NSLayoutConstraint!
+    @IBOutlet weak var cancelButton: UIButton!
+    @IBOutlet weak var renameButton: UIButton!
 
     var metadata: tableMetadata?
     
@@ -56,9 +56,6 @@ class NCRenameFile: UIViewController {
         }
                 
         title = NSLocalizedString("_rename_file_", comment: "")
-        
-        navigationItem.leftBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_cancel_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(cancel))
-        navigationItem.rightBarButtonItem = UIBarButtonItem(title: NSLocalizedString("_rename_", comment: ""), style: UIBarButtonItem.Style.plain, target: self, action: #selector(rename))
     }
     
     override func viewDidAppear(_ animated: Bool) {
@@ -71,12 +68,12 @@ class NCRenameFile: UIViewController {
     
     // MARK: - Action
     
-    @objc func cancel() {
+    @IBAction func cancel(_ sender: Any) {
         dismiss(animated: true)
     }
     
-    @objc func rename() {
-        
+    @IBAction func rename(_ sender: Any) {
+
         guard let metadata = metadata else { return }
         var newFileNameWithoutExt = ""
         var newExt = ""