NCShareAdvancePermissionFooter.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // NCShareAdvancePermissionFooter.swift
  3. // Nextcloud
  4. //
  5. // Created by T-systems on 09/08/21.
  6. // Copyright © 2022 Henrik Storch. All rights reserved.
  7. //
  8. // Author Henrik Storch <henrik.storch@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. protocol NCShareAdvanceFotterDelegate: AnyObject {
  25. var isNewShare: Bool { get }
  26. func dismissShareAdvanceView(shouldSave: Bool)
  27. }
  28. class NCShareAdvancePermissionFooter: UIView {
  29. @IBOutlet weak var buttonCancel: UIButton!
  30. @IBOutlet weak var buttonNext: UIButton!
  31. weak var delegate: NCShareAdvanceFotterDelegate?
  32. func setupUI(delegate: NCShareAdvanceFotterDelegate?) {
  33. self.delegate = delegate
  34. backgroundColor = .clear
  35. buttonCancel.backgroundColor = .clear
  36. buttonCancel.addTarget(self, action: #selector(cancelClicked), for: .touchUpInside)
  37. buttonCancel.setTitle(NSLocalizedString("_cancel_", comment: ""), for: .normal)
  38. buttonCancel.layer.cornerRadius = 25
  39. buttonCancel.layer.masksToBounds = true
  40. buttonCancel.layer.borderWidth = 1
  41. buttonCancel.backgroundColor = NCBrandColor.shared.secondarySystemBackground
  42. buttonCancel.layer.borderColor = NCBrandColor.shared.systemGray.cgColor
  43. buttonCancel.setTitleColor(NCBrandColor.shared.label.withAlphaComponent(0.3), for: .highlighted)
  44. buttonNext.setTitle(NSLocalizedString(delegate?.isNewShare == true ? "_share_" : "_save_", comment: ""), for: .normal)
  45. buttonNext.layer.cornerRadius = 25
  46. buttonNext.layer.masksToBounds = true
  47. buttonNext.backgroundColor = NCBrandColor.shared.brand
  48. buttonNext.addTarget(self, action: #selector(nextClicked), for: .touchUpInside)
  49. buttonNext.setTitleColor(UIColor(white: 1, alpha: 0.3), for: .highlighted)
  50. }
  51. @objc func cancelClicked() {
  52. delegate?.dismissShareAdvanceView(shouldSave: false)
  53. }
  54. @objc func nextClicked() {
  55. delegate?.dismissShareAdvanceView(shouldSave: true)
  56. }
  57. }