marinofaggiana 4 жил өмнө
parent
commit
ccab5429d9

+ 25 - 1
iOSClient/Main/Cell/NCGridCell.swift

@@ -24,7 +24,7 @@
 import Foundation
 import UIKit
 
-class NCGridCell: UICollectionViewCell, NCImageCellProtocol {
+class NCGridCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCellProtocol {
     
     @IBOutlet weak var imageItem: UIImageView!
     
@@ -59,6 +59,18 @@ class NCGridCell: UICollectionViewCell, NCImageCellProtocol {
         progressView.transform = CGAffineTransform(scaleX: 1.0, y: 0.5)
         progressView.trackTintColor = .clear
         
+        let longPressedGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPress(gestureRecognizer:)))
+        longPressedGesture.minimumPressDuration = 0.5
+        longPressedGesture.delegate = self
+        longPressedGesture.delaysTouchesBegan = true
+        self.addGestureRecognizer(longPressedGesture)
+        
+        let longPressedGestureMore = UILongPressGestureRecognizer(target: self, action: #selector(longPressInsideMore(gestureRecognizer:)))
+        longPressedGestureMore.minimumPressDuration = 0.5
+        longPressedGestureMore.delegate = self
+        longPressedGestureMore.delaysTouchesBegan = true
+        buttonMore.addGestureRecognizer(longPressedGestureMore)
+        
         setButtonMore(named: "more")
     }
     
@@ -75,8 +87,20 @@ class NCGridCell: UICollectionViewCell, NCImageCellProtocol {
         namedButtonMore = named
         buttonMore.setImage(CCGraphics.changeThemingColorImage(UIImage.init(named: named), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem), for: UIControl.State.normal)
     }
+    
+    @objc func longPressInsideMore(gestureRecognizer: UILongPressGestureRecognizer) {
+        if gestureRecognizer.state != .began { return }
+        delegate?.longPressMoreGridItem(with: objectId, namedButtonMore: namedButtonMore, gestureRecognizer: gestureRecognizer)
+    }
+    
+    @objc func longPress(gestureRecognizer: UILongPressGestureRecognizer) {
+        if gestureRecognizer.state != .began { return }
+        delegate?.longPressGridItem(with: objectId, gestureRecognizer: gestureRecognizer)
+    }
 }
 
 protocol NCGridCellDelegate {
     func tapMoreGridItem(with objectId: String, namedButtonMore: String, sender: Any)
+    func longPressMoreGridItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer)
+    func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer)
 }

+ 25 - 1
iOSClient/Main/Cell/NCListCell.swift

@@ -24,7 +24,7 @@
 import Foundation
 import UIKit
 
-class NCListCell: UICollectionViewCell, NCImageCellProtocol {
+class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCImageCellProtocol {
     
     @IBOutlet weak var imageItem: UIImageView!
     @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint!
@@ -73,6 +73,18 @@ class NCListCell: UICollectionViewCell, NCImageCellProtocol {
 
         separator.backgroundColor = NCBrandColor.sharedInstance.separator
         
+        let longPressedGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPress(gestureRecognizer:)))
+        longPressedGesture.minimumPressDuration = 0.5
+        longPressedGesture.delegate = self
+        longPressedGesture.delaysTouchesBegan = true
+        self.addGestureRecognizer(longPressedGesture)
+        
+        let longPressedGestureMore = UILongPressGestureRecognizer(target: self, action: #selector(longPressInsideMore(gestureRecognizer:)))
+        longPressedGestureMore.minimumPressDuration = 0.5
+        longPressedGestureMore.delegate = self
+        longPressedGestureMore.delaysTouchesBegan = true
+        buttonMore.addGestureRecognizer(longPressedGestureMore)
+        
         setButtonMore(named: "more")
     }
     
@@ -89,6 +101,16 @@ class NCListCell: UICollectionViewCell, NCImageCellProtocol {
         delegate?.tapMoreListItem(with: objectId, namedButtonMore: namedButtonMore, sender: sender)
     }
     
+    @objc func longPressInsideMore(gestureRecognizer: UILongPressGestureRecognizer) {
+        if gestureRecognizer.state != .began { return }
+        delegate?.longPressMoreListItem(with: objectId, namedButtonMore: namedButtonMore, gestureRecognizer: gestureRecognizer)
+    }
+    
+    @objc func longPress(gestureRecognizer: UILongPressGestureRecognizer) {
+        if gestureRecognizer.state != .began { return }
+        delegate?.longPressListItem(with: objectId, gestureRecognizer: gestureRecognizer)
+    }
+    
     func setButtonMore(named: String) {
         namedButtonMore = named
         imageMore.image = CCGraphics.changeThemingColorImage(UIImage.init(named: named), width: 50, height: 50, color: NCBrandColor.sharedInstance.optionItem)
@@ -98,4 +120,6 @@ class NCListCell: UICollectionViewCell, NCImageCellProtocol {
 protocol NCListCellDelegate {
     func tapShareListItem(with objectId: String, sender: Any)
     func tapMoreListItem(with objectId: String, namedButtonMore: String, sender: Any)
+    func longPressMoreListItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer)
+    func longPressListItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer)
 }

+ 12 - 0
iOSClient/Main/Collection/NCCollectionViewCommon.swift

@@ -601,6 +601,18 @@ class NCCollectionViewCommon: UIViewController, UIGestureRecognizerDelegate, UIS
         }
     }
     
+    func longPressListItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
+    
+    func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
+    
+    func longPressMoreListItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
+    
+    func longPressMoreGridItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
+    
     // MARK: SEGUE
     
     @objc func segue(metadata: tableMetadata) {

+ 12 - 0
iOSClient/Select/NCSelect.swift

@@ -336,6 +336,18 @@ class NCSelect: UIViewController, UIGestureRecognizerDelegate, NCListCellDelegat
     
     func tapRichWorkspace(sender: Any) {
     }
+    
+    func longPressListItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
+    
+    func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
+    
+    func longPressMoreListItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
+    
+    func longPressMoreGridItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
 }
 
 // MARK: - Collection View

+ 5 - 0
iOSClient/Trash/NCTrash.swift

@@ -379,7 +379,12 @@ class NCTrash: UIViewController, UIGestureRecognizerDelegate, NCTrashListCellDel
             collectionView(self.collectionView, didSelectItemAt: indexPath!)
         }
     }
+
+    func longPressGridItem(with objectId: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
     
+    func longPressMoreGridItem(with objectId: String, namedButtonMore: String, gestureRecognizer: UILongPressGestureRecognizer) {
+    }
 }
 
 // MARK: - Collection View