@@ -28,7 +28,6 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
2828 @IBOutlet weak var imageSelect : UIImageView !
2929 @IBOutlet weak var imageStatus : UIImageView !
3030 @IBOutlet weak var imageFavorite : UIImageView !
31- @IBOutlet weak var imageFavoriteBackground : UIImageView !
3231 @IBOutlet weak var imageLocal : UIImageView !
3332 @IBOutlet weak var labelTitle : UILabel !
3433 @IBOutlet weak var labelInfo : UILabel !
@@ -37,31 +36,26 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
3736 @IBOutlet weak var buttonShared : UIButton !
3837 @IBOutlet weak var imageMore : UIImageView !
3938 @IBOutlet weak var buttonMore : UIButton !
39+ @IBOutlet weak var progressView : UIProgressView !
4040 @IBOutlet weak var separator : UIView !
41- @IBOutlet weak var tag0 : UILabel !
42- @IBOutlet weak var tag1 : UILabel !
43-
41+ @IBOutlet weak var labelShared : UILabel !
4442 @IBOutlet weak var imageItemLeftConstraint : NSLayoutConstraint !
4543 @IBOutlet weak var separatorHeightConstraint : NSLayoutConstraint !
46- @IBOutlet weak var titleTrailingConstraint : NSLayoutConstraint !
4744 @IBOutlet weak var subInfoTrailingConstraint : NSLayoutConstraint !
4845
49- var ocId = " "
50- var ocIdTransfer = " "
51- var user = " "
46+ private var objectId = " "
47+ private var user = " "
48+ var indexPath = IndexPath ( )
5249
5350 weak var listCellDelegate : NCListCellDelegate ?
51+ var namedButtonMore = " "
5452
5553 var fileAvatarImageView : UIImageView ? {
5654 return imageShared
5755 }
58- var fileOcId : String ? {
59- get { return ocId }
60- set { ocId = newValue ?? " " }
61- }
62- var fileOcIdTransfer : String ? {
63- get { return ocIdTransfer }
64- set { ocIdTransfer = newValue ?? " " }
56+ var fileObjectId : String ? {
57+ get { return objectId }
58+ set { objectId = newValue ?? " " }
6559 }
6660 var filePreviewImageView : UIImageView ? {
6761 get { return imageItem }
@@ -83,6 +77,14 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
8377 get { return labelSubinfo }
8478 set { labelSubinfo = newValue }
8579 }
80+ var fileProgressView : UIProgressView ? {
81+ get { return progressView }
82+ set { progressView = newValue }
83+ }
84+ var fileSelectImage : UIImageView ? {
85+ get { return imageSelect }
86+ set { imageSelect = newValue }
87+ }
8688 var fileStatusImage : UIImageView ? {
8789 get { return imageStatus }
8890 set { imageStatus = newValue }
@@ -107,88 +109,92 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
107109 get { return separator }
108110 set { separator = newValue }
109111 }
110-
112+ var fileSharedLabel : UILabel ? {
113+ get { return labelShared }
114+ set { labelShared = newValue }
115+ }
111116 override func awakeFromNib( ) {
112117 super. awakeFromNib ( )
113- initCell ( )
114- }
115118
116- override func prepareForReuse( ) {
117- super. prepareForReuse ( )
118- initCell ( )
119- }
119+ imageItem. layer. cornerRadius = 6
120+ imageItem. layer. masksToBounds = true
120121
121- func initCell ( ) {
122+ // use entire cell as accessibility element
122123 accessibilityHint = nil
123124 accessibilityLabel = nil
124125 accessibilityValue = nil
125126 isAccessibilityElement = true
126127
127- imageItem. image = nil
128- imageItem. layer. cornerRadius = 6
129- imageItem. layer. masksToBounds = true
130- imageStatus. image = nil
131- imageFavorite. image = nil
132- imageFavoriteBackground. isHidden = true
133- imageLocal. image = nil
134- labelTitle. text = " "
135- labelInfo. text = " "
136- labelSubinfo. text = " "
137- imageShared. image = nil
138- imageMore. image = nil
139- separatorHeightConstraint. constant = 0.5
140- tag0. text = " "
141- tag1. text = " "
142- titleInfoTrailingDefault ( )
128+ progressView. tintColor = NCBrandColor . shared. brandElement
129+ progressView. transform = CGAffineTransform ( scaleX: 1.0 , y: 0.5 )
130+ progressView. trackTintColor = . clear
143131
144132 let longPressedGesture = UILongPressGestureRecognizer ( target: self , action: #selector( longPress ( gestureRecognizer: ) ) )
145133 longPressedGesture. minimumPressDuration = 0.5
146134 longPressedGesture. delegate = self
147135 longPressedGesture. delaysTouchesBegan = true
148136 self . addGestureRecognizer ( longPressedGesture)
137+
138+ separator. backgroundColor = . separator
139+ separatorHeightConstraint. constant = 0.5
140+
141+ labelTitle. text = " "
142+ labelInfo. text = " "
143+ labelTitle. textColor = . label
144+ labelInfo. textColor = . systemGray
145+ labelSubinfo. textColor = . systemGray
146+ }
147+
148+ override func prepareForReuse( ) {
149+ super. prepareForReuse ( )
150+ imageItem. backgroundColor = nil
151+ accessibilityHint = nil
152+ accessibilityLabel = nil
153+ accessibilityValue = nil
149154 }
150155
151156 override func snapshotView( afterScreenUpdates afterUpdates: Bool ) -> UIView ? {
152157 return nil
153158 }
154159
155160 @IBAction func touchUpInsideShare( _ sender: Any ) {
156- listCellDelegate? . tapShareListItem ( with: ocId , ocIdTransfer : ocIdTransfer , sender: sender)
161+ listCellDelegate? . tapShareListItem ( with: objectId , indexPath : indexPath , sender: sender)
157162 }
158163
159164 @IBAction func touchUpInsideMore( _ sender: Any ) {
160- listCellDelegate? . tapMoreListItem ( with: ocId , ocIdTransfer : ocIdTransfer , image: imageItem. image, sender: sender)
165+ listCellDelegate? . tapMoreListItem ( with: objectId , namedButtonMore : namedButtonMore , image: imageItem. image, indexPath : indexPath , sender: sender)
161166 }
162167
163168 @objc func longPress( gestureRecognizer: UILongPressGestureRecognizer ) {
164- listCellDelegate? . longPressListItem ( with: ocId , ocIdTransfer : ocIdTransfer , gestureRecognizer: gestureRecognizer)
169+ listCellDelegate? . longPressListItem ( with: objectId , indexPath : indexPath , gestureRecognizer: gestureRecognizer)
165170 }
166171
167172 fileprivate func setA11yActions( ) {
173+ let moreName = namedButtonMore == NCGlobal . shared. buttonMoreStop ? " _cancel_ " : " _more_ "
168174 self . accessibilityCustomActions = [
169175 UIAccessibilityCustomAction (
170176 name: NSLocalizedString ( " _share_ " , comment: " " ) ,
171177 target: self ,
172178 selector: #selector( touchUpInsideShare) ) ,
173179 UIAccessibilityCustomAction (
174- name: NSLocalizedString ( " _more_ " , comment: " " ) ,
180+ name: NSLocalizedString ( moreName , comment: " " ) ,
175181 target: self ,
176182 selector: #selector( touchUpInsideMore) )
177183 ]
178184 }
179185
180186 func titleInfoTrailingFull( ) {
181- titleTrailingConstraint. constant = 10
182187 subInfoTrailingConstraint. constant = 10
183188 }
184189
185190 func titleInfoTrailingDefault( ) {
186- titleTrailingConstraint. constant = 90
187191 subInfoTrailingConstraint. constant = 90
188192 }
189193
190- func setButtonMore( image: UIImage ) {
194+ func setButtonMore( named: String , image: UIImage ) {
195+ namedButtonMore = named
191196 imageMore. image = image
197+
192198 setA11yActions ( )
193199 }
194200
@@ -202,6 +208,10 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
202208 buttonShared. isHidden = status
203209 }
204210
211+ func hideSeparator( _ status: Bool ) {
212+ separator. isHidden = status
213+ }
214+
205215 func selected( _ status: Bool , isEditMode: Bool ) {
206216 if isEditMode {
207217 imageItemLeftConstraint. constant = 45
@@ -227,70 +237,32 @@ class NCListCell: UICollectionViewCell, UIGestureRecognizerDelegate, NCCellProto
227237 blurEffectView? . backgroundColor = . lightGray
228238 blurEffectView? . frame = self . bounds
229239 blurEffectView? . autoresizingMask = [ . flexibleWidth, . flexibleHeight]
230- imageSelect. image = NCImageCache . shared . getImageCheckedYes ( )
240+ imageSelect. image = NCImageCache . images . checkedYes
231241 backgroundView = blurEffectView
232242 separator. isHidden = true
233243 } else {
234- imageSelect. image = NCImageCache . shared . getImageCheckedNo ( )
244+ imageSelect. image = NCImageCache . images . checkedNo
235245 backgroundView = nil
236246 separator. isHidden = false
237247 }
238248
239249 }
240250
241251 func writeInfoDateSize( date: NSDate , size: Int64 ) {
242- labelInfo. text = NCUtility ( ) . dateDiff ( date as Date )
243- labelSubinfo. text = " · " + NCUtilityFileSystem ( ) . transformedSize ( size )
252+ labelInfo. text = NCUtility ( ) . dateDiff ( date as Date ) + " · " + NCUtilityFileSystem ( ) . transformedSize ( size )
253+ labelSubinfo. text = " "
244254 }
245255
246256 func setAccessibility( label: String , value: String ) {
247257 accessibilityLabel = label
248258 accessibilityValue = value
249259 }
250-
251- func setTags( tags: [ String ] ) {
252- if tags. isEmpty {
253- tag0. isHidden = true
254- tag1. isHidden = true
255- labelInfo. isHidden = false
256- labelSubinfo. isHidden = false
257- } else {
258- tag0. isHidden = false
259- tag1. isHidden = true
260- labelInfo. isHidden = true
261- labelSubinfo. isHidden = true
262-
263- if let tag = tags. first {
264- tag0. text = tag
265- if tags. count > 1 {
266- tag1. isHidden = false
267- tag1. text = " + \( tags. count - 1 ) "
268- }
269- }
270- }
271- }
272-
273- func setIconOutlines( ) {
274- imageFavoriteBackground. isHidden = fileFavoriteImage? . image == nil
275-
276- if imageStatus. image != nil {
277- imageStatus. makeCircularBackground ( withColor: . systemBackground)
278- } else {
279- imageStatus. backgroundColor = . clear
280- }
281-
282- if imageLocal. image != nil {
283- imageLocal. makeCircularBackground ( withColor: . systemBackground)
284- } else {
285- imageLocal. backgroundColor = . clear
286- }
287- }
288260}
289261
290262protocol NCListCellDelegate : AnyObject {
291- func tapShareListItem( with ocId : String , ocIdTransfer : String , sender: Any )
292- func tapMoreListItem( with ocId : String , ocIdTransfer : String , image: UIImage ? , sender: Any )
293- func longPressListItem( with ocId : String , ocIdTransfer : String , gestureRecognizer: UILongPressGestureRecognizer )
263+ func tapShareListItem( with objectId : String , indexPath : IndexPath , sender: Any )
264+ func tapMoreListItem( with objectId : String , namedButtonMore : String , image: UIImage ? , indexPath : IndexPath , sender: Any )
265+ func longPressListItem( with objectId : String , indexPath : IndexPath , gestureRecognizer: UILongPressGestureRecognizer )
294266}
295267
296268// MARK: - List Layout
0 commit comments