WatchConfigAppleWatchView.swift 4.4 KB

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