Browse Source

dev trash

Marino Faggiana 6 years ago
parent
commit
9223112271

+ 8 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -193,6 +193,8 @@
 		F73D71641F2674A400E233EB /* NCText.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F73D71631F2674A400E233EB /* NCText.storyboard */; };
 		F73F537F1E929C8500F8678D /* CCMore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73F537E1E929C8500F8678D /* CCMore.swift */; };
 		F7417DB3216CE925007D05F5 /* NCTrashHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7417DB2216CE925007D05F5 /* NCTrashHeader.swift */; };
+		F7417DB5216CFE8E007D05F5 /* NCTrashGridCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7417DB4216CFE8E007D05F5 /* NCTrashGridCell.xib */; };
+		F7417DB7216CFED0007D05F5 /* NCTrashGridCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7417DB6216CFED0007D05F5 /* NCTrashGridCell.swift */; };
 		F7434B3420E23FD700417916 /* NCDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB41ED5A87C00B7EAD4 /* NCDatabase.swift */; };
 		F7434B3620E23FE000417916 /* NCManageDatabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7BAADB51ED5A87C00B7EAD4 /* NCManageDatabase.swift */; };
 		F7434B3720E23FF200417916 /* NCUtility.swift in Sources */ = {isa = PBXBuildFile; fileRef = F70BFC7320E0FA7C00C67599 /* NCUtility.swift */; };
@@ -920,6 +922,8 @@
 		F73D71631F2674A400E233EB /* NCText.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = NCText.storyboard; sourceTree = "<group>"; };
 		F73F537E1E929C8500F8678D /* CCMore.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CCMore.swift; sourceTree = "<group>"; };
 		F7417DB2216CE925007D05F5 /* NCTrashHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCTrashHeader.swift; sourceTree = "<group>"; };
+		F7417DB4216CFE8E007D05F5 /* NCTrashGridCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCTrashGridCell.xib; sourceTree = "<group>"; };
+		F7417DB6216CFED0007D05F5 /* NCTrashGridCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NCTrashGridCell.swift; sourceTree = "<group>"; };
 		F7434B5F20E2440600417916 /* FileProviderExtension-Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FileProviderExtension-Bridging-Header.h"; sourceTree = "<group>"; };
 		F743B2C31C95BBE8006F5B4A /* CCShareInfoCMOC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCShareInfoCMOC.h; sourceTree = "<group>"; };
 		F743B2C41C95BBE8006F5B4A /* CCShareInfoCMOC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCShareInfoCMOC.m; sourceTree = "<group>"; };
@@ -2745,6 +2749,8 @@
 				F78F74352163781100C2ADAD /* NCTrash.swift */,
 				F7ED7EDB216B83D5007AB4D9 /* NCTrashListCell.xib */,
 				F7ED7EDD216B85DA007AB4D9 /* NCTrashListCell.swift */,
+				F7417DB4216CFE8E007D05F5 /* NCTrashGridCell.xib */,
+				F7417DB6216CFED0007D05F5 /* NCTrashGridCell.swift */,
 			);
 			path = Trash;
 			sourceTree = "<group>";
@@ -3743,6 +3749,7 @@
 				F7D4233C1F0596AC009C9782 /* Reader-Button-N@2x.png in Resources */,
 				F7D423411F0596AC009C9782 /* Reader-Export.png in Resources */,
 				F77B0F481D118A16002130FE /* synchronized.gif in Resources */,
+				F7417DB5216CFE8E007D05F5 /* NCTrashGridCell.xib in Resources */,
 				F7D4233E1F0596AC009C9782 /* Reader-Email.png in Resources */,
 				F762CB981EACB84400B38484 /* icon-info@2x.png in Resources */,
 				F7D423361F0596AC009C9782 /* AppIcon-167.png in Resources */,
