Browse Source

Improved blinkFileID on Trash

marinofaggiana 5 năm trước cách đây
mục cha
commit
3286141013
2 tập tin đã thay đổi với 9 bổ sung12 xóa
  1. 1 1
      iOSClient/Activity/NCActivity.swift
  2. 8 11
      iOSClient/Trash/NCTrash.swift

+ 1 - 1
iOSClient/Activity/NCActivity.swift

@@ -323,7 +323,7 @@ extension activityTableViewCell: UICollectionViewDelegate {
             if (responder as? UIViewController)!.navigationController != nil {
                 if let viewController = UIStoryboard.init(name: "NCTrash", bundle: nil).instantiateInitialViewController() as? NCTrash {
                     if let result = NCManageDatabase.sharedInstance.getTrashItem(fileID: String(activityPreview.fileId), account: activityPreview.account) {
-                        viewController.scrollToFileID = result.fileID
+                        viewController.blinkFileID = result.fileID
                         viewController.path = result.filePath
                         (responder as? UIViewController)!.navigationController?.pushViewController(viewController, animated: true)
                     }

+ 8 - 11
iOSClient/Trash/NCTrash.swift

@@ -30,7 +30,7 @@ class NCTrash: UIViewController, UIGestureRecognizerDelegate, NCTrashListCellDel
 
     var path = ""
     var titleCurrentFolder = NSLocalizedString("_trash_view_", comment: "")
-    var scrollToFileID = ""
+    var blinkFileID: String?
     
     private let appDelegate = UIApplication.shared.delegate as! AppDelegate
     
@@ -649,18 +649,15 @@ extension NCTrash {
         
         reloadDataThenPerform {
             // GoTo FileID
-            if self.scrollToFileID != "" {
+            if self.blinkFileID != nil {
                 for item in 0...self.datasource.count-1 {
-                    if self.datasource[item].fileID.contains(self.scrollToFileID) {
+                    if self.datasource[item].fileID.contains(self.blinkFileID!) {
                         let indexPath = IndexPath(item: item, section: 0)
-                        UIView.animate(withDuration: 0.5, animations: {
-                            self.collectionView.scrollToItem(at: indexPath, at: .top, animated: true)
-                        }, completion: { (finished) in
-                            DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-                                NCUtility.sharedInstance.blink(cell: self.collectionView.cellForItem(at: indexPath))
-                            }
-                        })
-                        self.scrollToFileID = ""
+                        self.collectionView.scrollToItem(at: indexPath, at: .top, animated: false)
+                        DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
+                            self.blinkFileID = nil
+                            NCUtility.sharedInstance.blink(cell: self.collectionView.cellForItem(at: indexPath))
+                        }
                     }
                 }
             }