ContactTrickEntry.swift 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import SwiftUI
  2. struct ContactTrickEntry: Hashable {
  3. var layout: ContactTrickLayout = .single
  4. var ring1: ContactTrickLargeRing = .none
  5. var primary: ContactTrickValue = .glucose
  6. var top: ContactTrickValue = .none
  7. var bottom: ContactTrickValue = .none
  8. var contactId: String? = nil
  9. var darkMode: Bool = true
  10. var ringWidth: ringWidth = .regular
  11. var ringGap: ringGap = .small
  12. var fontSize: fontSize = .regular
  13. var secondaryFontSize: fontSize = .small
  14. var fontWeight: Font.Weight = .medium
  15. var fontWidth: Font.Width = .standard
  16. enum fontSize: Int {
  17. case tiny = 200
  18. case small = 250
  19. case regular = 300
  20. case large = 400
  21. var displayName: String {
  22. switch self {
  23. case .tiny: return "Tiny"
  24. case .small: return "Small"
  25. case .regular: return "Regular"
  26. case .large: return "Large"
  27. }
  28. }
  29. }
  30. enum ringWidth: Int {
  31. case tiny = 3
  32. case small = 5
  33. case regular = 7
  34. case medium = 10
  35. case large = 15
  36. var displayName: String {
  37. switch self {
  38. case .tiny: return "Tiny"
  39. case .small: return "Small"
  40. case .regular: return "Regular"
  41. case .medium: return "Medium"
  42. case .large: return "Large"
  43. }
  44. }
  45. }
  46. enum ringGap: Int {
  47. case tiny = 1
  48. case small = 2
  49. case regular = 3
  50. case medium = 4
  51. case large = 5
  52. var displayName: String {
  53. switch self {
  54. case .tiny: return "Tiny"
  55. case .small: return "Small"
  56. case .regular: return "Regular"
  57. case .medium: return "Medium"
  58. case .large: return "Large"
  59. }
  60. }
  61. }
  62. }
  63. protocol ContactTrickObserver {
  64. func basalProfileDidChange(_ entry: [ContactTrickEntry])
  65. }
  66. //
  67. // extension ContactTrickEntry {
  68. // private enum CodingKeys: String, CodingKey {
  69. // case layout
  70. // case ring1
  71. // case primary
  72. // case top
  73. // case bottom
  74. // case contactId
  75. // case darkMode
  76. // case ringWidth
  77. // case ringGap
  78. // case fontSize
  79. // case secondaryFontSize
  80. // case fontWeight
  81. // case fontWidth
  82. // }
  83. //
  84. // init(from decoder: Decoder) throws {
  85. // let container = try decoder.container(keyedBy: CodingKeys.self)
  86. // let layout = try container.decodeIfPresent(ContactTrickLayout.self, forKey: .layout) ?? .single
  87. // let ring1 = try container.decodeIfPresent(ContactTrickLargeRing.self, forKey: .ring1) ?? .none
  88. // let primary = try container.decodeIfPresent(ContactTrickValue.self, forKey: .primary) ?? .glucose
  89. // let top = try container.decodeIfPresent(ContactTrickValue.self, forKey: .top) ?? .none
  90. // let bottom = try container.decodeIfPresent(ContactTrickValue.self, forKey: .bottom) ?? .none
  91. // let contactId = try container.decodeIfPresent(String.self, forKey: .contactId)
  92. // let darkMode = try container.decodeIfPresent(Bool.self, forKey: .darkMode) ?? true
  93. // let ringWidth = try container.decodeIfPresent(Int.self, forKey: .ringWidth) ?? 7
  94. // let ringGap = try container.decodeIfPresent(Int.self, forKey: .ringGap) ?? 2
  95. // let fontSize = try container.decodeIfPresent(Int.self, forKey: .fontSize) ?? 300
  96. // let secondaryFontSize = try container.decodeIfPresent(Int.self, forKey: .secondaryFontSize) ?? 250
  97. // let fontWeight = try container.decodeIfPresent(Font.Weight.self, forKey: .fontWeight) ?? .medium
  98. // let fontWidth = try container.decodeIfPresent(Font.Width.self, forKey: .fontWidth) ?? .standard
  99. //
  100. // self = ContactTrickEntry(
  101. // layout: layout,
  102. // ring1: ring1,
  103. // primary: primary,
  104. // top: top,
  105. // bottom: bottom,
  106. // contactId: contactId,
  107. // darkMode: darkMode,
  108. // ringWidth: ringWidth,
  109. // ringGap: ringGap,
  110. // fontSize: fontSize,
  111. // secondaryFontSize: secondaryFontSize,
  112. // fontWeight: fontWeight,
  113. // fontWidth: fontWidth
  114. // )
  115. // }
  116. // }