@@ -4296,6 +4303,7 @@
 				F758B448212C516300515F55 /* Array+Utils.swift in Sources */,
 				F758B453212C516300515F55 /* ReviewViewController.swift in Sources */,
 				F7D424701F063B82009C9782 /* CTAssetsPickerNoAssetsView.m in Sources */,
+				F7417DB7216CFED0007D05F5 /* NCTrashGridCell.swift in Sources */,
 				F7D424591F063B82009C9782 /* PHImageManager+CTAssetsPickerController.m in Sources */,
 				F79630EE215527D40015EEA5 /* NCViewerMedia.swift in Sources */,
 				F7CA1ED620E7E3FE002CC65E /* CALayer+PKDownloadButtonAnimations.m in Sources */,

+ 10 - 0
iOSClient/Trash/NCTrash.storyboard

@@ -47,9 +47,18 @@
                                                 <constraint firstAttribute="height" constant="1" id="5Wf-y6-RCg"/>
                                             </constraints>
                                         </view>
+                                        <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="trashMore" translatesAutoresizingMaskIntoConstraints="NO" id="nkV-w3-rdJ" userLabel="switch">
+                                            <rect key="frame" x="10" y="2" width="26" height="26"/>
+                                            <constraints>
+                                                <constraint firstAttribute="width" constant="26" id="Ghm-eE-bE5"/>
+                                                <constraint firstAttribute="height" constant="26" id="gge-hx-5g4"/>
+                                            </constraints>
+                                        </imageView>
                                     </subviews>
                                     <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                     <constraints>
+                                        <constraint firstItem="nkV-w3-rdJ" firstAttribute="centerY" secondItem="AQ6-rS-Wxb" secondAttribute="centerY" id="1Rd-vo-7Qb"/>
+                                        <constraint firstItem="nkV-w3-rdJ" firstAttribute="leading" secondItem="AQ6-rS-Wxb" secondAttribute="leading" constant="10" id="Kdy-nZ-IGc"/>
                                         <constraint firstAttribute="trailing" secondItem="2CA-s4-Jqg" secondAttribute="trailing" constant="17" id="MqZ-eT-w2f"/>
                                         <constraint firstAttribute="trailing" secondItem="hva-qI-4Kl" secondAttribute="trailing" id="Nq8-X5-7Cq"/>
                                         <constraint firstItem="hva-qI-4Kl" firstAttribute="leading" secondItem="AQ6-rS-Wxb" secondAttribute="leading" id="a0G-P5-ZTU"/>
@@ -59,6 +68,7 @@
                                     <connections>
                                         <outlet property="separator" destination="hva-qI-4Kl" id="3Zy-ap-3kf"/>
                                         <outlet property="tapMore" destination="2CA-s4-Jqg" id="ZrC-Kw-hzQ"/>
+                                        <outlet property="tapSwitch" destination="nkV-w3-rdJ" id="FFs-uz-jv7"/>
                                     </connections>
                                 </collectionReusableView>
                                 <connections>

+ 50 - 3
iOSClient/Trash/NCTrash.swift

@@ -19,13 +19,16 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
     var itemHeight: CGFloat = 60
     var datasource = [tableTrash]()
 
-    var gridLayout: ListLayout!
+    var listLayout: ListLayout!
+    var gridLayout: GridLayout!
 
     override func viewDidLoad() {
         super.viewDidLoad()
         
         collectionView.register(UINib.init(nibName: "NCTrashListCell", bundle: nil), forCellWithReuseIdentifier: "cell")
-        collectionView.collectionViewLayout = ListLayout(itemHeight: 60)
+        
+        listLayout = ListLayout(itemHeight: 60)
+        collectionView.collectionViewLayout = listLayout
     }
     
     override func viewWillAppear(_ animated: Bool) {
@@ -62,6 +65,7 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
     }
     
     // MARK: tap
+    
     func tapRestoreItem(with fileID: String) {
         print("tap item restore")
     }
@@ -70,6 +74,10 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
         print("tap item more")
     }
     
