| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import SwiftUI
- struct WatchConfigGarminView: View {
- @ObservedObject var state: WatchConfig.StateModel
- @State private var shouldDisplayHint: Bool = false
- @State var hintDetent = PresentationDetent.large
- @State var selectedVerboseHint: AnyView?
- @State var hintLabel: String?
- @State private var decimalPlaceholder: Decimal = 0.0
- @State private var booleanPlaceholder: Bool = false
- @Environment(\.colorScheme) var colorScheme
- var color: LinearGradient {
- colorScheme == .dark ? LinearGradient(
- gradient: Gradient(colors: [
- Color.bgDarkBlue,
- Color.bgDarkerDarkBlue
- ]),
- startPoint: .top,
- endPoint: .bottom
- )
- :
- LinearGradient(
- gradient: Gradient(colors: [Color.gray.opacity(0.1)]),
- startPoint: .top,
- endPoint: .bottom
- )
- }
- private func onDelete(offsets: IndexSet) {
- state.devices.remove(atOffsets: offsets)
- state.deleteGarminDevice()
- }
- var body: some View {
- Form {
- Section(
- header: Text("Garmin Configuration"),
- content:
- {
- VStack {
- Button {
- state.selectGarminDevices()
- } label: {
- Text("Add Device")
- .font(.title3) }
- .frame(maxWidth: .infinity, alignment: .center)
- .buttonStyle(.bordered)
- HStack(alignment: .top) {
- Text(
- "Lorem ipsum dolor sit amet, consetetur sadipscing elitr."
- )
- .font(.footnote)
- .foregroundColor(.secondary)
- .lineLimit(nil)
- Spacer()
- Button(
- action: {
- hintLabel = "Add Device"
- selectedVerboseHint = AnyView(Text("Add Garmin Device… bla bla bla"))
- shouldDisplayHint.toggle()
- },
- label: {
- HStack {
- Image(systemName: "questionmark.circle")
- }
- }
- ).buttonStyle(BorderlessButtonStyle())
- }.padding(.top)
- }.padding(.vertical)
- }
- ).listRowBackground(Color.chart)
- if !state.devices.isEmpty {
- Section(header: Text("Garmin Watch")) {
- List {
- ForEach(state.devices, id: \.uuid) { device in
- Text(device.friendlyName)
- }
- .onDelete(perform: onDelete)
- }
- }.listRowBackground(Color.chart)
- }
- }
- .sheet(isPresented: $shouldDisplayHint) {
- SettingInputHintView(
- hintDetent: $hintDetent,
- shouldDisplayHint: $shouldDisplayHint,
- hintLabel: hintLabel ?? "",
- hintText: selectedVerboseHint ?? AnyView(EmptyView()),
- sheetTitle: "Help"
- )
- }
- .navigationTitle("Garmin")
- .navigationBarTitleDisplayMode(.automatic)
- .scrollContentBackground(.hidden).background(color)
- }
- }
|