ActionSheetAppearance.swift 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. //
  2. // ActionSheetAppearance.swift
  3. // Sheeeeeeeeet
  4. //
  5. // Created by Daniel Saidi on 2017-11-18.
  6. // Copyright © 2017 Daniel Saidi. All rights reserved.
  7. //
  8. /*
  9. This class is used to specify the appearance for all action
  10. sheets and action sheet items provided by Sheeeeeeeeet. Use
  11. `ActionSheetAppearance.standard` to style all action sheets
  12. in an entire app. You can then apply individual appearances
  13. to individual action sheets and item types.
  14. The `item` appearance property is used as the base template
  15. for all other item appearances.
  16. */
  17. import UIKit
  18. open class ActionSheetAppearance {
  19. // MARK: - Initialization
  20. public init() {}
  21. public init(copy: ActionSheetAppearance) {
  22. cornerRadius = copy.cornerRadius
  23. contentInset = copy.contentInset
  24. groupMargins = copy.groupMargins
  25. separatorColor = copy.separatorColor
  26. itemsSeparatorColor = copy.itemsSeparatorColor ?? separatorColor
  27. buttonsSeparatorColor = copy.buttonsSeparatorColor ?? separatorColor
  28. item = ActionSheetItemAppearance(copy: copy.item)
  29. popover = ActionSheetPopoverAppearance(copy: copy.popover)
  30. cancelButton = ActionSheetCancelButtonAppearance(copy: copy.cancelButton)
  31. dangerButton = ActionSheetDangerButtonAppearance(copy: copy.dangerButton)
  32. okButton = ActionSheetOkButtonAppearance(copy: copy.okButton)
  33. collectionItem = ActionSheetCollectionItemAppearance(copy: copy.collectionItem)
  34. customItem = ActionSheetCustomItemAppearance(copy: copy.customItem)
  35. linkItem = ActionSheetLinkItemAppearance(copy: copy.linkItem)
  36. multiSelectItem = ActionSheetMultiSelectItemAppearance(copy: copy.multiSelectItem)
  37. multiSelectToggleItem = ActionSheetMultiSelectToggleItemAppearance(copy: copy.multiSelectToggleItem)
  38. selectItem = ActionSheetSelectItemAppearance(copy: copy.selectItem)
  39. singleSelectItem = ActionSheetSingleSelectItemAppearance(copy: copy.singleSelectItem)
  40. sectionMargin = ActionSheetSectionMarginAppearance(copy: copy.sectionMargin)
  41. sectionTitle = ActionSheetSectionTitleAppearance(copy: copy.sectionTitle)
  42. title = ActionSheetTitleAppearance(copy: copy.title)
  43. }
  44. // MARK: - Properties
  45. public var cornerRadius: CGFloat = 10
  46. public var contentInset: CGFloat = 15
  47. public var groupMargins: CGFloat = 15
  48. public var separatorColor: UIColor?
  49. public var itemsSeparatorColor: UIColor?
  50. public var buttonsSeparatorColor: UIColor?
  51. // MARK: - Appearance Properties
  52. public static var standard = ActionSheetAppearance()
  53. public lazy var item: ActionSheetItemAppearance = {
  54. return ActionSheetItemAppearance()
  55. }()
  56. public lazy var popover: ActionSheetPopoverAppearance = {
  57. return ActionSheetPopoverAppearance(width: 300)
  58. }()
  59. // MARK: - Buttons
  60. public lazy var cancelButton: ActionSheetCancelButtonAppearance = {
  61. return ActionSheetCancelButtonAppearance(copy: item)
  62. }()
  63. public lazy var dangerButton: ActionSheetDangerButtonAppearance = {
  64. return ActionSheetDangerButtonAppearance(copy: item)
  65. }()
  66. public lazy var okButton: ActionSheetOkButtonAppearance = {
  67. return ActionSheetOkButtonAppearance(copy: item)
  68. }()
  69. // MARK: - Items
  70. public lazy var collectionItem: ActionSheetCollectionItemAppearance = {
  71. return ActionSheetCollectionItemAppearance(copy: item)
  72. }()
  73. public lazy var customItem: ActionSheetCustomItemAppearance = {
  74. return ActionSheetCustomItemAppearance(copy: item)
  75. }()
  76. public lazy var linkItem: ActionSheetLinkItemAppearance = {
  77. return ActionSheetLinkItemAppearance(copy: item)
  78. }()
  79. public lazy var multiSelectItem: ActionSheetMultiSelectItemAppearance = {
  80. return ActionSheetMultiSelectItemAppearance(copy: selectItem)
  81. }()
  82. public lazy var multiSelectToggleItem: ActionSheetMultiSelectToggleItemAppearance = {
  83. return ActionSheetMultiSelectToggleItemAppearance(copy: item)
  84. }()
  85. public lazy var selectItem: ActionSheetSelectItemAppearance = {
  86. return ActionSheetSelectItemAppearance(copy: item)
  87. }()
  88. public lazy var singleSelectItem: ActionSheetSingleSelectItemAppearance = {
  89. return ActionSheetSingleSelectItemAppearance(copy: selectItem)
  90. }()
  91. // MARK: - Titles
  92. public lazy var sectionMargin: ActionSheetSectionMarginAppearance = {
  93. return ActionSheetSectionMarginAppearance(copy: item)
  94. }()
  95. public lazy var sectionTitle: ActionSheetSectionTitleAppearance = {
  96. return ActionSheetSectionTitleAppearance(copy: item)
  97. }()
  98. public lazy var title: ActionSheetTitleAppearance = {
  99. return ActionSheetTitleAppearance(copy: item)
  100. }()
  101. }