| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- import Combine
- import SwiftUI
- import Swinject
- import UIKit
- extension ShortcutsConfig {
- struct RootView: BaseView {
- let resolver: Resolver
- @StateObject var state = StateModel()
- @State private var shouldDisplayHint: Bool = false
- @State var hintDetent = PresentationDetent.large
- @State var selectedVerboseHint: String?
- @State var hintLabel: String?
- @State private var decimalPlaceholder: Decimal = 0.0
- @State private var booleanPlaceholder: Bool = false
- @Environment(\.colorScheme) var colorScheme
- @Environment(AppState.self) var appState
- var body: some View {
- Form {
- Section(
- header: Text("Shortcuts Integration"),
- content: {
- Text(
- "Trio lets you create automations using iOS Shortcuts. Go to the Shortcuts app to create new automations."
- )
- }
- ).listRowBackground(Color.chart)
- Section {
- Button {
- UIApplication.shared.open(URL(string: "shortcuts://")!)
- }
- label: { Label("Open iOS Shortcuts", systemImage: "arrow.triangle.branch").font(.title3).padding() }
- .frame(maxWidth: .infinity, alignment: .center)
- .buttonStyle(.bordered)
- }
- .listRowBackground(Color.clear)
- SettingInputSection(
- decimalValue: $decimalPlaceholder,
- booleanValue: $state.allowBolusByShortcuts,
- shouldDisplayHint: $shouldDisplayHint,
- selectedVerboseHint: Binding(
- get: { selectedVerboseHint },
- set: {
- selectedVerboseHint = $0
- hintLabel = "Allow Bolusing with Shortcuts"
- }
- ),
- units: state.units,
- type: .boolean,
- label: "Allow Bolusing with Shortcuts",
- miniHint: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr.",
- verboseHint: "Allow Bolusing with Shortcuts… bla bla bla"
- )
- }
- .sheet(isPresented: $shouldDisplayHint) {
- SettingInputHintView(
- hintDetent: $hintDetent,
- shouldDisplayHint: $shouldDisplayHint,
- hintLabel: hintLabel ?? "",
- hintText: selectedVerboseHint ?? "",
- sheetTitle: "Help"
- )
- }
- .scrollContentBackground(.hidden).background(appState.trioBackgroundColor(for: colorScheme))
- .onAppear(perform: configureView)
- .navigationTitle("Shortcuts")
- .navigationBarTitleDisplayMode(.automatic)
- }
- }
- }
|