+    func tapSwitchHeader() {
+        print("tap header switch")
+    }
+    
     func tapMoreHeader() {
         print("tap header more")
     }
@@ -77,6 +85,7 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
     // MARK: collectionView methods
     
     func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
+        
         let trashHeader = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "header", for: indexPath) as! NCTrashHeader
         trashHeader.delegate = self
         
@@ -132,6 +141,7 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
 class ListLayout: UICollectionViewFlowLayout {
     
     var itemHeight: CGFloat = 60
+    var headerHeight: CGFloat = 30
     
     init(itemHeight: CGFloat) {
         super.init()
@@ -141,7 +151,7 @@ class ListLayout: UICollectionViewFlowLayout {
         
         self.itemHeight = itemHeight
         self.scrollDirection = .vertical
-        self.headerReferenceSize = CGSize(width: 0, height: 30)
+        self.headerReferenceSize = CGSize(width: 0, height: headerHeight)
     }
     
     required init?(coder aDecoder: NSCoder) {
@@ -163,3 +173,40 @@ class ListLayout: UICollectionViewFlowLayout {
         }
     }
 }
+
+class GridLayout: UICollectionViewFlowLayout {
+    
+    var numberOfColumns: Int = 3
+    var headerHeight: CGFloat = 30
+    
+    init(numberOfColumns: Int) {
+        super.init()
+        
+        minimumLineSpacing = 1
+        minimumInteritemSpacing = 1
+        
+        self.numberOfColumns = numberOfColumns
+        self.scrollDirection = .vertical
+        self.headerReferenceSize = CGSize(width: 0, height: headerHeight)
+    }
+    
+    required init?(coder aDecoder: NSCoder) {
+        fatalError("init(coder:) has not been implemented")
+    }
+    
+    override var itemSize: CGSize {
+        get {
+            if let collectionView = collectionView {
+                let itemWidth: CGFloat = (collectionView.frame.width/CGFloat(self.numberOfColumns)) - self.minimumInteritemSpacing
+                let itemHeight: CGFloat = 100.0
+                return CGSize(width: itemWidth, height: itemHeight)
+            }
+            
+            // Default fallback
+            return CGSize(width: 100, height: 100)
+        }
+        set {
+            super.itemSize = newValue
+        }
+    }
+}

+ 67 - 0
iOSClient/Trash/NCTrashGridCell.swift

@@ -0,0 +1,67 @@
+//
+//  NCTrashGridCell.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 08/10/2018.
+//  Copyright © 2018 TWS. All rights reserved.
+//
+
+import Foundation
+import UIKit
+
+class NCTrashGridCell: UICollectionViewCell {
+    
+    @IBOutlet weak var imageItem: UIImageView!
+    
+    @IBOutlet weak var restore: UIImageView!
+    @IBOutlet weak var tapRestore: UIImageView!
+
+    @IBOutlet weak var more: UIImageView!
+    @IBOutlet weak var tapMore: UIImageView!
+
+    @IBOutlet weak var separator: UIView!
+
+    var delegate: NCTrashGridDelegate?
+    
+    var fileID = ""
+
+    override func awakeFromNib() {
+        super.awakeFromNib()
+       
+        restore.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "trashRestore"), multiplier: 2, color: NCBrandColor.sharedInstance.optionItem)
+        more.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "trashMore"), multiplier: 2, color: NCBrandColor.sharedInstance.optionItem)
+        
+        separator.backgroundColor = NCBrandColor.sharedInstance.seperator
+        
+        let tapGestureRestore = UITapGestureRecognizer(target: self, action: #selector(NCTrashListCell.tapRestore(sender:)))
+        addGestureRecognizer(tapGestureRestore)
+        tapGestureRestore.numberOfTapsRequired = 1
+        tapRestore.isUserInteractionEnabled = true
+        tapRestore.addGestureRecognizer(tapGestureRestore)
+        
+        let tapGestureMore = UITapGestureRecognizer(target: self, action: #selector(NCTrashListCell.tapMore(sender:)))
+        addGestureRecognizer(tapGestureMore)
+        tapGestureMore.numberOfTapsRequired = 1
+        tapMore.isUserInteractionEnabled = true
+        tapMore.addGestureRecognizer(tapGestureMore)
+    }
+    
+    public func configure(with fileID: String, image: UIImage?, title: String, info: String) {
+
+        self.fileID = fileID
+
+        imageItem.image = image
+    }
+    
+    @objc func tapRestore(sender: UITapGestureRecognizer) {
+        delegate?.tapRestoreItem(with: fileID)
+    }
+    @objc func tapMore(sender: UITapGestureRecognizer) {
+        delegate?.tapMoreItem(with: fileID)
+    }
+}
+
+protocol NCTrashGridDelegate {
+    func tapRestoreItem(with fileID: String)
+    func tapMoreItem(with fileID: String)
+}

