Browse Source

Add new Select class

Marino Faggiana 6 years ago
parent
commit
897212771c

+ 16 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -516,6 +516,8 @@
 		F78F74362163781100C2ADAD /* NCTrash.swift in Sources */ = {isa = PBXBuildFile; fileRef = F78F74352163781100C2ADAD /* NCTrash.swift */; };
 		F790110E21415BF600D7B136 /* NCViewerRichdocument.swift in Sources */ = {isa = PBXBuildFile; fileRef = F790110D21415BF600D7B136 /* NCViewerRichdocument.swift */; };
 		F79630EE215527D40015EEA5 /* NCViewerMedia.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79630ED215527D40015EEA5 /* NCViewerMedia.swift */; };
+		F79A65C32191D90F00FF6DCC /* NCSelect.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F79A65C22191D90F00FF6DCC /* NCSelect.storyboard */; };
+		F79A65C62191D95E00FF6DCC /* NCSelect.swift in Sources */ = {isa = PBXBuildFile; fileRef = F79A65C52191D95E00FF6DCC /* NCSelect.swift */; };
 		F7A321551E9E2A070069AD1B /* CCFavorites.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A3214F1E9E2A070069AD1B /* CCFavorites.m */; };
 		F7A321651E9E37960069AD1B /* CCActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A321641E9E37960069AD1B /* CCActivity.m */; };
 		F7A3218C1E9E42B30069AD1B /* CCMenuAccount.m in Sources */ = {isa = PBXBuildFile; fileRef = F7A3218B1E9E42B30069AD1B /* CCMenuAccount.m */; };
