Browse Source

create utility.blink

marinofaggiana 5 years ago
parent
commit
0f4dd216d4

+ 1 - 1
iOSClient/Main/CCMain.m

@@ -3730,7 +3730,7 @@
                             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];
+                                    [[NCUtility sharedInstance] blinkWithCell:cell];
                                 }
                             });
                         }];

+ 0 - 4
iOSClient/Main/Cell/CCCellMain.h

@@ -26,8 +26,6 @@
 
 @interface CCCellMain : MGSwipeTableCell
 
-@property(nonatomic, weak) IBOutlet UIView *viewBlink;
-
 @property(nonatomic, weak) IBOutlet UIImageView *file;
 @property(nonatomic, weak) IBOutlet UIImageView *status;
 @property(nonatomic, weak) IBOutlet UIImageView *favorite;
@@ -38,6 +36,4 @@
 @property(nonatomic, weak) IBOutlet UILabel *labelTitle;
 @property(nonatomic, weak) IBOutlet UILabel *labelInfoFile;
 
-- (void)blink;
-
 @end

+ 0 - 8
iOSClient/Main/Cell/CCCellMain.m

@@ -44,12 +44,4 @@
     self.contentView.preservesSuperviewLayoutMargins = NO;
 }
 
-- (void)blink
-{
-    self.viewBlink.backgroundColor = [[[NCBrandColor sharedInstance] brand] colorWithAlphaComponent:.3];
-    [UIView animateWithDuration:2 animations:^{
-        self.viewBlink.backgroundColor = [UIColor whiteColor];
-    }];
-}
-
 @end

+ 0 - 9
iOSClient/Main/Cell/CCCellMain.xib

@@ -18,10 +18,6 @@
                 <rect key="frame" x="0.0" y="0.0" width="600" height="59.5"/>
                 <autoresizingMask key="autoresizingMask"/>
                 <subviews>
-                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="kzh-qo-53V" userLabel="ViewBlink">
-                        <rect key="frame" x="0.0" y="0.0" width="600" height="59.5"/>
-                        <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
-                    </view>
                     <label opaque="NO" userInteractionEnabled="NO" tag="101" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="QNC-8X-DAC">
                         <rect key="frame" x="65" y="13" width="430" height="18"/>
                         <fontDescription key="fontDescription" type="system" pointSize="15"/>
@@ -80,16 +76,12 @@
                 <color key="tintColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                 <constraints>
                     <constraint firstAttribute="bottom" secondItem="p7I-KN-FVZ" secondAttribute="bottom" constant="14" id="2Ay-YK-f66"/>
-                    <constraint firstItem="kzh-qo-53V" firstAttribute="top" secondItem="sQq-jC-UEV" secondAttribute="top" id="2ba-az-fbM"/>
                     <constraint firstItem="5" firstAttribute="leading" secondItem="Fw2-NW-hsK" secondAttribute="trailing" constant="-10" id="32q-iB-1GU"/>
                     <constraint firstItem="DQR-yN-JaH" firstAttribute="top" secondItem="5" secondAttribute="bottom" constant="-9.5" id="3A5-mA-6Hh"/>
-                    <constraint firstAttribute="trailing" secondItem="kzh-qo-53V" secondAttribute="trailing" id="4R1-SZ-pCq"/>
                     <constraint firstItem="QNC-8X-DAC" firstAttribute="top" secondItem="sQq-jC-UEV" secondAttribute="top" constant="13" id="4ds-S3-swp"/>
                     <constraint firstItem="5" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leading" constant="15" id="5es-ma-EXb"/>
                     <constraint firstItem="qhJ-el-R92" firstAttribute="leading" secondItem="p7I-KN-FVZ" secondAttribute="trailing" constant="10" id="8Kc-xa-mlh"/>
-                    <constraint firstAttribute="bottom" secondItem="kzh-qo-53V" secondAttribute="bottom" id="9Ce-HT-LhF"/>
                     <constraint firstItem="aRp-Ql-cyA" firstAttribute="centerY" secondItem="sQq-jC-UEV" secondAttribute="centerY" id="DOx-77-6Mg"/>
-                    <constraint firstItem="kzh-qo-53V" firstAttribute="leading" secondItem="sQq-jC-UEV" secondAttribute="leading" id="Ivr-o5-QYo"/>
                     <constraint firstItem="qhJ-el-R92" firstAttribute="centerY" secondItem="sQq-jC-UEV" secondAttribute="centerY" id="Jrh-En-806"/>
                     <constraint firstItem="p7I-KN-FVZ" firstAttribute="leading" secondItem="5" secondAttribute="trailing" constant="10" id="Rcn-fx-Tz6"/>
                     <constraint firstItem="aRp-Ql-cyA" firstAttribute="leading" secondItem="qhJ-el-R92" secondAttribute="trailing" id="T0F-Ef-8tH"/>
@@ -113,7 +105,6 @@
                 <outlet property="more" destination="aRp-Ql-cyA" id="vbC-Za-UhD"/>
                 <outlet property="shared" destination="qhJ-el-R92" id="qXO-Vc-N0d"/>
                 <outlet property="status" destination="Fw2-NW-hsK" id="PjC-tV-ROx"/>
-                <outlet property="viewBlink" destination="kzh-qo-53V" id="Pe2-vt-aMK"/>
             </connections>
             <point key="canvasLocation" x="664" y="152.02398800599701"/>
         </tableViewCell>

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

@@ -94,13 +94,6 @@ 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 {

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

@@ -38,12 +38,5 @@ 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
-        }
-    }
 }
 

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

@@ -106,13 +106,6 @@ 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 {

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

@@ -62,13 +62,6 @@ 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 {

+ 1 - 9
iOSClient/Trash/NCTrash.swift

@@ -657,15 +657,7 @@ extension NCTrash {
                             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()
-                                    }
-                                }
+                                NCUtility.sharedInstance.blink(cell: self.collectionView.cellForItem(at: indexPath))
                             }
                         })
                         self.scrollToFileID = ""

+ 14 - 1
iOSClient/Utility/NCUtility.swift

@@ -309,6 +309,19 @@ class NCUtility: NSObject {
         let hour = Int(seconds / 3600)
         return String(format: "%02d:%02d:%02d", hour, min, sec)
     }
-
+    
+    @objc func blink(cell: AnyObject?) {
+        if let cell = cell as? UITableViewCell {
+            cell.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+            UIView.animate(withDuration: 2) {
+                cell.backgroundColor = .clear
+            }
+        } else if let cell = cell as? UICollectionViewCell {
+            cell.backgroundColor = NCBrandColor.sharedInstance.brand.withAlphaComponent(0.3)
+            UIView.animate(withDuration: 2) {
+                cell.backgroundColor = .clear
+            }
+        }
+    }
 }