AppDelegate+Appearance.swift 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // AppDelegate+Appearance.swift
  3. // SheeeeeeeeetExample
  4. //
  5. // Created by Daniel Saidi on 2018-10-08.
  6. // Copyright © 2018 Daniel Saidi. All rights reserved.
  7. //
  8. /*
  9. This extension isolates how the example app applies colors,
  10. fonts etc to the example action sheets.
  11. */
  12. import UIKit
  13. import Sheeeeeeeeet
  14. extension AppDelegate {
  15. func applyAppearance() {
  16. applyViewAppearances()
  17. applyColors()
  18. applyFonts()
  19. applyHeights()
  20. applyIcons()
  21. applySelectItemAppearances()
  22. applySeparatorInsets()
  23. applyPopoverWidth()
  24. }
  25. }
  26. private extension AppDelegate {
  27. func applyViewAppearances() {
  28. // ActionSheetBackgroundView.appearance().backgroundColor = .purple
  29. ActionSheetHeaderView.appearance().cornerRadius = 10
  30. ActionSheetTableView.appearance().cornerRadius = 10
  31. // ActionSheetTableView.appearance().separatorLineColor = .purple
  32. // ActionSheetItemTableView.appearance().cornerRadius = 20
  33. // ActionSheetTableView.appearance(whenContainedInInstancesOf: [MultiSelectActionSheet.self]).cornerRadius = 20
  34. }
  35. func applyColors() {
  36. ActionSheetItemCell.appearance().titleColor = .darkText
  37. ActionSheetItemCell.appearance().subtitleColor = .exampleBlue
  38. ActionSheetItemCell.appearance().tintColor = .darkText
  39. // ActionSheetItemCell.appearance().separatorColor = .red
  40. // ActionSheetItemCell.appearance().backgroundColor = red
  41. // ActionSheetItemCell.appearance(whenContainedInInstancesOf: [ActionSheetItemTableView.self]).backgroundColor = .purple
  42. ActionSheetOkButtonCell.appearance().titleColor = .darkGray
  43. ActionSheetCancelButtonCell.appearance().titleColor = .lightGray
  44. ActionSheetDangerButtonCell.appearance().titleColor = .examplePink
  45. }
  46. func applyFonts() {
  47. ActionSheetItemCell.appearance().titleFont = .robotoRegular(size: 17)
  48. ActionSheetItemCell.appearance().subtitleFont = .robotoRegular(size: 14)
  49. ActionSheetLinkItemCell.appearance().titleFont = .robotoRegular(size: 17)
  50. ActionSheetMultiSelectToggleItemCell.appearance().titleFont = .robotoMedium(size: 13)
  51. ActionSheetSectionTitleCell.appearance().titleFont = .robotoMedium(size: 13)
  52. ActionSheetTitleCell.appearance().titleFont = .robotoMedium(size: 15)
  53. ActionSheetOkButtonCell.appearance().titleFont = .robotoBlack(size: 17)
  54. ActionSheetDangerButtonCell.appearance().titleFont = .robotoMedium(size: 17)
  55. ActionSheetCancelButtonCell.appearance().titleFont = .robotoRegular(size: 17)
  56. }
  57. func applyHeights() {
  58. ActionSheetSectionTitle.height = 20
  59. ActionSheetSectionMargin.height = 20
  60. }
  61. func applyIcons() {
  62. ActionSheetLinkItemCell.appearance().linkIcon = UIImage(named: "ic_arrow_right")
  63. }
  64. func applySelectItemAppearances() {
  65. ActionSheetSelectItemCell.appearance().selectedIcon = UIImage(named: "ic_checkmark")
  66. ActionSheetSelectItemCell.appearance().unselectedIcon = UIImage(named: "ic_empty")
  67. ActionSheetSelectItemCell.appearance().selectedTintColor = .exampleBlue
  68. ActionSheetSelectItemCell.appearance().selectedTitleColor = .exampleGreen
  69. ActionSheetSelectItemCell.appearance().selectedIconColor = .examplePurple
  70. ActionSheetSingleSelectItemCell.appearance().selectedTintColor = .exampleGreen
  71. ActionSheetSingleSelectItemCell.appearance().selectedTitleFont = .robotoMedium(size: 35)
  72. ActionSheetSingleSelectItemCell.appearance().selectedSubtitleFont = .robotoMedium(size: 25)
  73. ActionSheetSingleSelectItemCell.appearance().selectedTitleColor = .examplePurple
  74. ActionSheetSingleSelectItemCell.appearance().selectedIconColor = .exampleBlue
  75. ActionSheetMultiSelectItemCell.appearance().tintColor = UIColor.darkText.withAlphaComponent(0.4)
  76. ActionSheetMultiSelectItemCell.appearance().titleColor = UIColor.darkText.withAlphaComponent(0.4)
  77. ActionSheetMultiSelectItemCell.appearance().selectedTintColor = .examplePurple
  78. ActionSheetMultiSelectItemCell.appearance().selectedTitleColor = .exampleBlue
  79. ActionSheetMultiSelectItemCell.appearance().selectedIconColor = .exampleGreen
  80. ActionSheetMultiSelectToggleItemCell.appearance().selectAllSubtitleColor = .lightGray
  81. ActionSheetMultiSelectToggleItemCell.appearance().deselectAllSubtitleColor = .exampleRed
  82. }
  83. func applySeparatorInsets() {
  84. ActionSheetItemCell.appearance().separatorInset = .zero
  85. ActionSheetTitleCell.appearance().separatorInset = .hiddenSeparator
  86. ActionSheetSectionTitleCell.appearance().separatorInset = .hiddenSeparator
  87. ActionSheetSectionMarginCell.appearance().separatorInset = .hiddenSeparator
  88. ActionSheetMultiSelectToggleItemCell.appearance().separatorInset = .hiddenSeparator
  89. }
  90. func applyPopoverWidth() {
  91. // ActionSheet.preferredPopoverWidth = 700
  92. }
  93. }