Przeglądaj źródła

new menu "Sort"

Marino Faggiana 6 lat temu
rodzic
commit
3fc9e69882
27 zmienionych plików z 236 dodań i 24 usunięć
  1. 23 0
      iOSClient/Images.xcassets/sortDateLessRecent.imageset/Contents.json
  2. BIN
      iOSClient/Images.xcassets/sortDateLessRecent.imageset/sortDateLessRecent.png
  3. BIN
      iOSClient/Images.xcassets/sortDateLessRecent.imageset/sortDateLessRecent@2x.png
  4. BIN
      iOSClient/Images.xcassets/sortDateLessRecent.imageset/sortDateLessRecent@3x.png
  5. 23 0
      iOSClient/Images.xcassets/sortDateMoreRecent.imageset/Contents.json
  6. BIN
      iOSClient/Images.xcassets/sortDateMoreRecent.imageset/sortDateLess.png
  7. BIN
      iOSClient/Images.xcassets/sortDateMoreRecent.imageset/sortDateLess@2x.png
  8. BIN
      iOSClient/Images.xcassets/sortDateMoreRecent.imageset/sortDateLess@3x.png
  9. 23 0
      iOSClient/Images.xcassets/sortFileNameAZ.imageset/Contents.json
  10. BIN
      iOSClient/Images.xcassets/sortFileNameAZ.imageset/sortFileNameAZ.png
  11. BIN
      iOSClient/Images.xcassets/sortFileNameAZ.imageset/sortFileNameAZ@2x.png
  12. BIN
      iOSClient/Images.xcassets/sortFileNameAZ.imageset/sortFileNameAZ@3x.png
  13. 23 0
      iOSClient/Images.xcassets/sortFileNameZA.imageset/Contents.json
  14. BIN
      iOSClient/Images.xcassets/sortFileNameZA.imageset/sortFileNameZA.png
  15. BIN
      iOSClient/Images.xcassets/sortFileNameZA.imageset/sortFileNameZA@2x.png
  16. BIN
      iOSClient/Images.xcassets/sortFileNameZA.imageset/sortFileNameZA@3x.png
  17. 23 0
      iOSClient/Images.xcassets/sortLargest.imageset/Contents.json
  18. BIN
      iOSClient/Images.xcassets/sortLargest.imageset/sortLargest.png
  19. BIN
      iOSClient/Images.xcassets/sortLargest.imageset/sortLargest@2x.png
  20. BIN
      iOSClient/Images.xcassets/sortLargest.imageset/sortLargest@3x.png
  21. 23 0
      iOSClient/Images.xcassets/sortSmallest.imageset/Contents.json
  22. BIN
      iOSClient/Images.xcassets/sortSmallest.imageset/sortSmallest.png
  23. BIN
      iOSClient/Images.xcassets/sortSmallest.imageset/sortSmallest@2x.png
  24. BIN
      iOSClient/Images.xcassets/sortSmallest.imageset/sortSmallest@3x.png
  25. 1 0
      iOSClient/Library/DropdownMenu/DropdownMenu.swift
  26. 6 0
      iOSClient/Supporting Files/en.lproj/Localizable.strings
  27. 91 24
      iOSClient/Trash/NCTrash.swift

+ 23 - 0
iOSClient/Images.xcassets/sortDateLessRecent.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "sortDateLessRecent.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortDateLessRecent@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortDateLessRecent@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/sortDateLessRecent.imageset/sortDateLessRecent.png


BIN
iOSClient/Images.xcassets/sortDateLessRecent.imageset/sortDateLessRecent@2x.png


BIN
iOSClient/Images.xcassets/sortDateLessRecent.imageset/sortDateLessRecent@3x.png


+ 23 - 0
iOSClient/Images.xcassets/sortDateMoreRecent.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "sortDateLess.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortDateLess@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortDateLess@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/sortDateMoreRecent.imageset/sortDateLess.png


BIN
iOSClient/Images.xcassets/sortDateMoreRecent.imageset/sortDateLess@2x.png


BIN
iOSClient/Images.xcassets/sortDateMoreRecent.imageset/sortDateLess@3x.png


+ 23 - 0
iOSClient/Images.xcassets/sortFileNameAZ.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "sortFileNameAZ.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortFileNameAZ@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortFileNameAZ@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/sortFileNameAZ.imageset/sortFileNameAZ.png


BIN
iOSClient/Images.xcassets/sortFileNameAZ.imageset/sortFileNameAZ@2x.png


BIN
iOSClient/Images.xcassets/sortFileNameAZ.imageset/sortFileNameAZ@3x.png


