marinofaggiana 4 years ago
parent
commit
94f6ecb6dc

+ 4 - 0
iOSClient/CCGlobal.h

@@ -281,6 +281,10 @@
 #define k_layout_view_media                             @"LayoutMedia"
 #define k_layout_view_recent                            @"LayoutRecent"
 
+// Button Type in Cell list/grid
+#define k_buttonMoreMore                                @"more"
+#define k_buttonMoreStop                                @"stop"
+
 // Rich Workspace
 #define k_fileNameRichWorkspace                         @"Readme.md"
 

+ 3 - 5
iOSClient/Main/Cell/NCGridCell.swift

@@ -69,9 +69,7 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
         longPressedGestureMore.minimumPressDuration = 0.5
         longPressedGestureMore.delegate = self
         longPressedGestureMore.delaysTouchesBegan = true
-        buttonMore.addGestureRecognizer(longPressedGestureMore)
-        
-        setButtonMore(named: "more")
+        buttonMore.addGestureRecognizer(longPressedGestureMore)        
     }
     
     override func prepareForReuse() {
@@ -93,9 +91,9 @@ class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
         delegate?.longPressGridItem(with: objectId, gestureRecognizer: gestureRecognizer)
     }
     
-    func setButtonMore(named: String) {
+    func setButtonMore(named: String, image: UIImage) {
         namedButtonMore = named
-        buttonMore.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: named), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem), for: UIControl.State.normal)
+        buttonMore.setImage(image, for: .normal)
     }
     
     func hideButtonMore() {

+ 3 - 5
iOSClient/Main/Cell/NCListCell.swift

@@ -80,9 +80,7 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
         longPressedGestureMore.minimumPressDuration = 0.5
         longPressedGestureMore.delegate = self
         longPressedGestureMore.delaysTouchesBegan = true
-        buttonMore.addGestureRecognizer(longPressedGestureMore)
-        
-        setButtonMore(named: "more")
+        buttonMore.addGestureRecognizer(longPressedGestureMore)        
     }
     
     override func prepareForReuse() {
@@ -108,9 +106,9 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCell
         delegate?.longPressListItem(with: objectId, gestureRecognizer: gestureRecognizer)
     }
     
-    func setButtonMore(named: String) {
+    func setButtonMore(named: String, image: UIImage) {
         namedButtonMore = named
-        imageMore.image = CCGraphics.changeThemingColorImage(UIImage.init(named: named), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
+        buttonMore.setImage(image, for: .normal)
     }
     
     func hideButtonMore() {

+ 10 - 6
iOSClient/Main/NCCollectionCommon.swift

@@ -38,7 +38,6 @@ class NCCollectionCommon: NSObject {
         static var cellCanShareImage = UIImage()
         static var cellShareByLinkImage = UIImage()
         static var cellFavouriteImage = UIImage()
-        static var cellMoreImage = UIImage()
         static var cellCommentImage = UIImage()
         static var cellLivePhotoImage = UIImage()
         static var cellOfflineFlag = UIImage()
@@ -54,6 +53,9 @@ class NCCollectionCommon: NSObject {
         
         static var cellCheckedYes = UIImage()
         static var cellCheckedNo = UIImage()
+        
+        static var cellButtonMore = UIImage()
+        static var cellButtonStop = UIImage()
 
         static var cellPlayImage = UIImage()
     }
@@ -66,7 +68,6 @@ class NCCollectionCommon: NSObject {
         NCCollectionCommonImages.cellCanShareImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "share"), width: 100, height: 100, color: NCBrandColor.sharedInstance.optionItem)
         NCCollectionCommonImages.cellShareByLinkImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "sharebylink"), width: 100, height: 100, color: NCBrandColor.sharedInstance.optionItem)
         NCCollectionCommonImages.cellFavouriteImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "favorite"), width: 100, height: 100, color: NCBrandColor.sharedInstance.yellowFavorite)
-        NCCollectionCommonImages.cellMoreImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
         NCCollectionCommonImages.cellCommentImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "comment"), width: 30, height: 30, color: NCBrandColor.sharedInstance.graySoft)
         NCCollectionCommonImages.cellLivePhotoImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "livePhoto"), width: 100, height: 100, color: NCBrandColor.sharedInstance.textView)
         NCCollectionCommonImages.cellOfflineFlag = UIImage.init(named: "offlineFlag")!
