| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- import SwiftUI
- import Swinject
- extension AppleHealthKit {
- struct RootView: BaseView {
- let resolver: Resolver
- @StateObject var state = StateModel()
- @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
- )
- }
- var body: some View {
- Form {
- Section {
- HStack {
- Image(systemName: "exclamationmark.triangle")
- Text(
- "Connecting to Apple Health will use an excessive amount of storage and may cause Apple Health to lag. This will be improved in a future release."
- )
- .font(.caption)
- }
- .foregroundColor(Color.secondary)
- Toggle("Connect to Apple Health", isOn: $state.useAppleHealth)
- HStack {
- Image(systemName: "pencil.circle.fill")
- Text(
- "This allows Trio to read from and write to Apple Heath. You must also give permissions in Settings > Health > Data Access. If you enter a glucose value into Apple Health, open Trio to confirm it shows up."
- )
- .font(.caption)
- }
- .foregroundColor(Color.secondary)
- if state.needShowInformationTextForSetPermissions {
- HStack {
- Image(systemName: "exclamationmark.circle.fill")
- Text("For write data to Apple Health you must give permissions in Settings > Health > Data Access")
- .font(.caption)
- }
- .foregroundColor(Color.secondary)
- }
- }
- }
- .scrollContentBackground(.hidden).background(color)
- .onAppear(perform: configureView)
- .navigationTitle("Apple Health")
- .navigationBarTitleDisplayMode(.automatic)
- }
- }
- }
|