+ 23 - 0
iOSClient/Images.xcassets/sortFileNameZA.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "sortFileNameZA.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortFileNameZA@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortFileNameZA@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/sortFileNameZA.imageset/sortFileNameZA.png


BIN
iOSClient/Images.xcassets/sortFileNameZA.imageset/sortFileNameZA@2x.png


BIN
iOSClient/Images.xcassets/sortFileNameZA.imageset/sortFileNameZA@3x.png


+ 23 - 0
iOSClient/Images.xcassets/sortLargest.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "sortLargest.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortLargest@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortLargest@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/sortLargest.imageset/sortLargest.png


BIN
iOSClient/Images.xcassets/sortLargest.imageset/sortLargest@2x.png


BIN
iOSClient/Images.xcassets/sortLargest.imageset/sortLargest@3x.png


+ 23 - 0
iOSClient/Images.xcassets/sortSmallest.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "sortSmallest.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortSmallest@2x.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "sortSmallest@3x.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
iOSClient/Images.xcassets/sortSmallest.imageset/sortSmallest.png


BIN
iOSClient/Images.xcassets/sortSmallest.imageset/sortSmallest@2x.png


BIN
iOSClient/Images.xcassets/sortSmallest.imageset/sortSmallest@3x.png


+ 1 - 0
iOSClient/Library/DropdownMenu/DropdownMenu.swift

@@ -53,6 +53,7 @@ open class DropdownMenu: UIView {
     }
     
     open weak var delegate: DropdownMenuDelegate?
+    open var token = ""
     open var animateDuration: TimeInterval = 0.25
     open var backgroudBeginColor: UIColor = UIColor.black.withAlphaComponent(0)
     open var backgroudEndColor = UIColor(white: 0, alpha: 0.4)

+ 6 - 0
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -310,6 +310,12 @@
 "_current_sort_ascending_"      = "(currently sorted ascending)";
 "_sort_ascending_"              = "Sort ascending";
 "_current_sort_descending_"     = "(currently sorted descending)";
+"_order_by_name_a_z_"           = "Sort by name (from A to Z)";
+"_order_by_name_z_a_"           = "Sort by name (from Z to A)";
+"_order_by_date_more_recent_"   = "Sort from the most recent";
+"_order_by_date_less_recent_"   = "Sort from the less recent";
+"_order_by_size_smallest_"      = "Sort from the smallest";
+"_order_by_size_largest_"       = "Sort from the largest";
 "_delete_selected_files_"       = "Delete files";
 "_move_selected_files_"         = "Move files";
 "_download_selected_files_"     = "Download files";

+ 91 - 24
iOSClient/Trash/NCTrash.swift

@@ -164,6 +164,7 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
         let item2 = DropdownItem(image: CCGraphics.changeThemingColorImage(UIImage.init(named: "trash"), multiplier: 2, color: NCBrandColor.sharedInstance.icon), title:  NSLocalizedString("_trash_delete_all_", comment: ""))
         
         menuView = DropdownMenu(navigationController: self.navigationController!, items: [item1, item2], selectedRow: -1)
+        menuView?.token = "tapMoreHeaderMenu"
         menuView?.delegate = self
         menuView?.rowHeight = 50
         menuView?.tableView.alwaysBounceVertical = false
