Эх сурвалжийг харах

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 жил өмнө
parent
commit
8194e6055b

+ 2 - 0
iOSClient/Brand/NCBrand.swift

@@ -139,6 +139,7 @@ class NCBrandColor: NSObject {
         static var buttonStop = UIImage()
         static var buttonMoreLock = UIImage()
         static var buttonRestore = UIImage()
+        static var buttonTrash = UIImage()
 
         static var iconContacts = UIImage()
         static var iconTalk = UIImage()
@@ -376,6 +377,7 @@ class NCBrandColor: NSObject {
         cacheImages.buttonStop = UIImage(named: "stop")!.image(color: gray, size: 50)
         cacheImages.buttonMoreLock = UIImage(named: "moreLock")!.image(color: gray, size: 50)
         cacheImages.buttonRestore = UIImage(named: "restore")!.image(color: gray, size: 50)
+        cacheImages.buttonTrash = UIImage(named: "trash")!.image(color: gray, size: 50)
 
         cacheImages.iconContacts = UIImage(named: "icon-contacts")!.image(color: brandElement, size: folderWidth)
         cacheImages.iconTalk = UIImage(named: "icon-talk")!.image(color: brandElement, size: folderWidth)

+ 5 - 1
iOSClient/Main/Collection Common/NCSelectableNavigationView.swift

@@ -34,6 +34,7 @@ extension RealmSwiftObject {
 }
 
 protocol NCSelectableNavigationView: AnyObject {
+
     var appDelegate: AppDelegate { get }
     var selectableDataSource: [RealmSwiftObject] { get }
     var collectionView: UICollectionView! { get set }
@@ -52,7 +53,10 @@ protocol NCSelectableNavigationView: AnyObject {
 }
 
 extension NCSelectableNavigationView {
-    func setNavigationItem() { setNavigationHeader() }
+
+    func setNavigationItem() {
+        setNavigationHeader()
+    }
 
     func setNavigationHeader() {
         if isEditMode {

+ 0 - 67
iOSClient/Menu/NCTrash+Menu.swift

@@ -28,62 +28,6 @@ import FloatingPanel
 import NCCommunication
 
 extension NCTrash {
-    var selectActions: [NCMenuAction] {
-        [
-            NCMenuAction(
-                title: NSLocalizedString("_trash_restore_selected_", comment: ""),
-                icon: NCUtility.shared.loadImage(named: "restore"),
-                action: { _ in
-                    self.selectOcId.forEach(self.restoreItem)
-                    self.tapSelect()
-                }
-            ),
-            NCMenuAction(
-                title: NSLocalizedString("_trash_delete_selected_", comment: ""),
-                icon: NCUtility.shared.loadImage(named: "trash"),
-                action: { _ in
-                    let alert = UIAlertController(title: NSLocalizedString("_trash_delete_selected_", comment: ""), message: "", preferredStyle: .alert)
-                    alert.addAction(UIAlertAction(title: NSLocalizedString("_delete_", comment: ""), style: .destructive, handler: { _ in
-                        self.selectOcId.forEach(self.deleteItem)
-                        self.tapSelect()
-                    }))
-                    alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: { _ in }))
-                    self.present(alert, animated: true, completion: nil)
-                }
-            )
-        ]
-    }
-
-    func toggleMenuMoreHeader() {
-
-        var actions: [NCMenuAction] = []
-
-        actions.append(
-            NCMenuAction(
-                title: NSLocalizedString("_trash_restore_all_", comment: ""),
-                icon: NCUtility.shared.loadImage(named: "restore"),
-                action: { _ in
-                    self.datasource.forEach({ self.restoreItem(with: $0.fileId) })
-                }
-            )
-        )
-
-        actions.append(
-            NCMenuAction(
-                title: NSLocalizedString("_trash_delete_all_", comment: ""),
-                icon: NCUtility.shared.loadImage(named: "trash"),
-                action: { _ in
-                    let alert = UIAlertController(title: NSLocalizedString("_trash_delete_all_description_", comment: ""), message: "", preferredStyle: .alert)
-                    alert.addAction(UIAlertAction(title: NSLocalizedString("_trash_delete_all_", comment: ""), style: .destructive, handler: { _ in
-                        self.emptyTrash()
-                    }))
-                    alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel))
-                    self.present(alert, animated: true, completion: nil)
-                }
-            )
-        )
-        presentMenu(with: actions)
-    }
 
     func toggleMenuMore(with objectId: String, image: UIImage?, isGridCell: Bool) {
 
@@ -91,17 +35,6 @@ extension NCTrash {
             return
         }
 
-        guard isGridCell else {
-            let alert = UIAlertController(title: NSLocalizedString("_want_delete_", comment: ""), message: tableTrash.trashbinFileName, preferredStyle: .alert)
-            alert.addAction(UIAlertAction(title: NSLocalizedString("_delete_", comment: ""), style: .destructive, handler: { _ in
-                self.deleteItem(with: objectId)
-            }))
-            alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel))
-            self.present(alert, animated: true, completion: nil)
-
-            return
-        }
-
         var actions: [NCMenuAction] = []
 
         var iconHeader: UIImage!

+ 1 - 1
iOSClient/Trash/Cell/NCTrashListCell.swift

@@ -65,7 +65,7 @@ class NCTrashListCell: UICollectionViewCell, NCTrashCell {
         ]
 
         imageRestore.image = NCBrandColor.cacheImages.buttonRestore
-        imageMore.image = NCUtility.shared.loadImage(named: "trash")
+        imageMore.image = NCBrandColor.cacheImages.buttonTrash
 
         imageItem.layer.cornerRadius = 6
         imageItem.layer.masksToBounds = true

+ 9 - 4
iOSClient/Trash/NCTrash+CollectionView.swift

@@ -155,12 +155,17 @@ extension NCTrash: UICollectionViewDataSource {
             }
 
             header.delegate = self
-            header.buttonMoreIsHidden(false)
             header.setStatusButtonsView(enable: !datasource.isEmpty)
             header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
-            header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand,
-                                     imageButton1: UIImage(named: "restore"), titleButton1: NSLocalizedString("_trash_restore_selected_", comment: ""),
-                                     imageButton2: UIImage(named: "trash"), titleButton2: NSLocalizedString("_trash_delete_selected_", comment: ""))
+            if isEditMode {
+                header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand,
+                                         imageButton1: UIImage(named: "restore"), titleButton1: NSLocalizedString("_trash_restore_selected_", comment: ""),
+                                         imageButton2: UIImage(named: "trash"), titleButton2: NSLocalizedString("_trash_delete_selected_", comment: ""))
+            } else {
+                header.setButtonsCommand(heigt: NCGlobal.shared.heightButtonsCommand,
+                                         imageButton1: UIImage(named: "restore"), titleButton1: NSLocalizedString("_trash_restore_all_", comment: ""),
+                                         imageButton2: UIImage(named: "trash"), titleButton2: NSLocalizedString("_trash_delete_all_", comment: ""))
+            }
             header.setButtonsView(heigt: NCGlobal.shared.heightButtonsView)
             header.setRichWorkspaceHeight(0)
             header.setSectionHeight(0)

