瀏覽代碼

add NCActionSheetHeaderView

Marino Faggiana 6 年之前
父節點
當前提交
6e088000fb

+ 8 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -130,6 +130,8 @@
 		F7169A1E1EE590930086BD69 /* NCSharesCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7169A1B1EE590930086BD69 /* NCSharesCell.xib */; };
 		F7226EDC1EE4089300EBECB1 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7226EDB1EE4089300EBECB1 /* Main.storyboard */; };
 		F726EEEC1FED1C820030B9C8 /* NCEndToEndInitialize.swift in Sources */ = {isa = PBXBuildFile; fileRef = F726EEEB1FED1C820030B9C8 /* NCEndToEndInitialize.swift */; };
+		F729B92B217A2E4E00FE2150 /* NCActionSheetHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F729B92A217A2E4E00FE2150 /* NCActionSheetHeaderView.xib */; };
+		F729B92D217A2F1B00FE2150 /* NCActionSheetHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F729B92C217A2F1B00FE2150 /* NCActionSheetHeaderView.swift */; };
 		F72AAECA1E5C60C700BB17E1 /* AHKActionSheet.m in Sources */ = {isa = PBXBuildFile; fileRef = F72AAEC31E5C60C700BB17E1 /* AHKActionSheet.m */; };
 		F72AAECB1E5C60C700BB17E1 /* AHKActionSheetViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = F72AAEC51E5C60C700BB17E1 /* AHKActionSheetViewController.m */; };
 		F72D0FF9210B6638009C96B7 /* Protobuf.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F72D0FEF210B6638009C96B7 /* Protobuf.framework */; };
@@ -910,6 +912,8 @@
 		F7229B491DF71BB300E8C4E7 /* AUTHORS */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AUTHORS; sourceTree = SOURCE_ROOT; };
 		F726EEEB1FED1C820030B9C8 /* NCEndToEndInitialize.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCEndToEndInitialize.swift; sourceTree = "<group>"; };
 		F7296A661C8880ED001A7809 /* CCloadItemData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCloadItemData.swift; sourceTree = "<group>"; };
+		F729B92A217A2E4E00FE2150 /* NCActionSheetHeaderView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCActionSheetHeaderView.xib; sourceTree = "<group>"; };
+		F729B92C217A2F1B00FE2150 /* NCActionSheetHeaderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCActionSheetHeaderView.swift; sourceTree = "<group>"; };
 		F72AAEC21E5C60C700BB17E1 /* AHKActionSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AHKActionSheet.h; sourceTree = "<group>"; };
 		F72AAEC31E5C60C700BB17E1 /* AHKActionSheet.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AHKActionSheet.m; sourceTree = "<group>"; };
 		F72AAEC41E5C60C700BB17E1 /* AHKActionSheetViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AHKActionSheetViewController.h; sourceTree = "<group>"; };
@@ -2890,6 +2894,8 @@
 				F78F74332163757000C2ADAD /* NCTrash.storyboard */,
 				F7417DB2216CE925007D05F5 /* NCTrashHeaderFooterMenu.swift */,
 				F78F74352163781100C2ADAD /* NCTrash.swift */,
+				F729B92A217A2E4E00FE2150 /* NCActionSheetHeaderView.xib */,
+				F729B92C217A2F1B00FE2150 /* NCActionSheetHeaderView.swift */,
 				F7ED7EDB216B83D5007AB4D9 /* NCTrashListCell.xib */,
 				F7ED7EDD216B85DA007AB4D9 /* NCTrashListCell.swift */,
 				F7417DB4216CFE8E007D05F5 /* NCTrashGridCell.xib */,
@@ -3813,6 +3819,7 @@
 				F7D423471F0596AC009C9782 /* Reader-Mark-Y.png in Resources */,
 				F7D423431F0596AC009C9782 /* Reader-Export@3x.png in Resources */,
 				F7D4233C1F0596AC009C9782 /* Reader-Button-N@2x.png in Resources */,
+				F729B92B217A2E4E00FE2150 /* NCActionSheetHeaderView.xib in Resources */,
 				F7D423411F0596AC009C9782 /* Reader-Export.png in Resources */,
 				F77B0F481D118A16002130FE /* synchronized.gif in Resources */,
 				F7417DB5216CFE8E007D05F5 /* NCTrashGridCell.xib in Resources */,
@@ -4259,6 +4266,7 @@
 				F762CB171EACB66200B38484 /* XLFormRegexValidator.m in Sources */,
 				F758B44F212C516300515F55 /* Error.swift in Sources */,
 				F7622FBE2175FCC0000383FF /* ActionSheetCollectionItemAppearance.swift in Sources */,
+				F729B92D217A2F1B00FE2150 /* NCActionSheetHeaderView.swift in Sources */,
 				F73CC0691E813DFF006E3047 /* BKPasscodeDummyViewController.m in Sources */,
 				F762CB1A1EACB66200B38484 /* XLForm.m in Sources */,
 				F73B4EFC1F470D9100BBEE4B /* LangGreekModel.cpp in Sources */,

+ 17 - 0
iOSClient/Trash/NCActionSheetHeaderView.swift

@@ -0,0 +1,17 @@
+//
+//  NCTrashGridCell.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 08/10/2018.
+//  Copyright © 2018 TWS. All rights reserved.
+//
+
+import Foundation
+import UIKit
+
+class NCActionSheetHeaderView: UIView {
+    
+    @IBOutlet weak var imageItem: UIImageView!
+    @IBOutlet weak var label: UILabel!
+
+}

+ 51 - 0
iOSClient/Trash/NCActionSheetHeaderView.xib