@@ -173,34 +174,96 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
     
     func tapOrderHeaderMenu(sender: Any) {
         
+        var menuView: DropdownMenu?
+        var selectedRow = 0
+        
+        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; selectedRow = 0 }
+            if datasourceAscending == false { item2.style = .highlight; selectedRow = 1 }
+        case "date":
+            if datasourceAscending == false { item3.style = .highlight; selectedRow = 2 }
+            if datasourceAscending == true { item4.style = .highlight; selectedRow = 3 }
+        case "size":
+            if datasourceAscending == true { item5.style = .highlight; selectedRow = 4 }
+            if datasourceAscending == false { item6.style = .highlight; selectedRow = 5 }
+        default:
+            print("")
+        }
+        
+        menuView = DropdownMenu(navigationController: self.navigationController!, items: [item1, item2, item3, item4, item5, item6], selectedRow: selectedRow)
+        menuView?.token = "tapOrderHeaderMenu"
+        menuView?.delegate = self
+        menuView?.rowHeight = 50
+        menuView?.highlightColor = NCBrandColor.sharedInstance.brand
+        menuView?.tableView.alwaysBounceVertical = false
+        menuView?.topOffsetY = CGFloat(highHeader-2)
+        menuView?.showMenu()
     }
     
     func dropdownMenu(_ dropdownMenu: DropdownMenu, didSelectRowAt indexPath: IndexPath) {
         
-        if indexPath.row == 0 {
-            for record: tableTrash in self.datasource {
-                restoreItem(with: record.fileID)
+        if dropdownMenu.token == "tapOrderHeaderMenu" {
+            
+            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: print("")
             }
-        }
-        
-        if indexPath.row == 1 {
             
-            var items = [ActionSheetItem]()
+            datasourceSorted = CCUtility.getOrderSettings()
+            datasourceAscending = CCUtility.getAscendingSettings()
             
-            items.append(ActionSheetTitle(title: NSLocalizedString("_trash_delete_all_", comment: "")))
-            items.append(ActionSheetDangerButton(title: NSLocalizedString("_delete_", comment: "")))
-            items.append(ActionSheetCancelButton(title: NSLocalizedString("_cancel_", comment: "")))
+            guard let datasource = NCManageDatabase.sharedInstance.getTrash(filePath: path, sorted: datasourceSorted, ascending: datasourceAscending) else {
+                return
+            }
             
-            let actionSheet = ActionSheet(items: items) { sheet, item in
-                if item is ActionSheetDangerButton {
-                    for record: tableTrash in self.datasource {
-                        self.deleteItem(with: record.fileID)
-                    }
+            self.datasource = datasource
+            collectionView.reloadData()
+        }
+        
+        if dropdownMenu.token == "tapMoreHeaderMenu" {
+        
+            if indexPath.row == 0 {
+                for record: tableTrash in self.datasource {
+                    restoreItem(with: record.fileID)
                 }
-                if item is ActionSheetCancelButton { return }
             }
             
-            actionSheet.present(in: self, from: self.view)
+            if indexPath.row == 1 {
+                
+                var items = [ActionSheetItem]()
+                
+                items.append(ActionSheetTitle(title: NSLocalizedString("_trash_delete_all_", comment: "")))
+                items.append(ActionSheetDangerButton(title: NSLocalizedString("_delete_", comment: "")))
+                items.append(ActionSheetCancelButton(title: NSLocalizedString("_cancel_", comment: "")))
+                
+                let actionSheet = ActionSheet(items: items) { sheet, item in
+                    if item is ActionSheetDangerButton {
+                        for record: tableTrash in self.datasource {
+                            self.deleteItem(with: record.fileID)
+                        }
+                    }
+                    if item is ActionSheetCancelButton { return }
+                }
+                
+                actionSheet.present(in: self, from: self.view)
+            }
         }
     }
     
@@ -322,21 +385,25 @@ class NCTrash: UIViewController , UICollectionViewDataSource, UICollectionViewDe
                 trashHeader.buttonMore.isEnabled = true
             }
             
-            // Order
-            var ascending = "  ▽" // da A a Z (∨∧) 
-            if datasourceAscending == false { ascending = "  △" }
+            // Order (∨∧▽△)
+            var title = ""
             
             switch datasourceSorted {
             case "fileName":
-                trashHeader.buttonOrder.setTitle(NSLocalizedString("_order_by_name_", comment: "") + ascending, for: .normal)
+                if datasourceAscending == true { title = NSLocalizedString("_order_by_name_a_z_", comment: "") }
+                if datasourceAscending == false { title = NSLocalizedString("_order_by_name_z_a_", comment: "") }
             case "date":
-                trashHeader.buttonOrder.setTitle(NSLocalizedString("_order_by_date_", comment: "") + ascending, for: .normal)
+                if datasourceAscending == false { title = NSLocalizedString("_order_by_date_more_recent_", comment: "") }
+                if datasourceAscending == true { title = NSLocalizedString("_order_by_date_less_recent_", comment: "") }
             case "size":
-                trashHeader.buttonOrder.setTitle(NSLocalizedString("_order_by_size_", comment: "") + ascending, for: .normal)
+                if datasourceAscending == true { title = NSLocalizedString("_order_by_size_smallest_", comment: "") }
+                if datasourceAscending == false { title = NSLocalizedString("_order_by_size_largest_", comment: "") }
             default:
-                trashHeader.buttonOrder.setTitle(NSLocalizedString("_order_by_", comment: "") + " " + datasourceSorted + ascending, for: .normal)
+                title = NSLocalizedString("_order_by_", comment: "") + " " + datasourceSorted
             }
             
+            trashHeader.buttonOrder.setTitle(title + "  ▽", for: .normal)
+            
             return trashHeader
             
         } else {