+ 74 - 0
iOSClient/Trash/NCTrashGridCell.xib

@@ -0,0 +1,74 @@
+<?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="retina4_7" 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"/>
+        <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" id="vf1-Kf-9uL" customClass="NCTrashGridCell" customModule="Nextcloud" customModuleProvider="target">
+            <rect key="frame" x="0.0" y="0.0" width="220" height="280"/>
+            <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+            <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO">
+                <rect key="frame" x="0.0" y="0.0" width="220" height="280"/>
+                <autoresizingMask key="autoresizingMask"/>
+                <subviews>
+                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5Ci-V1-hf5" userLabel="ImageItem">
+                        <rect key="frame" x="0.0" y="0.0" width="220" height="220"/>
+                    </imageView>
+                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="u5S-jk-VdX" userLabel="tapRestore">
+                        <rect key="frame" x="0.0" y="220" width="60" height="60"/>
+                        <constraints>
+                            <constraint firstAttribute="height" constant="60" id="X2d-a1-gaa"/>
+                            <constraint firstAttribute="width" constant="60" id="kFt-s1-hBy"/>
+                        </constraints>
+                    </imageView>
+                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="b2F-OH-tLj" userLabel="restore">
+                        <rect key="frame" x="17" y="237" width="26" height="26"/>
+                        <constraints>
+                            <constraint firstAttribute="height" constant="26" id="L0E-5H-HIf"/>
+                            <constraint firstAttribute="width" constant="26" id="Qmu-32-cdJ"/>
+                        </constraints>
+                    </imageView>
+                    <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="BAZ-pD-XUh" userLabel="tapMore">
+                        <rect key="frame" x="160" y="220" width="60" height="60"/>
+                        <constraints>
+                            <constraint firstAttribute="width" constant="60" id="KeR-CV-it5"/>
+                            <constraint firstAttribute="height" constant="60" id="zCg-ZG-RPg"/>
+                        </constraints>
+                    </imageView>
+                    <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="3sA-NC-kIg" userLabel="More">
+                        <rect key="frame" x="177" y="237" width="26" height="26"/>
+                        <constraints>
+                            <constraint firstAttribute="width" constant="26" id="hoH-4o-Tff"/>
+                            <constraint firstAttribute="height" constant="26" id="vGK-h7-x3M"/>
+                        </constraints>
+                    </imageView>
+                </subviews>
+            </view>
+            <constraints>
+                <constraint firstItem="VXh-sQ-LeX" firstAttribute="bottom" secondItem="5Ci-V1-hf5" secondAttribute="bottom" constant="60" id="Gvf-MS-ZTo"/>
+                <constraint firstItem="u5S-jk-VdX" firstAttribute="top" secondItem="5Ci-V1-hf5" secondAttribute="bottom" id="Ik4-A3-18F"/>
+                <constraint firstItem="5Ci-V1-hf5" firstAttribute="top" secondItem="VXh-sQ-LeX" secondAttribute="top" id="Ouj-ZD-UFm"/>
+                <constraint firstItem="VXh-sQ-LeX" firstAttribute="trailing" secondItem="BAZ-pD-XUh" secondAttribute="trailing" id="R5r-VT-N0I"/>
+                <constraint firstItem="BAZ-pD-XUh" firstAttribute="top" secondItem="5Ci-V1-hf5" secondAttribute="bottom" id="X6x-hS-u2A"/>
+                <constraint firstItem="3sA-NC-kIg" firstAttribute="centerX" secondItem="BAZ-pD-XUh" secondAttribute="centerX" id="Xnl-Jn-Y8H"/>
+                <constraint firstItem="b2F-OH-tLj" firstAttribute="centerY" secondItem="u5S-jk-VdX" secondAttribute="centerY" id="ZW1-bm-DB8"/>
+                <constraint firstItem="b2F-OH-tLj" firstAttribute="centerX" secondItem="u5S-jk-VdX" secondAttribute="centerX" id="aVh-gg-Krs"/>
+                <constraint firstItem="VXh-sQ-LeX" firstAttribute="trailing" secondItem="5Ci-V1-hf5" secondAttribute="trailing" id="cHT-cP-NN6"/>
+                <constraint firstItem="u5S-jk-VdX" firstAttribute="leading" secondItem="VXh-sQ-LeX" secondAttribute="leading" id="fxs-Ju-143"/>
+                <constraint firstItem="3sA-NC-kIg" firstAttribute="centerY" secondItem="BAZ-pD-XUh" secondAttribute="centerY" id="k1J-aj-7W5"/>
+                <constraint firstItem="5Ci-V1-hf5" firstAttribute="leading" secondItem="VXh-sQ-LeX" secondAttribute="leading" id="qT3-WD-iTV"/>
+            </constraints>
+            <viewLayoutGuide key="safeArea" id="VXh-sQ-LeX"/>
+            <size key="customSize" width="220" height="267"/>
+            <point key="canvasLocation" x="88" y="132"/>
+        </collectionViewCell>
+    </objects>
+</document>