+ 25 - 10
iOSClient/Trash/NCTrash.swift

@@ -164,9 +164,7 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
         sortMenu.toggleMenu(viewController: self, key: NCGlobal.shared.layoutViewTrash, sortButton: sender as? UIButton, serverUrl: "", hideDirectoryOnTop: true)
     }
 
-    func tapButtonMore(_ sender: Any) {
-        toggleMenuMoreHeader()
-    }
+    func tapButtonMore(_ sender: Any) { }
 
     func tapRestoreListItem(with ocId: String, image: UIImage?, sender: Any) {
 
@@ -202,16 +200,33 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
     }
 
     func tapButton1(_ sender: Any) {
-        datasource.forEach({ self.restoreItem(with: $0.fileId) })
+
+        if isEditMode {
+            self.selectOcId.forEach(self.restoreItem)
+            self.tapSelect()
+        } else {
+            datasource.forEach({ self.restoreItem(with: $0.fileId) })
+        }
     }
 
     func tapButton2(_ sender: Any) {
-        let alert = UIAlertController(title: NSLocalizedString("_trash_delete_all_description_", comment: ""), message: "", preferredStyle: .alert)
-        alert.addAction(UIAlertAction(title: NSLocalizedString("_trash_delete_all_", comment: ""), style: .destructive, handler: { _ in
-            self.emptyTrash()
-        }))
-        alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel))
-        self.present(alert, animated: true, completion: nil)
+
+        if isEditMode {
+            let alert = UIAlertController(title: NSLocalizedString("_trash_delete_selected_", comment: ""), message: "", preferredStyle: .alert)
+            alert.addAction(UIAlertAction(title: NSLocalizedString("_delete_", comment: ""), style: .destructive, handler: { _ in
+                self.selectOcId.forEach(self.deleteItem)
+                self.tapSelect()
+            }))
+            alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel, handler: { _ in }))
+            self.present(alert, animated: true, completion: nil)
+        } else {
+            let alert = UIAlertController(title: NSLocalizedString("_trash_delete_all_description_", comment: ""), message: "", preferredStyle: .alert)
+            alert.addAction(UIAlertAction(title: NSLocalizedString("_trash_delete_all_", comment: ""), style: .destructive, handler: { _ in
+                self.emptyTrash()
+            }))
+            alert.addAction(UIAlertAction(title: NSLocalizedString("_cancel_", comment: ""), style: .cancel))
+            self.present(alert, animated: true, completion: nil)
+        }
     }
 
     func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) { }