Przeglądaj źródła

coding

Signed-off-by: marinofaggiana <ios@nextcloud.com>
marinofaggiana 2 lat temu
rodzic
commit
b7d75ee46b

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

@@ -155,11 +155,12 @@ extension NCTrash: UICollectionViewDataSource {
             }
 
             header.delegate = self
+            header.buttonMoreIsHidden(false)
             header.setStatusButtonsView(enable: !datasource.isEmpty)
             header.setSortedTitle(layoutForView?.titleButtonHeader ?? "")
-
-            header.buttonMoreIsHidden(false)
-            header.setButtonsCommand(heigt: 0)
+            header.setButtonsCommand(heigt: heightButtonsCommand,
+                                     imageButton1: UIImage(named: "restore"), titleButton1: NSLocalizedString("_trash_restore_selected_", comment: ""),
+                                     imageButton2: UIImage(named: "trash"), titleButton2: NSLocalizedString("_trash_delete_selected_", comment: ""))
             header.setButtonsView(heigt: heightButtonsView)
             header.setRichWorkspaceHeight(0)
             header.setSectionHeight(0)
@@ -182,7 +183,7 @@ extension NCTrash: UICollectionViewDataSource {
 extension NCTrash: UICollectionViewDelegateFlowLayout {
 
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
-        return CGSize(width: collectionView.frame.width, height: heightButtonsView)
+        return CGSize(width: collectionView.frame.width, height: heightButtonsView + heightButtonsCommand)
     }
 
     func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForFooterInSection section: Int) -> CGSize {

+ 16 - 0
iOSClient/Trash/NCTrash.swift

@@ -47,6 +47,7 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
     var listLayout: NCListLayout!
     var gridLayout: NCGridLayout!
 
+    internal let heightButtonsCommand: CGFloat = 60
     internal let heightButtonsView: CGFloat = 40
     internal let footerEndHeight: CGFloat = 100
 
@@ -204,10 +205,25 @@ class NCTrash: UIViewController, NCSelectableNavigationView, NCTrashListCellDele
         } // else: undefined sender
     }
 
+    func tapButton1(_ sender: Any) {
+        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)
+    }
+
     func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) { }
 
     func longPressMoreGridItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) { }
 
+    // MARK: - DataSource
+
     @objc func reloadDataSource() {
 
         layoutForView = NCUtility.shared.getLayoutForView(key: NCGlobal.shared.layoutViewTrash, serverUrl: "")