NCTrashListCell.swift 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // NCTrashListCell.swift
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 08/10/2018.
  6. // Copyright © 2018 Marino Faggiana. All rights reserved.
  7. //
  8. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  9. //
  10. // This program is free software: you can redistribute it and/or modify
  11. // it under the terms of the GNU General Public License as published by
  12. // the Free Software Foundation, either version 3 of the License, or
  13. // (at your option) any later version.
  14. //
  15. // This program is distributed in the hope that it will be useful,
  16. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. // GNU General Public License for more details.
  19. //
  20. // You should have received a copy of the GNU General Public License
  21. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. //
  23. import UIKit
  24. class NCTrashListCell: UICollectionViewCell {
  25. @IBOutlet weak var imageItem: UIImageView!
  26. @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint!
  27. @IBOutlet weak var imageSelect: UIImageView!
  28. @IBOutlet weak var labelTitle: UILabel!
  29. @IBOutlet weak var labelInfo: UILabel!
  30. @IBOutlet weak var imageRestore: UIImageView!
  31. @IBOutlet weak var imageMore: UIImageView!
  32. @IBOutlet weak var buttonMore: UIButton!
  33. @IBOutlet weak var buttonRestore: UIButton!
  34. @IBOutlet weak var separator: UIView!
  35. @IBOutlet weak var separatorHeightConstraint: NSLayoutConstraint!
  36. var delegate: NCTrashListCellDelegate?
  37. var objectId = ""
  38. var indexPath = IndexPath()
  39. override func awakeFromNib() {
  40. super.awakeFromNib()
  41. imageRestore.image = NCBrandColor.cacheImages.buttonRestore
  42. imageMore.image = NCBrandColor.cacheImages.buttonMore
  43. imageItem.layer.cornerRadius = 6
  44. imageItem.layer.masksToBounds = true
  45. separator.backgroundColor = NCBrandColor.shared.separator
  46. separatorHeightConstraint.constant = 0.5
  47. }
  48. @IBAction func touchUpInsideMore(_ sender: Any) {
  49. delegate?.tapMoreListItem(with: objectId, image: imageItem.image, sender: sender)
  50. }
  51. @IBAction func touchUpInsideRestore(_ sender: Any) {
  52. delegate?.tapRestoreListItem(with: objectId, image: imageItem.image, sender: sender)
  53. }
  54. func selectMode(_ status: Bool) {
  55. if status {
  56. imageItemLeftConstraint.constant = 45
  57. imageSelect.isHidden = false
  58. } else {
  59. imageItemLeftConstraint.constant = 10
  60. imageSelect.isHidden = true
  61. backgroundView = nil
  62. }
  63. }
  64. func selected(_ status: Bool) {
  65. if status {
  66. imageSelect.image = NCBrandColor.cacheImages.checkedYes
  67. let blurEffect = UIBlurEffect(style: .extraLight)
  68. let blurEffectView = UIVisualEffectView(effect: blurEffect)
  69. blurEffectView.frame = self.bounds
  70. blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  71. blurEffectView.backgroundColor = NCBrandColor.shared.brandElement.withAlphaComponent(0.2)
  72. backgroundView = blurEffectView
  73. } else {
  74. imageSelect.image = NCBrandColor.cacheImages.checkedNo
  75. backgroundView = nil
  76. }
  77. }
  78. }
  79. protocol NCTrashListCellDelegate {
  80. func tapRestoreListItem(with objectId: String, image: UIImage?, sender: Any)
  81. func tapMoreListItem(with objectId: String, image: UIImage?, sender: Any)
  82. }