ActionSheetAppearance.swift 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. backgroundColor = copy.backgroundColor
  26. separatorColor = copy.separatorColor
  27. itemsBackgroundColor = copy.itemsBackgroundColor ?? backgroundColor
  28. itemsSeparatorColor = copy.itemsSeparatorColor ?? separatorColor
  29. buttonsSeparatorColor = copy.buttonsSeparatorColor ?? backgroundColor
  30. buttonsSeparatorColor = copy.buttonsSeparatorColor ?? separatorColor
  31. popover = ActionSheetPopoverAppearance(copy: copy.popover)
  32. item = ActionSheetItemAppearance(copy: copy.item)
  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. cancelButton = ActionSheetCancelButtonAppearance(copy: copy.cancelButton)
  41. dangerButton = ActionSheetDangerButtonAppearance(copy: copy.dangerButton)
  42. okButton = ActionSheetOkButtonAppearance(copy: copy.okButton)
  43. sectionMargin = ActionSheetSectionMarginAppearance(copy: copy.sectionMargin)
  44. sectionTitle = ActionSheetSectionTitleAppearance(copy: copy.sectionTitle)
  45. title = ActionSheetTitleAppearance(copy: copy.title)
  46. }
  47. // MARK: - Properties
  48. public var cornerRadius: CGFloat = 10
  49. public var contentInset: CGFloat = 15
  50. public var groupMargins: CGFloat = 15
  51. public var backgroundColor: UIColor?
  52. public var separatorColor: UIColor?
  53. public var itemsBackgroundColor: UIColor?
  54. public var itemsSeparatorColor: UIColor?
  55. public var buttonsBackgroundColor: UIColor?
  56. public var buttonsSeparatorColor: UIColor?
  57. // MARK: - Appearance Properties
  58. public static var standard = ActionSheetAppearance()
  59. public lazy var popover = ActionSheetPopoverAppearance(width: 300)
  60. // MARK: - Items
  61. public lazy var item = ActionSheetItemAppearance()
  62. public lazy var collectionItem = ActionSheetCollectionItemAppearance(copy: item)
  63. public lazy var customItem = ActionSheetCustomItemAppearance(copy: item)
  64. public lazy var linkItem = ActionSheetLinkItemAppearance(copy: item)
  65. public lazy var multiSelectItem = ActionSheetMultiSelectItemAppearance(copy: selectItem)
  66. public lazy var multiSelectToggleItem = ActionSheetMultiSelectToggleItemAppearance(copy: item)
  67. public lazy var selectItem = ActionSheetSelectItemAppearance(copy: item)
  68. public lazy var singleSelectItem = ActionSheetSingleSelectItemAppearance(copy: selectItem)
  69. // MARK: - Buttons
  70. public lazy var cancelButton = ActionSheetCancelButtonAppearance(copy: item)
  71. public lazy var dangerButton = ActionSheetDangerButtonAppearance(copy: item)
  72. public lazy var okButton = ActionSheetOkButtonAppearance(copy: item)
  73. // MARK: - Titles
  74. public lazy var sectionMargin = ActionSheetSectionMarginAppearance(copy: item)
  75. public lazy var sectionTitle = ActionSheetSectionTitleAppearance(copy: item)
  76. public lazy var title = ActionSheetTitleAppearance(copy: item)
  77. }