@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
+    <device id="retina5_5" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <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"/>
+        <view contentMode="scaleToFill" id="I6b-nN-xlb" customClass="NCActionSheetHeaderView" customModule="Nextcloud" customModuleProvider="target">
+            <rect key="frame" x="0.0" y="0.0" width="414" height="50"/>
+            <autoresizingMask key="autoresizingMask"/>
+            <subviews>
+                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="lfq-lr-NgS" userLabel="ImageItem">
+                    <rect key="frame" x="0.0" y="0.0" width="50" height="50"/>
+                    <constraints>
+                        <constraint firstAttribute="height" constant="50" id="LyU-cM-aSJ"/>
+                        <constraint firstAttribute="width" constant="50" id="dY1-pJ-pdP"/>
+                    </constraints>
+                </imageView>
+                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="yAB-e1-3vF">
+                    <rect key="frame" x="55" y="0.0" width="354" height="50"/>
+                    <fontDescription key="fontDescription" type="system" pointSize="14"/>
+                    <nil key="textColor"/>
+                    <nil key="highlightedColor"/>
+                </label>
+            </subviews>
+            <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+            <constraints>
+                <constraint firstItem="yAB-e1-3vF" firstAttribute="leading" secondItem="lfq-lr-NgS" secondAttribute="trailing" constant="5" id="0ZQ-29-0WG"/>
+                <constraint firstItem="2A6-rU-2Mc" firstAttribute="bottom" secondItem="yAB-e1-3vF" secondAttribute="bottom" id="BjK-gV-vSx"/>
+                <constraint firstItem="lfq-lr-NgS" firstAttribute="leading" secondItem="2A6-rU-2Mc" secondAttribute="leading" id="cMS-FO-o0J"/>
+                <constraint firstItem="yAB-e1-3vF" firstAttribute="top" secondItem="2A6-rU-2Mc" secondAttribute="top" id="gFc-7X-Z4w"/>
+                <constraint firstItem="lfq-lr-NgS" firstAttribute="top" secondItem="2A6-rU-2Mc" secondAttribute="top" id="nlU-7A-uMz"/>
+                <constraint firstItem="2A6-rU-2Mc" firstAttribute="trailing" secondItem="yAB-e1-3vF" secondAttribute="trailing" constant="5" id="zl1-OY-Erp"/>
+            </constraints>
+            <freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
+            <viewLayoutGuide key="safeArea" id="2A6-rU-2Mc"/>
+            <connections>
+                <outlet property="imageItem" destination="lfq-lr-NgS" id="jW9-9z-oNq"/>
+                <outlet property="label" destination="yAB-e1-3vF" id="SiI-G5-9og"/>
+            </connections>
+            <point key="canvasLocation" x="-479.71014492753625" y="196.46739130434784"/>
+        </view>
+    </objects>
+</document>

+ 33 - 10
iOSClient/Trash/NCTrash.swift

@@ -233,7 +233,6 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
         if !isEditMode {
             var items = [ActionSheetItem]()
             
-            items.append(ActionSheetTitle(title: NSLocalizedString("_delete_selected_files_", comment: "")))
             items.append(ActionSheetDangerButton(title: NSLocalizedString("_delete_", comment: "")))
             items.append(ActionSheetCancelButton(title: NSLocalizedString("_cancel_", comment: "")))
             
@@ -242,6 +241,10 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
                 if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
             }
             
+            let headerView = actionSheetHeader(with: fileID)
+            actionSheet.headerView = headerView
+            actionSheet.headerView?.frame.size.height = 50
+            
             actionSheet.present(in: self, from: sender as! UIButton)
         } else {
             let buttonPosition:CGPoint = (sender as! UIButton).convert(CGPoint.zero, to:collectionView)
@@ -269,15 +272,9 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
                 if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
             }
             
-            /*
-            guard let tableTrash = NCManageDatabase.sharedInstance.getTrashItem(fileID: fileID) else {
-                return
-            }
-            if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconFileID(fileID, fileNameView: tableTrash.fileName)) {
-                actionSheet.headerView = UIImageView(image: UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(fileID, fileNameView: tableTrash.fileName)))
-                actionSheet.headerView?.frame.size.height = 150
-            }
-            */
+            let headerView = actionSheetHeader(with: fileID)
+            actionSheet.headerView = headerView
+            actionSheet.headerView?.frame.size.height = 50
             
             actionSheet.present(in: self, from: sender as! UIButton)
         } else {
@@ -732,6 +729,7 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
     }
     
     // MARK: UTILITY
+    
     private func cellBlurEffect(with frame: CGRect) -> UIView {
         
         let blurEffect = UIBlurEffect(style: .extraLight)
@@ -744,6 +742,31 @@ class NCTrash: UIViewController ,UICollectionViewDataSource, UICollectionViewDel
         return blurEffectView
     }
     
+    private func actionSheetHeader(with fileID: String) -> UIView? {
+        
+        var image: UIImage?
+
+        guard let tableTrash = NCManageDatabase.sharedInstance.getTrashItem(fileID: fileID) else {
+            return nil
+        }
+        
+        // Header
+        if tableTrash.iconName.count > 0 {
+            image = UIImage.init(named: tableTrash.iconName)
+        } else {
+            image = UIImage.init(named: "file")
+        }
+        if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconFileID(tableTrash.fileID, fileNameView: tableTrash.fileName)) {
+            image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(tableTrash.fileID, fileNameView: tableTrash.fileName))
+        }
+        
+        let headerView = UINib(nibName: "NCActionSheetHeaderView", bundle: nil).instantiate(withOwner: self, options: nil).first as! NCActionSheetHeaderView
+        headerView.imageItem.image = image
+        headerView.label.text = tableTrash.trashbinFileName
+        headerView.label.textColor = NCBrandColor.sharedInstance.icon
+        
+        return headerView
+    }
 }
 
 class ListLayout: UICollectionViewFlowLayout {