@@ -83,6 +84,9 @@ class NCCollectionCommon: NSObject {
         NCCollectionCommonImages.cellCheckedYes = CCGraphics.changeThemingColorImage(UIImage.init(named: "checkedYes"), width: 100, height: 100, color: NCBrandColor.sharedInstance.brandElement)
         NCCollectionCommonImages.cellCheckedNo = CCGraphics.changeThemingColorImage(UIImage.init(named: "checkedNo"), width: 100, height: 100, color: NCBrandColor.sharedInstance.graySoft)
         
+        NCCollectionCommonImages.cellButtonMore = CCGraphics.changeThemingColorImage(UIImage.init(named: "more"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
+        NCCollectionCommonImages.cellButtonStop = CCGraphics.changeThemingColorImage(UIImage.init(named: "stop"), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
+
         NCCollectionCommonImages.cellPlayImage = CCGraphics.changeThemingColorImage(UIImage.init(named: "play"), width: 100, height: 100, color: .white)
     }
     
@@ -255,11 +259,11 @@ class NCCollectionCommon: NSObject {
             }
             if metadata.status == k_metadataStatusInDownload || metadata.status == k_metadataStatusDownloading ||  metadata.status >= k_metadataStatusTypeUpload {
                 cell.progressView.isHidden = false
-                cell.setButtonMore(named: "stop")
+                cell.setButtonMore(named: k_buttonMoreStop, image: NCCollectionCommonImages.cellButtonStop)
             } else {
                 cell.progressView.isHidden = true
                 cell.progressView.progress = progress
-                cell.setButtonMore(named: "more")
+                cell.setButtonMore(named: k_buttonMoreMore, image: NCCollectionCommonImages.cellButtonMore)
             }
             // Write status on Label Info
             switch metadata.status {
@@ -399,11 +403,11 @@ class NCCollectionCommon: NSObject {
             // Transfer
             if metadata.status == k_metadataStatusInDownload || metadata.status == k_metadataStatusDownloading ||  metadata.status >= k_metadataStatusTypeUpload {
                 cell.progressView.isHidden = false
-                cell.setButtonMore(named: "stop")
+                cell.setButtonMore(named: k_buttonMoreStop, image: NCCollectionCommonImages.cellButtonStop)
             } else {
                 cell.progressView.isHidden = true
                 cell.progressView.progress = 0.0
-                cell.setButtonMore(named: "more")
+                cell.setButtonMore(named: k_buttonMoreMore, image: NCCollectionCommonImages.cellButtonMore)
             }
             
             // Live Photo

+ 4 - 4
iOSClient/Main/NCCollectionViewCommon.swift

@@ -484,7 +484,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                             if progress > 0 {
                                 cell.progressView?.isHidden = false
                                 cell.progressView?.progress = progress
-                                cell.setButtonMore(named: "stop")
+                                cell.setButtonMore(named: k_buttonMoreStop, image: NCCollectionCommon.NCCollectionCommonImages.cellButtonStop)
                                 if status == k_metadataStatusInDownload {
                                     cell.labelInfo.text = CCUtility.transformedSize(totalBytesExpected) + " - ↓ " + CCUtility.transformedSize(totalBytes)
                                 } else if status == k_metadataStatusInUpload {
@@ -496,7 +496,7 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
                             if progress > 0 {
                                 cell.progressView.isHidden = false
                                 cell.progressView.progress = progress
-                                cell.setButtonMore(named: "stop")
+                                cell.setButtonMore(named: k_buttonMoreStop, image: NCCollectionCommon.NCCollectionCommonImages.cellButtonStop)
                             }
                         }
                     }
@@ -657,9 +657,9 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         guard let metadata = NCManageDatabase.sharedInstance.getMetadataFromOcId(objectId) else { return }
         guard let tabBarController = self.tabBarController else { return }
 
-        if namedButtonMore == "more" {
+        if namedButtonMore == k_buttonMoreMore {
             toggleMoreMenu(viewController: tabBarController, metadata: metadata)
-        } else if namedButtonMore == "stop" {
+        } else if namedButtonMore == k_buttonMoreStop {
             NCNetworking.shared.cancelTransferMetadata(metadata) { }
         }
     }