@@ -1422,6 +1424,8 @@
 		F7956FCA1B4886E60085DEA3 /* CCUploadFromOtherUpp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCUploadFromOtherUpp.m; sourceTree = "<group>"; };
 		F7956FCB1B4886E60085DEA3 /* CCUploadFromOtherUpp.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = CCUploadFromOtherUpp.storyboard; sourceTree = "<group>"; };
 		F79630ED215527D40015EEA5 /* NCViewerMedia.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerMedia.swift; sourceTree = "<group>"; };
+		F79A65C22191D90F00FF6DCC /* NCSelect.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCSelect.storyboard; sourceTree = "<group>"; };
+		F79A65C52191D95E00FF6DCC /* NCSelect.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCSelect.swift; sourceTree = "<group>"; };
 		F7A3214E1E9E2A070069AD1B /* CCFavorites.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCFavorites.h; sourceTree = "<group>"; };
 		F7A3214F1E9E2A070069AD1B /* CCFavorites.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = CCFavorites.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
 		F7A321631E9E37960069AD1B /* CCActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCActivity.h; sourceTree = "<group>"; };
@@ -3002,6 +3006,15 @@
 			path = Viewer;
 			sourceTree = "<group>";
 		};
+		F79A65C12191D8DC00FF6DCC /* Select */ = {
+			isa = PBXGroup;
+			children = (
+				F79A65C22191D90F00FF6DCC /* NCSelect.storyboard */,
+				F79A65C52191D95E00FF6DCC /* NCSelect.swift */,
+			);
+			path = Select;
+			sourceTree = "<group>";
+		};
 		F7A3214D1E9E2A070069AD1B /* Favorites */ = {
 			isa = PBXGroup;
 			children = (
@@ -3530,6 +3543,7 @@
 				F7FCFFD51D70798C000E6E29 /* PeekPop */,
 				F7BE6E2A1D2D5C3B00106933 /* QuickActions */,
 				F7FE125B1BAC03FB0041924B /* Security */,
+				F79A65C12191D8DC00FF6DCC /* Select */,
 				F7ACE4281BAC0268006C0017 /* Settings */,
 				F728CE741BF6322C00E69702 /* Share */,
 				F758B41E212C516300515F55 /* Scan */,
@@ -3895,6 +3909,7 @@
 				F7B1FBC41E72E3D1001781FE /* Media.xcassets in Resources */,
 				F78F74342163757000C2ADAD /* NCTrash.storyboard in Resources */,
 				F7D4234E1F0596AC009C9782 /* Reader-Thumbs@2x.png in Resources */,
+				F79A65C32191D90F00FF6DCC /* NCSelect.storyboard in Resources */,
 				F77B0F2F1D118A16002130FE /* CCMove.storyboard in Resources */,
 				F7F54D001E5B14C700E19C62 /* UIBarButtonItemGrid.png in Resources */,
 				F7F54CFE1E5B14C700E19C62 /* UIBarButtonItemArrowRight@2x.png in Resources */,
@@ -4476,6 +4491,7 @@
 				F7622FBB2175FCC0000383FF /* ActionSheetSelectItemAppearance.swift in Sources */,
 				F7622FB12175FCC0000383FF /* ActionSheetPopoverApperance.swift in Sources */,
 				F712ACA22175E56F0061158E /* CTAssetsGridSelectedView.m in Sources */,
+				F79A65C62191D95E00FF6DCC /* NCSelect.swift in Sources */,
 				F70CAE3A1F8CF31A008125FD /* NCEndToEndEncryption.m in Sources */,
 				F73B4F0C1F470D9100BBEE4B /* nsHebrewProber.cpp in Sources */,
 				F762CAFB1EACB66200B38484 /* XLFormDatePickerCell.m in Sources */,

+ 4 - 96
iOSClient/Offline/NCOffline.storyboard

@@ -1,11 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14313.18" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="EFX-fO-Oip">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="EFX-fO-Oip">
     <device id="retina5_9" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
         <deployment identifier="iOS"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14283.14"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
@@ -23,99 +23,11 @@
                                 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                                 <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="fF1-wd-0xN">
                                     <size key="itemSize" width="0.0" height="0.0"/>
-                                    <size key="headerReferenceSize" width="50" height="50"/>
-                                    <size key="footerReferenceSize" width="50" height="50"/>
+                                    <size key="headerReferenceSize" width="0.0" height="0.0"/>
+                                    <size key="footerReferenceSize" width="0.0" height="0.0"/>
                                     <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
                                 </collectionViewFlowLayout>
                                 <cells/>
-                                <collectionReusableView key="sectionHeaderView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" reuseIdentifier="headerMenu" id="AQ6-rS-Wxb" customClass="NCOfflineHeaderMenu" customModule="Nextcloud" customModuleProvider="target">
-                                    <rect key="frame" x="0.0" y="0.0" width="375" height="50"/>
-                                    <autoresizingMask key="autoresizingMask"/>
-                                    <subviews>
-                                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="hva-qI-4Kl" userLabel="Separator">
-                                            <rect key="frame" x="0.0" y="48" width="375" height="1"/>
-                                            <color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                            <color key="tintColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                            <constraints>
-                                                <constraint firstAttribute="height" constant="1" id="5Wf-y6-RCg"/>
-                                            </constraints>
-                                        </view>
-                                        <button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="gBv-v2-Zec" userLabel="buttonSwitch">
-                                            <rect key="frame" x="12" y="12.666666666666664" width="25" height="25"/>
-                                            <constraints>
-                                                <constraint firstAttribute="height" constant="25" id="0mp-3J-eb3"/>
-                                                <constraint firstAttribute="width" constant="25" id="DxY-uU-Znk"/>
-                                            </constraints>
-                                            <state key="normal" image="switchList"/>
-                                            <connections>
-                                                <action selector="touchUpInsideSwitch:" destination="AQ6-rS-Wxb" eventType="touchUpInside" id="wkS-i9-OsH"/>
-                                            </connections>
-                                        </button>
-                                        <button hidden="YES" opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qqn-cs-A3P" userLabel="buttonSwitch">
-                                            <rect key="frame" x="338" y="12.666666666666664" width="25" height="25"/>
-                                            <constraints>
-                                                <constraint firstAttribute="width" constant="25" id="2OK-Fr-IGe"/>
-                                                <constraint firstAttribute="height" constant="25" id="HAe-ET-Q3h"/>
-                                            </constraints>
-                                            <state key="normal" image="moreBig"/>
-                                            <connections>
-                                                <action selector="touchUpInsideMore:" destination="AQ6-rS-Wxb" eventType="touchUpInside" id="F2B-LW-hs5"/>
-                                            </connections>
-                                        </button>
-                                        <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0q4-Qd-ic4" userLabel="buttonOrder">
-                                            <rect key="frame" x="55" y="11" width="230" height="28"/>
-                                            <constraints>
-                                                <constraint firstAttribute="width" constant="230" id="n74-Xy-Qpd"/>
-                                            </constraints>
-                                            <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                                            <state key="normal" title="Sort by name (from A to Z)">
-                                                <color key="titleColor" cocoaTouchSystemColor="darkTextColor"/>
-                                            </state>
-                                            <connections>
-                                                <action selector="touchUpInsideOrder:" destination="AQ6-rS-Wxb" eventType="touchUpInside" id="bwn-i4-jiF"/>
-                                            </connections>
-                                        </button>
-                                    </subviews>
-                                    <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                                    <constraints>
-                                        <constraint firstItem="0q4-Qd-ic4" firstAttribute="leading" secondItem="gBv-v2-Zec" secondAttribute="trailing" constant="18" id="86t-HS-JzM"/>
-                                        <constraint firstItem="0q4-Qd-ic4" firstAttribute="centerY" secondItem="AQ6-rS-Wxb" secondAttribute="centerY" id="APZ-gg-uLs"/>
-                                        <constraint firstItem="Qqn-cs-A3P" firstAttribute="centerY" secondItem="AQ6-rS-Wxb" secondAttribute="centerY" id="Cgb-zq-vQE"/>
-                                        <constraint firstAttribute="trailing" secondItem="Qqn-cs-A3P" secondAttribute="trailing" constant="12" id="FJp-2Z-jvg"/>
-                                        <constraint firstItem="gBv-v2-Zec" firstAttribute="leading" secondItem="AQ6-rS-Wxb" secondAttribute="leading" constant="12" id="Glf-95-Dxh"/>
-                                        <constraint firstAttribute="trailing" secondItem="hva-qI-4Kl" secondAttribute="trailing" id="Nq8-X5-7Cq"/>
-                                        <constraint firstItem="gBv-v2-Zec" firstAttribute="centerY" secondItem="AQ6-rS-Wxb" secondAttribute="centerY" id="OEU-E8-r92"/>
-                                        <constraint firstItem="hva-qI-4Kl" firstAttribute="leading" secondItem="AQ6-rS-Wxb" secondAttribute="leading" id="a0G-P5-ZTU"/>
-                                        <constraint firstAttribute="bottom" secondItem="hva-qI-4Kl" secondAttribute="bottom" constant="1" id="ixp-nm-HUt"/>
-                                    </constraints>
-                                    <connections>
-                                        <outlet property="buttonMore" destination="Qqn-cs-A3P" id="9hu-4g-sm5"/>
-                                        <outlet property="buttonOrder" destination="0q4-Qd-ic4" id="A8C-el-YQr"/>
-                                        <outlet property="buttonOrderWidthConstraint" destination="n74-Xy-Qpd" id="1yu-SR-FZN"/>
-                                        <outlet property="buttonSwitch" destination="gBv-v2-Zec" id="yBa-g0-ChU"/>
-                                        <outlet property="separator" destination="hva-qI-4Kl" id="rP4-bg-nt9"/>
-                                    </connections>
-                                </collectionReusableView>
-                                <collectionReusableView key="sectionFooterView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" insetsLayoutMarginsFromSafeArea="NO" reuseIdentifier="footerMenu" id="KIO-gv-emq" customClass="NCOfflineFooterMenu" customModule="Nextcloud" customModuleProvider="target">
-                                    <rect key="frame" x="0.0" y="50" width="375" height="50"/>
-                                    <autoresizingMask key="autoresizingMask"/>
-                                    <subviews>
-                                        <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5ZS-UE-CHl" userLabel="LabelFooter">
-                                            <rect key="frame" x="10" y="17" width="355" height="16"/>
-                                            <fontDescription key="fontDescription" type="system" pointSize="13"/>
-                                            <nil key="textColor"/>
-                                            <nil key="highlightedColor"/>
-                                        </label>
-                                    </subviews>
-                                    <constraints>
-                                        <constraint firstItem="5ZS-UE-CHl" firstAttribute="centerY" secondItem="KIO-gv-emq" secondAttribute="centerY" id="5Ip-b9-luC"/>
-                                        <constraint firstAttribute="trailing" secondItem="5ZS-UE-CHl" secondAttribute="trailing" constant="10" id="6rY-5r-1Mf"/>
-                                        <constraint firstItem="5ZS-UE-CHl" firstAttribute="leading" secondItem="KIO-gv-emq" secondAttribute="leading" constant="10" id="JLx-VS-sTx"/>
-                                    </constraints>
-                                    <connections>
-                                        <outlet property="labelFooter" destination="5ZS-UE-CHl" id="zcJ-1o-Jtw"/>
-                                    </connections>
-                                </collectionReusableView>
                                 <connections>
                                     <outlet property="dataSource" destination="EFX-fO-Oip" id="2On-qP-zuG"/>
                                     <outlet property="delegate" destination="EFX-fO-Oip" id="s3n-CL-8X2"/>
@@ -149,8 +61,4 @@
             <point key="canvasLocation" x="1080" y="228"/>
         </scene>
     </scenes>
-    <resources>
-        <image name="moreBig" width="120" height="120"/>
-        <image name="switchList" width="25" height="25"/>
-    </resources>
 </document>

+ 74 - 0
iOSClient/Select/NCSelect.storyboard

@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="EAU-PF-EEd">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
+        <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <scenes>
+        <!--Select-->
+        <scene sceneID="d4X-6u-1HM">
+            <objects>
+                <viewController id="VYq-xA-D35" customClass="NCSelect" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                    <view key="view" contentMode="scaleToFill" id="MaM-Im-7sc">
+                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" translatesAutoresizingMaskIntoConstraints="NO" id="0HI-k1-SD0">
+                                <rect key="frame" x="0.0" y="64" width="375" height="603"/>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                                <collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="0.0" minimumInteritemSpacing="0.0" id="D7P-75-aB1">
+                                    <size key="itemSize" width="0.0" height="0.0"/>
+                                    <size key="headerReferenceSize" width="0.0" height="0.0"/>
+                                    <size key="footerReferenceSize" width="0.0" height="0.0"/>
+                                    <inset key="sectionInset" minX="0.0" minY="0.0" maxX="0.0" maxY="0.0"/>
+                                </collectionViewFlowLayout>
+                                <cells/>
+                                <connections>
+                                    <outlet property="dataSource" destination="VYq-xA-D35" id="knG-ac-buS"/>
+                                    <outlet property="delegate" destination="VYq-xA-D35" id="EXB-bA-tje"/>
+                                </connections>
+                            </collectionView>
+                        </subviews>
+                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+                        <constraints>
+                            <constraint firstItem="vaA-85-uNN" firstAttribute="trailing" secondItem="0HI-k1-SD0" secondAttribute="trailing" id="Dk4-c3-6wl"/>
+                            <constraint firstItem="0HI-k1-SD0" firstAttribute="top" secondItem="vaA-85-uNN" secondAttribute="top" id="GKj-QM-2Yy"/>
+                            <constraint firstItem="vaA-85-uNN" firstAttribute="bottom" secondItem="0HI-k1-SD0" secondAttribute="bottom" id="rfT-Rj-oeD"/>
+                            <constraint firstItem="0HI-k1-SD0" firstAttribute="leading" secondItem="vaA-85-uNN" secondAttribute="leading" id="uLL-RT-YFO"/>
+                        </constraints>
+                        <viewLayoutGuide key="safeArea" id="vaA-85-uNN"/>
+                    </view>
+                    <navigationItem key="navigationItem" id="N5K-De-4CP"/>
+                    <connections>
+                        <outlet property="collectionView" destination="0HI-k1-SD0" id="xme-mG-bnz"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="vH8-UY-9MN" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="1196" y="228.93553223388307"/>
+        </scene>
+        <!--Navigation Controller-->
+        <scene sceneID="KP9-Ja-zsS">
+            <objects>
+                <navigationController automaticallyAdjustsScrollViewInsets="NO" id="EAU-PF-EEd" sceneMemberID="viewController">
+                    <toolbarItems/>
+                    <navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="OMR-Ah-U1w">
+                        <rect key="frame" x="0.0" y="20" width="375" height="44"/>
+                        <autoresizingMask key="autoresizingMask"/>
+                    </navigationBar>
+                    <nil name="viewControllers"/>
+                    <connections>
+                        <segue destination="VYq-xA-D35" kind="relationship" relationship="rootViewController" id="dZh-kL-x5f"/>
+                    </connections>
+                </navigationController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="rcK-ZU-zTS" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="256.80000000000001" y="228.93553223388307"/>
+        </scene>
+    </scenes>
+</document>

+ 756 - 0
iOSClient/Select/NCSelect.swift

@@ -0,0 +1,756 @@
+//
+//  NCSelect.swift
+//  Nextcloud
+//
+//  Created by Marino Faggiana on 06/11/2018.
+//  Copyright © 2018 Marino Faggiana. All rights reserved.
+//
+//  Author Marino Faggiana <m.faggiana@twsweb.it>
+//
+//  This program is free software: you can redistribute it and/or modify
+//  it under the terms of the GNU General Public License as published by
+//  the Free Software Foundation, either version 3 of the License, or
+//  (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+//
+//  You should have received a copy of the GNU General Public License
+//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+
+import Foundation
+
+class NCSelect: UIViewController ,UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout, UIGestureRecognizerDelegate, NCListCellDelegate, NCGridCellDelegate, NCSectionHeaderMenuDelegate, DropdownMenuDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate  {
+    
+    @IBOutlet fileprivate weak var collectionView: UICollectionView!
+    
+    var titleCurrentFolder = NSLocalizedString("_select_", comment: "")
+    var directoryID = ""
+    
+    private let appDelegate = UIApplication.shared.delegate as! AppDelegate
+    
+    private var isEditMode = false
+    private var selectFileID = [String]()
+    
+    private var sectionDatasource = CCSectionDataSourceMetadata()
+    
+    private var datasourceSorted = ""
+    private var datasourceAscending = true
+    private var datasourceGroupBy = ""
+    private var datasourceDirectoryOnTop = false
+    
+    private var listLayout: NCListLayout!
+    private var gridLayout: NCGridLayout!
+    
+    private var actionSheet: ActionSheet?
+    
+    private let headerMenuHeight: CGFloat = 50
+    private let sectionHeaderHeight: CGFloat = 20
+    private let footerHeight: CGFloat = 50
+    
+    private let refreshControl = UIRefreshControl()
+    
+    private var metadataSelect = tableMetadata()
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        
+        // Cell
+        collectionView.register(UINib.init(nibName: "NCListCell", bundle: nil), forCellWithReuseIdentifier: "listCell")
+        collectionView.register(UINib.init(nibName: "NCGridCell", bundle: nil), forCellWithReuseIdentifier: "gridCell")
+        
+        // Header
+        collectionView.register(UINib.init(nibName: "NCSectionHeaderMenu", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeaderMenu")
+        collectionView.register(UINib.init(nibName: "NCSectionHeader", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withReuseIdentifier: "sectionHeader")
+        
+        // Footer
+        collectionView.register(UINib.init(nibName: "NCSectionFooter", bundle: nil), forSupplementaryViewOfKind: UICollectionView.elementKindSectionFooter, withReuseIdentifier: "sectionFooter")
+        
+        collectionView.alwaysBounceVertical = true
+        
+        listLayout = NCListLayout()
+        gridLayout = NCGridLayout()
+        
+        // Add Refresh Control
+        if #available(iOS 10.0, *) {
+            collectionView.refreshControl = refreshControl
+        } else {
+            collectionView.addSubview(refreshControl)
+        }
+        
+        // Configure Refresh Control
+        refreshControl.tintColor = NCBrandColor.sharedInstance.brandText
+        refreshControl.backgroundColor = NCBrandColor.sharedInstance.brand
+        refreshControl.addTarget(self, action: #selector(loadDatasource), for: .valueChanged)
+        
+        // empty Data Source
+        self.collectionView.emptyDataSetDelegate = self;
+        self.collectionView.emptyDataSetSource = self;
+    }
+    
+    override func viewWillAppear(_ animated: Bool) {
+        super.viewWillAppear(animated)
+        
+        // Color
+        appDelegate.aspectNavigationControllerBar(self.navigationController?.navigationBar, online: appDelegate.reachability.isReachable(), hidden: false)
+        appDelegate.aspectTabBar(self.tabBarController?.tabBar, hidden: false)
+        
+        self.navigationItem.title = titleCurrentFolder
+        
+        datasourceSorted = CCUtility.getOrderSettings()
+        datasourceAscending = CCUtility.getAscendingSettings()
+        datasourceGroupBy = CCUtility.getGroupBySettings()
+        datasourceDirectoryOnTop = CCUtility.getDirectoryOnTop()
+        
+        if CCUtility.getLayoutSelect() == "list" {
+            collectionView.collectionViewLayout = listLayout
+        } else {
+            collectionView.collectionViewLayout = gridLayout
+        }
+        
+        loadDatasource()
+    }
+    
+    override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
+        super.viewWillTransition(to: size, with: coordinator)
+        
+        coordinator.animate(alongsideTransition: nil) { _ in
+            self.collectionView.collectionViewLayout.invalidateLayout()
+            self.actionSheet?.viewDidLayoutSubviews()
+        }
+    }
+    
+    // MARK: DZNEmpty
+    
+    func backgroundColor(forEmptyDataSet scrollView: UIScrollView) -> UIColor? {
+        return NCBrandColor.sharedInstance.backgroundView
+    }
+    
+    func image(forEmptyDataSet scrollView: UIScrollView) -> UIImage? {
+        return CCGraphics.changeThemingColorImage(UIImage.init(named: "filesNoFiles"), multiplier: 2, color: NCBrandColor.sharedInstance.brandElement)
+    }
+    
+    func title(forEmptyDataSet scrollView: UIScrollView) -> NSAttributedString? {
+        let text = "\n"+NSLocalizedString("_files_no_files_", comment: "")
+        let attributes = [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 20), NSAttributedString.Key.foregroundColor: UIColor.lightGray]
+        return NSAttributedString.init(string: text, attributes: attributes)
+    }
+    
+    func emptyDataSetShouldAllowScroll(_ scrollView: UIScrollView) -> Bool {
+        return true
+    }
+    
+    // MARK: TAP EVENT
+    
+    func tapSwitchHeader(sender: Any) {
+        
+        if collectionView.collectionViewLayout == gridLayout {
+            // list layout
+            UIView.animate(withDuration: 0.0, animations: {
+                self.collectionView.collectionViewLayout.invalidateLayout()
+                self.collectionView.setCollectionViewLayout(self.listLayout, animated: false, completion: { (_) in
+                    self.collectionView.reloadData()
+                    self.collectionView.setContentOffset(CGPoint(x:0,y:0), animated: false)
+                })
+            })
+            CCUtility.setLayoutSelect("list")
+        } else {
+            // grid layout
+            UIView.animate(withDuration: 0.0, animations: {
+                self.collectionView.collectionViewLayout.invalidateLayout()
+                self.collectionView.setCollectionViewLayout(self.gridLayout, animated: false, completion: { (_) in
+                    self.collectionView.reloadData()
+                    self.collectionView.setContentOffset(CGPoint(x:0,y:0), animated: false)
+                })
+            })
+            CCUtility.setLayoutSelect("grid")
+        }
+    }
+    
+    func tapOrderHeader(sender: Any) {
+        
+        var menuView: DropdownMenu?
+        var selectedIndexPath = [IndexPath()]
+        
+        let item1 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "sortFileNameAZ"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_order_by_name_a_z_", comment: ""))
+        let item2 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "sortFileNameZA"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_order_by_name_z_a_", comment: ""))
+        let item3 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "sortDateMoreRecent"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_order_by_date_more_recent_", comment: ""))
+        let item4 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "sortDateLessRecent"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_order_by_date_less_recent_", comment: ""))
+        let item5 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "sortSmallest"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_order_by_size_smallest_", comment: ""))
+        let item6 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "sortLargest"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_order_by_size_largest_", comment: ""))
+        
+        switch datasourceSorted {
+        case "fileName":
+            if datasourceAscending == true { item1.style = .highlight; selectedIndexPath.append(IndexPath(row: 0, section: 0)) }
+            if datasourceAscending == false { item2.style = .highlight; selectedIndexPath.append(IndexPath(row: 1, section: 0)) }
+        case "date":
+            if datasourceAscending == false { item3.style = .highlight; selectedIndexPath.append(IndexPath(row: 2, section: 0)) }
+            if datasourceAscending == true { item4.style = .highlight; selectedIndexPath.append(IndexPath(row: 3, section: 0)) }
+        case "size":
+            if datasourceAscending == true { item5.style = .highlight; selectedIndexPath.append(IndexPath(row: 4, section: 0)) }
+            if datasourceAscending == false { item6.style = .highlight; selectedIndexPath.append(IndexPath(row: 5, section: 0)) }
+        default:
+            ()
+        }
+        
+        let item7 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "MenuGroupByAlphabetic"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_group_alphabetic_no_", comment: ""))
+        let item8 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "MenuGroupByFile"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_group_typefile_no_", comment: ""))
+        let item9 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "MenuGroupByDate"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_group_date_no_", comment: ""))
+        
+        switch datasourceGroupBy {
+        case "alphabetic":
+            item7.style = .highlight; selectedIndexPath.append(IndexPath(row: 0, section: 1))
+        case "typefile":
+            item8.style = .highlight; selectedIndexPath.append(IndexPath(row: 1, section: 1))
+        case "date":
+            item9.style = .highlight; selectedIndexPath.append(IndexPath(row: 2, section: 1))
+        default:
+            ()
+        }
+        
+        let item10 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "foldersOnTop"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title: NSLocalizedString("_directory_on_top_no_", comment: ""))
+        
+        if datasourceDirectoryOnTop {
+            item10.style = .highlight; selectedIndexPath.append(IndexPath(row: 0, section: 2))
+        }
+        
+        let sectionOrder = DropdownSection(sectionIdentifier: "", items: [item1, item2, item3, item4, item5, item6])
+        let sectionGroupBy = DropdownSection(sectionIdentifier: "", items: [item7, item8, item9])
+        let sectionFolderOnTop = DropdownSection(sectionIdentifier: "", items: [item10])
+        
+        menuView = DropdownMenu(navigationController: self.navigationController!, sections: [sectionOrder, sectionGroupBy, sectionFolderOnTop], selectedIndexPath: selectedIndexPath)
+        menuView?.token = "tapOrderHeaderMenu"
+        menuView?.delegate = self
+        menuView?.rowHeight = 45
+        menuView?.sectionHeaderHeight = 8
+        menuView?.highlightColor = NCBrandColor.sharedInstance.brand
+        menuView?.tableView.alwaysBounceVertical = false
+        menuView?.tableViewBackgroundColor = UIColor.white
+        
+        let header = (sender as? UIButton)?.superview
+        let headerRect = self.collectionView.convert(header!.bounds, from: self.view)
+        let menuOffsetY =  headerRect.height - headerRect.origin.y - 2
+        menuView?.topOffsetY = CGFloat(menuOffsetY)
+        
+        menuView?.showMenu()
+    }
+    
+    func tapMoreHeader(sender: Any) {
+        
+    }
+    
+    func tapMoreItem(with fileID: String, sender: Any) {
+        tapMoreGridItem(with: fileID, sender: sender)
+    }
+    
+    func tapMoreGridItem(with fileID: String, sender: Any) {
+        
+        guard let metadata = NCManageDatabase.sharedInstance.getMetadata(predicate: NSPredicate(format: "fileID == %@", fileID)) else {
+            return
+        }
+        guard let serverUrl = NCManageDatabase.sharedInstance.getServerUrl(metadata.directoryID) else {
+            return
+        }
+        
+        if !isEditMode {
+            
+            var items = [ActionSheetItem]()
+            let appearanceDelete = ActionSheetItemAppearance.init()
+            appearanceDelete.textColor = UIColor.red
+            
+            if (metadata.directory == false || serverUrl == CCUtility.getHomeServerUrlActiveUrl(appDelegate.activeUrl)) {
+                items.append(ActionSheetItem(title: NSLocalizedString("_remove_available_offline_", comment: ""), value: 0, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "offline"), multiplier: 2, color: NCBrandColor.sharedInstance.icon)))
+            }
+            items.append(ActionSheetItem(title: NSLocalizedString("_share_", comment: ""), value: 1, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), multiplier: 2, color: NCBrandColor.sharedInstance.icon)))
+            
+            let itemDelete = ActionSheetItem(title: NSLocalizedString("_delete_", comment: ""), value: 2, image: CCGraphics.changeThemingColorImage(UIImage.init(named: "trash"), multiplier: 2, color: UIColor.red))
+            itemDelete.customAppearance = appearanceDelete
+            items.append(itemDelete)
+            items.append(ActionSheetCancelButton(title: NSLocalizedString("_cancel_", comment: "")))
+            
+            actionSheet = ActionSheet(items: items) { sheet, item in
+                if item.value as? Int == 0 {
+                    if metadata.directory {
+                        NCManageDatabase.sharedInstance.setDirectory(serverUrl: CCUtility.stringAppendServerUrl(serverUrl, addFileName: metadata.fileName)!, offline: false)
+                    } else {
+                        NCManageDatabase.sharedInstance.setLocalFile(fileID: metadata.fileID, offline: false)
+                    }
+                    self.loadDatasource()
+                }
+                if item.value as? Int == 1 { self.appDelegate.activeMain.openWindowShare(metadata) }
+                if item.value as? Int == 2 { self.deleteItem(with: metadata, sender: sender) }
+                if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
+            }
+            
+            let headerView = actionSheetHeader(with: metadata)
+            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)
+            let indexPath = collectionView.indexPathForItem(at: buttonPosition)
+            collectionView(self.collectionView, didSelectItemAt: indexPath!)
+        }
+    }
+    
+    // MARK: DROP-DOWN-MENU
+    
+    func dropdownMenu(_ dropdownMenu: DropdownMenu, didSelectRowAt indexPath: IndexPath) {
+        
+        if dropdownMenu.token == "tapOrderHeaderMenu" {
+            
+            switch indexPath.section {
+                
+            case 0: switch indexPath.row {
+                
+            case 0: CCUtility.setOrderSettings("fileName"); CCUtility.setAscendingSettings(true)
+            case 1: CCUtility.setOrderSettings("fileName"); CCUtility.setAscendingSettings(false)
+                
+            case 2: CCUtility.setOrderSettings("date"); CCUtility.setAscendingSettings(false)
+            case 3: CCUtility.setOrderSettings("date"); CCUtility.setAscendingSettings(true)
+                
+            case 4: CCUtility.setOrderSettings("size"); CCUtility.setAscendingSettings(true)
+            case 5: CCUtility.setOrderSettings("size"); CCUtility.setAscendingSettings(false)
+                
+            default: ()
+                }
+            case 1: switch indexPath.row {
+                
+            case 0:
+                if datasourceGroupBy == "alphabetic" {
+                    CCUtility.setGroupBySettings("none")
+                } else {
+                    CCUtility.setGroupBySettings("alphabetic")
+                }
+            case 1:
+                if datasourceGroupBy == "typefile" {
+                    CCUtility.setGroupBySettings("none")
+                } else {
+                    CCUtility.setGroupBySettings("typefile")
+                }
+            case 2:
+                if datasourceGroupBy == "date" {
+                    CCUtility.setGroupBySettings("none")
+                } else {
+                    CCUtility.setGroupBySettings("date")
+                }
+                
+            default: ()
+                }
+            case 2: if datasourceDirectoryOnTop {
+                CCUtility.setDirectoryOnTop(false)
+            } else {
+                CCUtility.setDirectoryOnTop(true)
+                }
+            default: ()
+            }
+            
+            datasourceAscending = CCUtility.getAscendingSettings()
+            datasourceSorted = CCUtility.getOrderSettings()
+            datasourceGroupBy = CCUtility.getGroupBySettings()
+            datasourceDirectoryOnTop = CCUtility.getDirectoryOnTop()
+            
+            loadDatasource()
+        }
+        
+        if dropdownMenu.token == "tapMoreHeaderMenu" {
+            
+        }
+        
+        if dropdownMenu.token == "tapMoreHeaderMenuSelect" {
+            
+        }
+    }
+    
+    // MARK: NC API
+    
+    func downloadThumbnail(with tableMetadata: tableMetadata, indexPath: IndexPath) {
+        
+        let ocNetworking = OCnetworking.init(delegate: self, metadataNet: nil, withUser: appDelegate.activeUser, withUserID: appDelegate.activeUserID, withPassword: appDelegate.activePassword, withUrl: appDelegate.activeUrl)
+        
+        ocNetworking?.downloadPreviewTrash(withFileID: tableMetadata.fileID, fileName: tableMetadata.fileName, completion: { (message, errorCode) in
+            if errorCode == 0 && CCUtility.fileProviderStorageIconExists(tableMetadata.fileID, fileNameView: tableMetadata.fileName) {
+                self.collectionView.reloadItems(at: [indexPath])
+            }
+        })
+    }
+    
+    func deleteItem(with metadata: tableMetadata, sender: Any) {
+        
+        var items = [ActionSheetItem]()
+        
+        guard let serverUrl = NCManageDatabase.sharedInstance.getServerUrl(metadata.directoryID) else {
+            return
+        }
+        guard let tableDirectory = NCManageDatabase.sharedInstance.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == serverUrl", appDelegate.activeAccount, serverUrl)) else {
+            return
+        }
+        
+        items.append(ActionSheetDangerButton(title: NSLocalizedString("_delete_", comment: "")))
+        items.append(ActionSheetCancelButton(title: NSLocalizedString("_cancel_", comment: "")))
+        
+        actionSheet = ActionSheet(items: items) { sheet, item in
+            if item is ActionSheetDangerButton {
+                NCMainCommon.sharedInstance.deleteFile(metadatas: [metadata], e2ee: tableDirectory.e2eEncrypted, serverUrl: serverUrl, folderFileID: tableDirectory.fileID) { (errorCode, message) in
+                    self.loadDatasource()
+                }
+            }
+            if item is ActionSheetCancelButton { print("Cancel buttons has the value `true`") }
+        }
+        
+        let headerView = actionSheetHeader(with: metadata)
+        actionSheet?.headerView = headerView
+        actionSheet?.headerView?.frame.size.height = 50
+        
+        actionSheet?.present(in: self, from: sender as! UIButton)
+    }
+    
+    // MARK: DATASOURCE
+    @objc func loadDatasource() {
+        
+        var fileIDs = [String]()
+        sectionDatasource = CCSectionDataSourceMetadata()
+        
+        if directoryID == "" {
+            
+            if let directories = NCManageDatabase.sharedInstance.getTablesDirectory(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "serverUrl", ascending: true) {
+                for directory: tableDirectory in directories {
+                    fileIDs.append(directory.fileID)
+                }
+            }
+            
+            if let files = NCManageDatabase.sharedInstance.getTableLocalFiles(predicate: NSPredicate(format: "account == %@ AND offline == true", appDelegate.activeAccount), sorted: "fileName", ascending: true) {
+                for file: tableLocalFile in files {
+                    fileIDs.append(file.fileID)
+                }
+            }
+            
+            if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND fileID IN %@", appDelegate.activeAccount, fileIDs), sorted: datasourceSorted, ascending: datasourceAscending)  {
+                
+                sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: datasourceGroupBy, filterFileID: nil, filterTypeFileImage: false, filterTypeFileVideo: false, activeAccount: appDelegate.activeAccount)
+            }
+            
+        } else {
+            
+            if let metadatas = NCManageDatabase.sharedInstance.getMetadatas(predicate: NSPredicate(format: "account == %@ AND directoryID == %@", appDelegate.activeAccount, directoryID), sorted: datasourceSorted, ascending: datasourceAscending)  {
+                
+                sectionDatasource = CCSectionMetadata.creataDataSourseSectionMetadata(metadatas, listProgressMetadata: nil, groupByField: datasourceGroupBy, filterFileID: nil, filterTypeFileImage: false, filterTypeFileVideo: false, activeAccount: appDelegate.activeAccount)
+            }
+        }
+        
+        self.refreshControl.endRefreshing()
+        
+        collectionView.reloadData()
+    }
+    
+    // MARK: COLLECTIONVIEW METHODS
+    
+    func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
+        
+        if (indexPath.section == 0) {
+            
+            if kind == UICollectionView.elementKindSectionHeader {
+                
+                let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeaderMenu", for: indexPath) as! NCSectionHeaderMenu
+                
+                if collectionView.collectionViewLayout == gridLayout {
+                    header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchList"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
+                } else {
+                    header.buttonSwitch.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: "switchGrid"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), for: .normal)
+                }
+                
+                header.delegate = self
+                
+                header.setStatusButton(count: sectionDatasource.allFileID.count)
+                header.setTitleOrder(datasourceSorted: datasourceSorted, datasourceAscending: datasourceAscending)
+                
+                if datasourceGroupBy == "none" {
+                    header.labelSection.isHidden = true
+                    header.labelSectionHeightConstraint.constant = 0
+                } else {
+                    header.labelSection.isHidden = false
+                    header.setTitleLabel(sectionDatasource: sectionDatasource, section: indexPath.section)
+                    header.labelSectionHeightConstraint.constant = sectionHeaderHeight
+                }
+                
+                return header
+                
+            } else {
+                
+                let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
+                
+                footer.setTitleLabel(sectionDatasource: sectionDatasource)
+                
+                return footer
+            }
+            
+        } else {
+            
+            if kind == UICollectionView.elementKindSectionHeader {
+                
+                let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionHeader", for: indexPath) as! NCSectionHeader
+                
+                header.setTitleLabel(sectionDatasource: sectionDatasource, section: indexPath.section)
+                
+                return header
+                
+            } else {
+                
+                let footer = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "sectionFooter", for: indexPath) as! NCSectionFooter
+                
+                footer.setTitleLabel(sectionDatasource: sectionDatasource)
+                
+                return footer
+            }
+        }
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
+        if section == 0 {
+            if datasourceGroupBy == "none" {
+                return CGSize(width: collectionView.frame.width, height: headerMenuHeight)
+            } else {
+                return CGSize(width: collectionView.frame.width, height: headerMenuHeight + sectionHeaderHeight)
+            }
+        } else {
+            return CGSize(width: collectionView.frame.width, height: sectionHeaderHeight)
+        }
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {
+        let sections = sectionDatasource.sectionArrayRow.allKeys.count
+        if (section == sections - 1) {
+            return CGSize(width: collectionView.frame.width, height: footerHeight)
+        } else {
+            return CGSize(width: collectionView.frame.width, height: 0)
+        }
+    }
+    
+    func numberOfSections(in collectionView: UICollectionView) -> Int {
+        let sections = sectionDatasource.sectionArrayRow.allKeys.count
+        return sections
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
+        let key = sectionDatasource.sections.object(at: section)
+        let datasource = sectionDatasource.sectionArrayRow.object(forKey: key) as! [tableMetadata]
+        return datasource.count
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
+        
+        var image: UIImage?
+        var imagePreview = false
+        
+        guard let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(indexPath, sectionDataSource: sectionDatasource) else {
+            return collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
+        }
+        
+        if metadata.iconName.count > 0 {
+            image = UIImage.init(named: metadata.iconName)
+        } else {
+            image = UIImage.init(named: "file")
+        }
+        
+        if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconFileID(metadata.fileID, fileNameView: metadata.fileName)) {
+            image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(metadata.fileID, fileNameView: metadata.fileName))
+            imagePreview = true
+        } else {
+            if metadata.hasPreview == 1 && !CCUtility.fileProviderStorageIconExists(metadata.fileID, fileNameView: metadata.fileName) {
+                downloadThumbnail(with: metadata, indexPath: indexPath)
+            }
+        }
+        
+        if collectionView.collectionViewLayout == listLayout {
+            
+            // LIST
+            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as! NCListCell
+            cell.delegate = self
+            
+            cell.fileID = metadata.fileID
+            cell.indexPath = indexPath
+            cell.labelTitle.text = metadata.fileNameView
+            
+            if metadata.directory {
+                cell.imageItem.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
+                cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date)
+            } else {
+                cell.imageItem.image = image
+                cell.labelInfo.text = CCUtility.dateDiff(metadata.date as Date) + " " + CCUtility.transformedSize(metadata.size)
+            }
+            
+            if isEditMode {
+                cell.imageItemLeftConstraint.constant = 45
+                cell.imageSelect.isHidden = false
+                
+                if selectFileID.contains(metadata.fileID) {
+                    cell.imageSelect.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "checkedYes"), multiplier: 2, color: NCBrandColor.sharedInstance.brand)
+                    cell.backgroundView = cellBlurEffect(with: cell.bounds)
+                } else {
+                    cell.imageSelect.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "checkedNo"), multiplier: 2, color: NCBrandColor.sharedInstance.optionItem)
+                    cell.backgroundView = nil
+                }
+            } else {
+                cell.imageItemLeftConstraint.constant = 10
+                cell.imageSelect.isHidden = true
+                cell.backgroundView = nil
+            }
+            
+            // Remove last separator
+            if collectionView.numberOfItems(inSection: indexPath.section) == indexPath.row + 1 {
+                cell.separator.isHidden = true
+            } else {
+                cell.separator.isHidden = false
+            }
+            
+            return cell
+            
+        } else {
+            
+            // GRID
+            let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as! NCGridCell
+            cell.delegate = self
+            
+            cell.fileID = metadata.fileID
+            cell.indexPath = indexPath
+            cell.labelTitle.text = metadata.fileNameView
+            
+            if metadata.directory {
+                image = UIImage.init(named: "folder")
+                cell.imageItem.image = CCGraphics.changeThemingColorImage(image, width: image!.size.width*6, height: image!.size.height*6, scale: 3.0, color: NCBrandColor.sharedInstance.brandElement)
+                cell.imageItem.contentMode = .center
+            } else {
+                cell.imageItem.image = image
+                if imagePreview == false {
+                    let width = cell.imageItem.image!.size.width * 2
+                    //let scale = UIScreen.main.scale
+                    cell.imageItem.image = NCUtility.sharedInstance.resizeImage(image: image!, newWidth: width)
+                    cell.imageItem.contentMode = .center
+                }
+            }
+            
+            if isEditMode {
+                cell.imageSelect.isHidden = false
+                if selectFileID.contains(metadata.fileID) {
+                    cell.imageSelect.image = CCGraphics.changeThemingColorImage(UIImage.init(named: "checkedYes"), multiplier: 2, color: UIColor.white)
+                    cell.backgroundView = cellBlurEffect(with: cell.bounds)
+                } else {
+                    cell.imageSelect.isHidden = true
+                    cell.backgroundView = nil
+                }
+            } else {
+                cell.imageSelect.isHidden = true
+                cell.backgroundView = nil
+            }
+            return cell
+        }
+    }
+    
+    func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
+        
+        guard let metadata = NCMainCommon.sharedInstance.getMetadataFromSectionDataSourceIndexPath(indexPath, sectionDataSource: sectionDatasource) else {
+            return
+        }
+        
+        if isEditMode {
+            if let index = selectFileID.index(of: metadata.fileID) {
+                selectFileID.remove(at: index)
+            } else {
+                selectFileID.append(metadata.fileID)
+            }
+            collectionView.reloadItems(at: [indexPath])
+            return
+        }
+        
+        if metadata.directory {
+            
+            let nc:NCSelect = UIStoryboard(name: "NCSelect", bundle: nil).instantiateInitialViewController() as! NCSelect
+            
+            guard let serverUrl = NCManageDatabase.sharedInstance.getServerUrl(metadata.directoryID) else {
+                return
+            }
+            let serverUrlPush = CCUtility.stringAppendServerUrl(serverUrl, addFileName: metadata.fileName)
+            guard let directoryIDPush = NCManageDatabase.sharedInstance.getDirectoryID(serverUrlPush) else {
+                return
+            }
+            
+            nc.directoryID = directoryIDPush
+            nc.titleCurrentFolder = metadata.fileNameView
+            
+            self.navigationController?.pushViewController(nc, animated: true)
+            
+        } else {
+            
+            metadataSelect = metadata
+            performSegue(withIdentifier: "segueDetail", sender: self)
+        }
+    }
+    
+    // MARK: SEGUE
+    
+    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
+        
+        let photoDataSource: NSMutableArray = []
+        
+        for fileID: String in sectionDatasource.allFileID as! [String] {
+            let metadata = sectionDatasource.allRecordsDataSource.object(forKey: fileID) as! tableMetadata
+            if metadata.typeFile == k_metadataTypeFile_image {
+                photoDataSource.add(metadata)
+            }
+        }
+        
+        if let segueNavigationController = segue.destination as? UINavigationController {
+            if let segueViewController = segueNavigationController.topViewController as? CCDetail {
+                
+                segueViewController.metadataDetail = metadataSelect
+                segueViewController.dateFilterQuery = nil
+                segueViewController.photoDataSource = photoDataSource
+                segueViewController.title = metadataSelect.fileNameView
+            }
+        }
+    }
+    
+    // MARK: UTILITY
+    
+    private func cellBlurEffect(with frame: CGRect) -> UIView {
+        
+        let blurEffect = UIBlurEffect(style: .extraLight)
+        let blurEffectView = UIVisualEffectView(effect: blurEffect)
+        
+        blurEffectView.frame = frame
+        blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+        blurEffectView.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.2)
+        
+        return blurEffectView
+    }
+    
+    private func actionSheetHeader(with metadata: tableMetadata) -> UIView? {
+        
+        var image: UIImage?
+        
+        // Header
+        if metadata.directory {
+            image = CCGraphics.changeThemingColorImage(UIImage.init(named: "folder"), multiplier: 3, color: NCBrandColor.sharedInstance.brandElement)
+        } else if metadata.iconName.count > 0 {
+            image = UIImage.init(named: metadata.iconName)
+        } else {
+            image = UIImage.init(named: "file")
+        }
+        if FileManager().fileExists(atPath: CCUtility.getDirectoryProviderStorageIconFileID(metadata.fileID, fileNameView: metadata.fileNameView)) {
+            image = UIImage.init(contentsOfFile: CCUtility.getDirectoryProviderStorageIconFileID(metadata.fileID, fileNameView: metadata.fileNameView))
+        }
+        
+        let headerView = UINib(nibName: "NCActionSheetHeaderView", bundle: nil).instantiate(withOwner: self, options: nil).first as! NCActionSheetHeaderView
+        
+        headerView.imageItem.image = image
+        headerView.label.text = metadata.fileNameView
+        headerView.label.textColor = NCBrandColor.sharedInstance.icon
+        
+        return headerView
+    }
+}

+ 2 - 0
iOSClient/Utility/CCUtility.h

@@ -156,6 +156,8 @@
 + (void)setLayoutTrash:(NSString *)layout;
 + (NSString *)getLayoutOffline;
 + (void)setLayoutOffline:(NSString *)layout;
++ (NSString *)getLayoutSelect;
++ (void)setLayoutSelect:(NSString *)layout;
 
 // ===== Varius =====
 

+ 18 - 0
iOSClient/Utility/CCUtility.m

@@ -592,6 +592,24 @@
     [UICKeyChainStore setString:layout forKey:@"layoutOffline" service:k_serviceShareKeyChain];
 }
 
++ (NSString *)getLayoutSelect
+{
+    NSString *layout = [UICKeyChainStore stringForKey:@"layoutSelect" service:k_serviceShareKeyChain];
+    
+    // Default
+    if (layout == nil) {
+        [self setLayoutTrash:@"list"];
+        return @"list";
+    }
+    
+    return layout;
+}
+
++ (void)setLayoutSelect:(NSString *)layout
+{
+    [UICKeyChainStore setString:layout forKey:@"layoutSelect" service:k_serviceShareKeyChain];
+}
+
 
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Varius =====