+ 11 - 0
iOSClient/Trash/NCTrashHeader.swift

@@ -10,6 +10,7 @@ import Foundation
 
 class NCTrashHeader: UICollectionReusableView {
     
+    @IBOutlet weak var tapSwitch: UIImageView!
     @IBOutlet weak var tapMore: UIImageView!
     @IBOutlet weak var separator: UIView!
     
@@ -22,6 +23,12 @@ class NCTrashHeader: UICollectionReusableView {
         
         separator.backgroundColor = NCBrandColor.sharedInstance.seperator
         
+        let tapGestureSwitch = UITapGestureRecognizer(target: self, action: #selector(NCTrashHeader.tapSwitch(sender:)))
+        addGestureRecognizer(tapGestureSwitch)
+        tapGestureSwitch.numberOfTapsRequired = 1
+        tapSwitch.isUserInteractionEnabled = true
+        tapSwitch.addGestureRecognizer(tapGestureSwitch)
+        
         let tapGestureMore = UITapGestureRecognizer(target: self, action: #selector(NCTrashHeader.tapMore(sender:)))
         addGestureRecognizer(tapGestureMore)
         tapGestureMore.numberOfTapsRequired = 1
@@ -29,12 +36,16 @@ class NCTrashHeader: UICollectionReusableView {
         tapMore.addGestureRecognizer(tapGestureMore)
     }
     
+    @objc func tapSwitch(sender: UITapGestureRecognizer) {
+        delegate?.tapSwitchHeader()
+    }
     @objc func tapMore(sender: UITapGestureRecognizer) {
         delegate?.tapMoreHeader()
     }
 }
 
 protocol NCTrashHeaderDelegate {
+    func tapSwitchHeader()
     func tapMoreHeader()
 }