Browse Source

fix blink cell

marinofaggiana 5 years ago
parent
commit
2f50819748

+ 1 - 1
iOSClient/Main/CCMain.m

@@ -3727,7 +3727,7 @@
                         [UIView animateWithDuration:0.5 animations:^{
                             [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:NO];
                         } completion:^(BOOL finished) {
-                            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
+                            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.5 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
                                 CCCellMain *cell = [self.tableView cellForRowAtIndexPath:indexPath];
                                 if (cell) {
                                     [cell blink];

+ 7 - 0
iOSClient/Main/Cell/NCGridCell.swift

@@ -94,6 +94,13 @@ class NCGridCell: UICollectionViewCell {
             labelTitleTrailing.constant = labelTitleTrailingConstant
         }
     }
+    
+    func blink() {
+        self.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+        UIView.animate(withDuration: 2) {
+            self.backgroundColor = .clear
+        }
+    }
 }
 
 protocol NCGridCellDelegate {

+ 7 - 0
iOSClient/Main/Cell/NCGridMediaCell.swift

@@ -38,5 +38,12 @@ class NCGridMediaCell: UICollectionViewCell {
     override func awakeFromNib() {
         super.awakeFromNib()
     }
+    
+    func blink() {
+        self.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+        UIView.animate(withDuration: 2) {
+            self.backgroundColor = .clear
+        }
+    }
 }
 

+ 7 - 0
iOSClient/Main/Cell/NCListCell.swift

@@ -106,6 +106,13 @@ class NCListCell: UICollectionViewCell {
             labelTitleTrailing.constant = labelTitleTrailingConstant
         }
     }
+    
+    func blink() {
+        self.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+        UIView.animate(withDuration: 2) {
+            self.backgroundColor = .clear
+        }
+    }
 }
 
 protocol NCListCellDelegate {

+ 7 - 0
iOSClient/Trash/Cell/NCTrashListCell.swift

@@ -62,6 +62,13 @@ class NCTrashListCell: UICollectionViewCell {
     @IBAction func touchUpInsideRestore(_ sender: Any) {
         delegate?.tapRestoreListItem(with: fileID, sender: sender)
     }
+    
+    func blink() {
+        self.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+        UIView.animate(withDuration: 2) {
+            self.backgroundColor = .clear
+        }
+    }
 }
 
 protocol NCTrashListCellDelegate {

+ 13 - 9
iOSClient/Trash/NCTrash.swift

@@ -653,17 +653,21 @@ extension NCTrash {
                 for item in 0...self.datasource.count-1 {
                     if self.datasource[item].fileID.contains(self.scrollToFileID) {
                         let indexPath = IndexPath(item: item, section: 0)
-                        self.collectionView.scrollToItem(at: indexPath, at: .top, animated: true)
-                        DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
-                            if let cell = self.collectionView.cellForItem(at: indexPath) as? NCTrashListCell {
-                                cell.layer.borderWidth = 1
-                                cell.layer.borderColor = NCBrandColor.sharedInstance.brand.cgColor
-                                DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
-                                    cell.layer.borderWidth = 0
-                                    cell.layer.borderColor = UIColor.clear.cgColor
+                        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) {
+                                if self.collectionView.collectionViewLayout == self.listLayout {
+                                    if let cell = self.collectionView.cellForItem(at: indexPath) as? NCTrashListCell {
+                                        cell.blink()
+                                    }
+                                } else {
+                                    if let cell = self.collectionView.cellForItem(at: indexPath) as? NCGridCell {
+                                        cell.blink()
+                                    }
                                 }
                             }
-                        }
+                        })
                         self.scrollToFileID = ""
                     }
                 }