NCTrashListCell.swift 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 Foundation
  24. import UIKit
  25. class NCTrashListCell: UICollectionViewCell {
  26. @IBOutlet weak var imageItem: UIImageView!
  27. @IBOutlet weak var imageItemLeftConstraint: NSLayoutConstraint!
  28. @IBOutlet weak var imageSelect: UIImageView!
  29. @IBOutlet weak var labelTitle: UILabel!
  30. @IBOutlet weak var labelInfo: UILabel!
  31. @IBOutlet weak var imageRestore: UIImageView!
  32. @IBOutlet weak var imageMore: UIImageView!
  33. @IBOutlet weak var buttonMore: UIButton!
  34. @IBOutlet weak var buttonRestore: UIButton!
  35. @IBOutlet weak var separator: UIView!
  36. var delegate: NCTrashListCellDelegate?
  37. var objectId = ""
  38. var indexPath = IndexPath()
  39. override func awakeFromNib() {
  40. super.awakeFromNib()
  41. imageRestore.image = UIImage(named: "restore")!.image(color: NCBrandColor.shared.optionItem, size: 25)
  42. imageMore.image = UIImage(named: "more")!.image(color: NCBrandColor.shared.optionItem, size: 25)
  43. imageItem.layer.cornerRadius = 6
  44. imageItem.layer.masksToBounds = true
  45. separator.backgroundColor = NCBrandColor.shared.separator
  46. }
  47. @IBAction func touchUpInsideMore(_ sender: Any) {
  48. delegate?.tapMoreListItem(with: objectId, image: imageItem.image, sender: sender)
  49. }
  50. @IBAction func touchUpInsideRestore(_ sender: Any) {
  51. delegate?.tapRestoreListItem(with: objectId, image: imageItem.image, sender: sender)
  52. }
  53. func selectMode(_ status: Bool) {
  54. if status {
  55. imageItemLeftConstraint.constant = 45
  56. imageSelect.isHidden = false
  57. } else {
  58. imageItemLeftConstraint.constant = 10
  59. imageSelect.isHidden = true
  60. backgroundView = nil
  61. }
  62. }
  63. func selected(_ status: Bool) {
  64. if status {
  65. imageSelect.image = NCCollectionCommon.images.checkedYes
  66. let blurEffect = UIBlurEffect(style: .extraLight)
  67. let blurEffectView = UIVisualEffectView(effect: blurEffect)
  68. blurEffectView.frame = self.bounds
  69. blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
  70. blurEffectView.backgroundColor = NCBrandColor.shared.brandElement.withAlphaComponent(0.2)
  71. backgroundView = blurEffectView
  72. } else {
  73. imageSelect.image = NCCollectionCommon.images.checkedNo
  74. backgroundView = nil
  75. }
  76. }
  77. }
  78. protocol NCTrashListCellDelegate {
  79. func tapRestoreListItem(with objectId: String, image: UIImage?, sender: Any)
  80. func tapMoreListItem(with objectId: String, image: UIImage?, sender: Any)
  81. }