AppleHealthKitRootView.swift 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import SwiftUI
  2. import Swinject
  3. extension AppleHealthKit {
  4. struct RootView: BaseView {
  5. let resolver: Resolver
  6. @StateObject var state = StateModel()
  7. @Environment(\.colorScheme) var colorScheme
  8. var color: LinearGradient {
  9. colorScheme == .dark ? LinearGradient(
  10. gradient: Gradient(colors: [
  11. Color.bgDarkBlue,
  12. Color.bgDarkerDarkBlue
  13. ]),
  14. startPoint: .top,
  15. endPoint: .bottom
  16. )
  17. :
  18. LinearGradient(
  19. gradient: Gradient(colors: [Color.gray.opacity(0.1)]),
  20. startPoint: .top,
  21. endPoint: .bottom
  22. )
  23. }
  24. var body: some View {
  25. Form {
  26. Section {
  27. HStack {
  28. Image(systemName: "exclamationmark.triangle")
  29. Text(
  30. "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."
  31. )
  32. .font(.caption)
  33. }
  34. .foregroundColor(Color.secondary)
  35. Toggle("Connect to Apple Health", isOn: $state.useAppleHealth)
  36. HStack {
  37. Image(systemName: "pencil.circle.fill")
  38. Text(
  39. "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."
  40. )
  41. .font(.caption)
  42. }
  43. .foregroundColor(Color.secondary)
  44. if state.needShowInformationTextForSetPermissions {
  45. HStack {
  46. Image(systemName: "exclamationmark.circle.fill")
  47. Text("For write data to Apple Health you must give permissions in Settings > Health > Data Access")
  48. .font(.caption)
  49. }
  50. .foregroundColor(Color.secondary)
  51. }
  52. }
  53. }
  54. .scrollContentBackground(.hidden).background(color)
  55. .onAppear(perform: configureView)
  56. .navigationTitle("Apple Health")
  57. .navigationBarTitleDisplayMode(.automatic)
  58. }
  59. }
  60. }