Prechádzať zdrojové kódy

mprove trash UX

- fix grammar
- fix destructive button title
- update icon + move unneeded NCMenu into an alert

Signed-off-by: Henrik Storch <henrik.storch@nextcloud.com>
Henrik Storch 3 rokov pred
rodič
commit
dd4c51c5b4

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

@@ -111,7 +111,7 @@ extension NCSelectableNavigationView where Self: UIViewController {
                     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("_ok_", comment: ""), style: .destructive, handler: { _ in
+                        alert.addAction(UIAlertAction(title: NSLocalizedString("_delete_", comment: ""), style: .destructive, handler: { _ in
                             self.selectOcId.forEach(trash.deleteItem)
                             self.tapSelect()
                         }))

+ 12 - 41
iOSClient/Menu/NCTrash+Menu.swift

@@ -48,8 +48,8 @@ extension NCTrash {
                 title: NSLocalizedString("_trash_delete_all_", comment: ""),
                 icon: NCUtility.shared.loadImage(named: "trash"),
                 action: { _ in
-                    let alert = UIAlertController(title: NSLocalizedString("_trash_delete_all_", comment: ""), message: "", preferredStyle: .alert)
-                    alert.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .destructive, handler: { _ 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))
@@ -60,54 +60,25 @@ extension NCTrash {
         presentMenu(with: actions)
     }
 
-    func toggleMenuMoreList(with objectId: String, image: UIImage?) {
-
-        var actions: [NCMenuAction] = []
+    func toggleMenuMore(with objectId: String, image: UIImage?, isGridCell: Bool) {
 
         guard let tableTrash = NCManageDatabase.shared.getTrashItem(fileId: objectId, account: appDelegate.account) else {
             return
         }
 
-        var iconHeader: UIImage!
-        if let icon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)) {
-            iconHeader = icon
-        } else {
-            if tableTrash.directory {
-                iconHeader = UIImage(named: "folder")!.image(color: NCBrandColor.shared.gray, size: 50)
-            } else {
-                iconHeader = UIImage(named: tableTrash.iconName)
-            }
-        }
-
-        actions.append(
-            NCMenuAction(
-                title: tableTrash.trashbinFileName,
-                icon: iconHeader,
-                action: nil
-            )
-        )
-
-        actions.append(
-            NCMenuAction(
-                title: NSLocalizedString("_delete_", comment: ""),
-                icon: NCUtility.shared.loadImage(named: "trash"),
-                action: { _ in
-                    self.deleteItem(with: objectId)
-                }
-            )
-        )
-
-        self.presentMenu(with: actions)
-    }
+        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)
 
-    func toggleMenuMoreGrid(with objectId: String, namedButtonMore: String, image: UIImage?) {
-
-        var actions: [NCMenuAction] = []
-
-        guard let tableTrash = NCManageDatabase.shared.getTrashItem(fileId: objectId, account: appDelegate.account) else {
             return
         }
 
+        var actions: [NCMenuAction] = []
+
         var iconHeader: UIImage!
         if let icon = UIImage(contentsOfFile: CCUtility.getDirectoryProviderStorageIconOcId(tableTrash.fileId, etag: tableTrash.fileName)) {
             iconHeader = icon

+ 2 - 1
iOSClient/Supporting Files/en.lproj/Localizable.strings

@@ -708,10 +708,11 @@
 "_trash_view_"                      = "Deleted files";
 "_trash_restore_all_"               = "Restore all files";
 "_trash_delete_all_"                = "Empty trash";
+"_trash_delete_all_description_"    = "Do you want to empty the trash?";
 "_trash_no_trash_"                  = "No files deleted";
 "_trash_no_trash_description_"      = "You can restore deleted files from here";
 "_trash_restore_selected_"          = "Restore selected files";
-"_trash_delete_selected_"           = "Deleted selected files";
+"_trash_delete_selected_"           = "Delete selected files";
 "_manage_file_offline_"             = "Manage offline files";
 "_set_available_offline_"           = "Set as available offline";
 "_remove_available_offline_"        = "Remove as available offline";

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

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

+ 2 - 0
iOSClient/Trash/NCTrash+CollectionView.swift

@@ -110,11 +110,13 @@ extension NCTrash: UICollectionViewDataSource {
 
         if collectionView.collectionViewLayout == listLayout {
             guard let listCell = collectionView.dequeueReusableCell(withReuseIdentifier: "listCell", for: indexPath) as? NCTrashListCell else { return UICollectionViewCell() }
+            listCell.delegate = self
             cell = listCell
         } else {
             // GRID
             guard let gridCell = collectionView.dequeueReusableCell(withReuseIdentifier: "gridCell", for: indexPath) as? NCGridCell else { return UICollectionViewCell() }
             gridCell.setButtonMore(named: NCGlobal.shared.buttonMoreMore, image: NCBrandColor.cacheImages.buttonMore)
+            gridCell.delegate = self
             cell = gridCell
         }
 

+ 15 - 15
iOSClient/Trash/NCTrash.swift

@@ -27,28 +27,28 @@ import Realm
 import UIKit
 import NCCommunication
 
-class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDelegate, NCTrashSectionHeaderMenuDelegate, NCEmptyDataSetDelegate {
+class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDelegate, NCTrashSectionHeaderMenuDelegate, NCEmptyDataSetDelegate, NCGridCellDelegate {
 
     var selectableDataSource: [RealmSwiftObject] { datasource }
 
     @IBOutlet weak var collectionView: UICollectionView!
 
-     var trashPath = ""
-     var titleCurrentFolder = NSLocalizedString("_trash_view_", comment: "")
-     var blinkFileId: String?
-     var emptyDataSet: NCEmptyDataSet?
+    var trashPath = ""
+    var titleCurrentFolder = NSLocalizedString("_trash_view_", comment: "")
+    var blinkFileId: String?
+    var emptyDataSet: NCEmptyDataSet?
 
     internal let appDelegate = (UIApplication.shared.delegate as? AppDelegate)!
 
-     internal var isEditMode = false
-     internal var selectOcId: [String] = []
+    internal var isEditMode = false
+    internal var selectOcId: [String] = []
 
-     var datasource: [tableTrash] = []
-     var layoutForView: NCGlobal.layoutForViewType?
-     var listLayout: NCListLayout!
-     var gridLayout: NCGridLayout!
-     let highHeader: CGFloat = 50
-     private let refreshControl = UIRefreshControl()
+    var datasource: [tableTrash] = []
+    var layoutForView: NCGlobal.layoutForViewType?
+    var listLayout: NCListLayout!
+    var gridLayout: NCGridLayout!
+    let highHeader: CGFloat = 50
+    private let refreshControl = UIRefreshControl()
 
     // MARK: - View Life Cycle
 
@@ -183,7 +183,7 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
     func tapMoreListItem(with objectId: String, image: UIImage?, sender: Any) {
 
         if !isEditMode {
-            toggleMenuMoreList(with: objectId, image: image)
+            toggleMenuMore(with: objectId, image: image, isGridCell: false)
         } else if let button = sender as? UIView {
             let buttonPosition = button.convert(CGPoint.zero, to: collectionView)
             let indexPath = collectionView.indexPathForItem(at: buttonPosition)
@@ -194,7 +194,7 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
     func tapMoreGridItem(with objectId: String, namedButtonMore: String, image: UIImage?, sender: Any) {
 
         if !isEditMode {
-            toggleMenuMoreGrid(with: objectId, namedButtonMore: namedButtonMore, image: image)
+            toggleMenuMore(with: objectId, image: image, isGridCell: true)
         } else if let button = sender as? UIView {
             let buttonPosition = button.convert(CGPoint.zero, to: collectionView)
             let indexPath = collectionView.indexPathForItem(at: buttonPosition)