WatchConfigAppleWatchView.swift 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. import SwiftUI
  2. import Swinject
  3. struct WatchConfigAppleWatchView: BaseView {
  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. @Environment(AppState.self) var appState
  14. private func onDelete(offsets: IndexSet) {
  15. state.devices.remove(atOffsets: offsets)
  16. state.deleteGarminDevice()
  17. }
  18. var body: some View {
  19. Form {
  20. Section(
  21. header: Text("Apple Watch Configuration"),
  22. content: {
  23. VStack {
  24. Picker(
  25. selection: $state.selectedAwConfig,
  26. label: Text("Display on Watch")
  27. ) {
  28. ForEach(AwConfig.allCases) { selection in
  29. Text(selection.displayName).tag(selection)
  30. }
  31. }.padding(.top)
  32. HStack(alignment: .top) {
  33. Text(
  34. "Lorem ipsum dolor sit amet, consetetur sadipscing elitr."
  35. )
  36. .font(.footnote)
  37. .foregroundColor(.secondary)
  38. .lineLimit(nil)
  39. Spacer()
  40. Button(
  41. action: {
  42. hintLabel = "Display on Watch"
  43. selectedVerboseHint = "Display on Watch… bla bla bla"
  44. shouldDisplayHint.toggle()
  45. },
  46. label: {
  47. HStack {
  48. Image(systemName: "questionmark.circle")
  49. }
  50. }
  51. ).buttonStyle(BorderlessButtonStyle())
  52. }.padding(.top)
  53. }.padding(.bottom)
  54. }
  55. ).listRowBackground(Color.chart)
  56. SettingInputSection(
  57. decimalValue: $decimalPlaceholder,
  58. booleanValue: $state.displayFatAndProteinOnWatch,
  59. shouldDisplayHint: $shouldDisplayHint,
  60. selectedVerboseHint: Binding(
  61. get: { selectedVerboseHint },
  62. set: {
  63. selectedVerboseHint = $0
  64. hintLabel = "Show Protein and Fat"
  65. }
  66. ),
  67. units: state.units,
  68. type: .boolean,
  69. label: "Show Protein and Fat",
  70. miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
  71. verboseHint: "Show Protein and Fat… bla bla bla"
  72. )
  73. SettingInputSection(
  74. decimalValue: $decimalPlaceholder,
  75. booleanValue: $state.confirmBolusFaster,
  76. shouldDisplayHint: $shouldDisplayHint,
  77. selectedVerboseHint: Binding(
  78. get: { selectedVerboseHint },
  79. set: {
  80. selectedVerboseHint = $0
  81. hintLabel = "Confirm Bolus Faster"
  82. }
  83. ),
  84. units: state.units,
  85. type: .boolean,
  86. label: "Confirm Bolus Faster",
  87. miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
  88. verboseHint: "Confirm Bolus Faster… bla bla bla"
  89. )
  90. Section(
  91. header: Text("Complications"),
  92. content: {
  93. VStack {
  94. HStack {
  95. NavigationLink("Contact image") {
  96. ContactTrick.RootView(resolver: resolver)
  97. }.foregroundStyle(Color.accentColor)
  98. }
  99. }
  100. }
  101. ).listRowBackground(Color.chart)
  102. }
  103. .sheet(isPresented: $shouldDisplayHint) {
  104. SettingInputHintView(
  105. hintDetent: $hintDetent,
  106. shouldDisplayHint: $shouldDisplayHint,
  107. hintLabel: hintLabel ?? "",
  108. hintText: selectedVerboseHint ?? "",
  109. sheetTitle: "Help"
  110. )
  111. }
  112. .navigationTitle("Apple Watch")
  113. .navigationBarTitleDisplayMode(.automatic)
  114. .scrollContentBackground(.hidden)
  115. .background(appState.trioBackgroundColor(for: colorScheme))
  116. }
  117. }