| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- 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 {
- Toggle("Connect to Apple Health", isOn: $state.useAppleHealth)
- HStack {
- Image(systemName: "pencil.circle.fill")
- Text(
- "This allows iAPS 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 iAPS 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)
- }
- }
- }
|