Advertisement
Guest User

Untitled

a guest
Sep 20th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. struct TokenTypography {
  2.  
  3. // 1. Prepare base materials
  4.  
  5. /// a. Level 1 base settings
  6. private enum FontSize: CGFloat {
  7. case
  8. small = 12,
  9. medium = 17,
  10. large = 28
  11. }
  12. private enum FontFamily: String {
  13. case
  14. HelveticaNeue = "HelveticaNeue",
  15. Georgia = "Georgia"
  16. }
  17.  
  18. /// b. Level 2 tokens
  19. enum FontSizeToken: CGFloat {
  20. case caption, body, title
  21.  
  22. func getValue() -> CGFloat {
  23. switch self {
  24. case .caption:
  25. return FontSize.small.rawValue
  26. case .body:
  27. return FontSize.medium.rawValue
  28. case .title:
  29. return FontSize.large.rawValue
  30. }
  31. }
  32. }
  33. enum FontFamilyToken: String {
  34. case main, sub
  35.  
  36. func getValue() -> String {
  37. switch self {
  38. case .main:
  39. return FontFamily.HelveticaNeue.rawValue
  40. case .sub:
  41. return FontFamily.Georgia.rawValue
  42. }
  43. }
  44. }
  45.  
  46. // 2. Expose data
  47.  
  48. let mainFont: Font!
  49. let subFont: Font!
  50.  
  51. init() {
  52. self.mainFont = Font.custom(FontFamilyToken.main.getValue(), size: FontSizeToken.body.getValue())
  53. self.subFont = Font.custom(FontFamilyToken.sub.getValue(), size: FontSizeToken.caption.getValue())
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement