WatchConfigAppleWatchView.swift 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. import SwiftUI
  2. import Swinject
  3. struct WatchConfigAppleWatchView: View {
  4. let resolver: Resolver
  5. @ObservedObject var state: WatchConfig.StateModel
  6. @State private var shouldDisplayHint: Bool = false
  7. @State var hintDetent = PresentationDetent.large
  8. @State var selectedVerboseHint: String?
  9. @State var hintLabel: String?
  10. @State private var decimalPlaceholder: Decimal = 0.0
  11. @State private var booleanPlaceholder: Bool = false
  12. @Environment(\.colorScheme) var colorScheme
  13. var color: LinearGradient {
  14. colorScheme == .dark ? LinearGradient(
  15. gradient: Gradient(colors: [
  16. Color.bgDarkBlue,
  17. Color.bgDarkerDarkBlue
  18. ]),
  19. startPoint: .top,
  20. endPoint: .bottom
  21. )
  22. :
  23. LinearGradient(
  24. gradient: Gradient(colors: [Color.gray.opacity(0.1)]),
  25. startPoint: .top,
  26. endPoint: .bottom
  27. )
  28. }
  29. private func onDelete(offsets: IndexSet) {
  30. state.devices.remove(atOffsets: offsets)
  31. state.deleteGarminDevice()
  32. }
  33. var body: some View {
  34. Form {
  35. Section(
  36. header: Text("Apple Watch Configuration"),
  37. content: {
  38. VStack {
  39. Picker(
  40. selection: $state.selectedAwConfig,
  41. label: Text("Display on Watch")
  42. ) {
  43. ForEach(AwConfig.allCases) { selection in
  44. Text(selection.displayName).tag(selection)
  45. }
  46. }.padding(.top)
  47. HStack(alignment: .top) {
  48. Text(
  49. "Lorem ipsum dolor sit amet, consetetur sadipscing elitr."
  50. )
  51. .font(.footnote)
  52. .foregroundColor(.secondary)
  53. .lineLimit(nil)
  54. Spacer()
  55. Button(
  56. action: {
  57. hintLabel = "Display on Watch"
  58. selectedVerboseHint = "Display on Watch… bla bla bla"
  59. shouldDisplayHint.toggle()
  60. },
  61. label: {
  62. HStack {
  63. Image(systemName: "questionmark.circle")
  64. }
  65. }
  66. ).buttonStyle(BorderlessButtonStyle())
  67. }.padding(.top)
  68. }.padding(.bottom)
  69. }
  70. ).listRowBackground(Color.chart)
  71. SettingInputSection(
  72. decimalValue: $decimalPlaceholder,
  73. booleanValue: $state.displayFatAndProteinOnWatch,
  74. shouldDisplayHint: $shouldDisplayHint,
  75. selectedVerboseHint: Binding(
  76. get: { selectedVerboseHint },
  77. set: {
  78. selectedVerboseHint = $0
  79. hintLabel = "Show Protein and Fat"
  80. }
  81. ),
  82. units: state.units,
  83. type: .boolean,
  84. label: "Show Protein and Fat",
  85. miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
  86. verboseHint: "Show Protein and Fat… bla bla bla"
  87. )
  88. SettingInputSection(
  89. decimalValue: $decimalPlaceholder,
  90. booleanValue: $state.confirmBolusFaster,
  91. shouldDisplayHint: $shouldDisplayHint,
  92. selectedVerboseHint: Binding(
  93. get: { selectedVerboseHint },
  94. set: {
  95. selectedVerboseHint = $0
  96. hintLabel = "Confirm Bolus Faster"
  97. }
  98. ),
  99. units: state.units,
  100. type: .boolean,
  101. label: "Confirm Bolus Faster",
  102. miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
  103. verboseHint: "Confirm Bolus Faster… bla bla bla"
  104. )
  105. Section(
  106. header: Text("Complications"),
  107. content: {
  108. VStack {
  109. HStack {
  110. NavigationLink(
  111. "Contact Image",
  112. destination: ContactTrick.RootView(resolver: resolver)
  113. ).foregroundStyle(Color.accentColor)
  114. }
  115. }
  116. // .padding(.bottom)
  117. }
  118. ).listRowBackground(Color.chart)
  119. }
  120. .sheet(isPresented: $shouldDisplayHint) {
  121. SettingInputHintView(
  122. hintDetent: $hintDetent,
  123. shouldDisplayHint: $shouldDisplayHint,
  124. hintLabel: hintLabel ?? "",
  125. hintText: selectedVerboseHint ?? "",
  126. sheetTitle: "Help"
  127. )
  128. }
  129. .navigationTitle("Apple Watch")
  130. .navigationBarTitleDisplayMode(.automatic)
  131. .scrollContentBackground(.hidden).background(color)
  132. }
  133. }