NCMenuAction.swift 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // NCMenuAction.swift
  3. // Nextcloud
  4. //
  5. // Created by Philippe Weidmann on 16.01.20.
  6. // Copyright © 2020 Philippe Weidmann. All rights reserved.
  7. // Copyright © 2020 Marino Faggiana All rights reserved.
  8. //
  9. // Author Philippe Weidmann <philippe.weidmann@infomaniak.com>
  10. // Author Marino Faggiana <marino.faggiana@nextcloud.com>
  11. //
  12. // This program is free software: you can redistribute it and/or modify
  13. // it under the terms of the GNU General Public License as published by
  14. // the Free Software Foundation, either version 3 of the License, or
  15. // (at your option) any later version.
  16. //
  17. // This program is distributed in the hope that it will be useful,
  18. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. // GNU General Public License for more details.
  21. //
  22. // You should have received a copy of the GNU General Public License
  23. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. //
  25. import Foundation
  26. class NCMenuAction {
  27. let title: String
  28. let icon: UIImage
  29. let selectable: Bool
  30. var onTitle: String?
  31. var onIcon: UIImage?
  32. var selected: Bool = false
  33. var isOn: Bool = false
  34. var action: ((_ menuAction: NCMenuAction) -> Void)?
  35. init(title: String, icon: UIImage, action: ((_ menuAction: NCMenuAction) -> Void)?) {
  36. self.title = title
  37. self.icon = icon
  38. self.action = action
  39. self.selectable = false
  40. }
  41. init(title: String, icon: UIImage, onTitle: String? = nil, onIcon: UIImage? = nil, selected: Bool, on: Bool, action: ((_ menuAction: NCMenuAction) -> Void)?) {
  42. self.title = title
  43. self.icon = icon
  44. self.onTitle = onTitle ?? title
  45. self.onIcon = onIcon ?? icon
  46. self.action = action
  47. self.selected = selected
  48. self.isOn = on
  49. self.selectable = true
  50. }
  51. }