InsulinModelInformationView.swift 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // InsulinModelInformationView.swift
  3. // LoopKitUI
  4. //
  5. // Created by Anna Quinlan on 7/6/20.
  6. // Copyright © 2020 LoopKit Authors. All rights reserved.
  7. //
  8. import SwiftUI
  9. import LoopKit
  10. public struct InsulinModelInformationView: View {
  11. var onExit: (() -> Void)?
  12. var mode: SettingsPresentationMode
  13. @Environment(\.presentationMode) var presentationMode
  14. @Environment(\.appName) private var appName
  15. public init(onExit: (() -> Void)?, mode: SettingsPresentationMode = .acceptanceFlow) {
  16. self.onExit = onExit
  17. self.mode = mode
  18. }
  19. public var body: some View {
  20. InformationView(
  21. title: Text(TherapySetting.insulinModel.title),
  22. informationalContent: {
  23. VStack (alignment: .leading, spacing: 20) {
  24. diaInfo
  25. modelPeakInfo
  26. }
  27. .foregroundColor(.secondary)
  28. },
  29. onExit: onExit ?? { self.presentationMode.wrappedValue.dismiss() },
  30. mode: mode
  31. )
  32. }
  33. private var diaInfo: Text {
  34. Text(LocalizedString("\(appName) assumes that the insulin it has delivered is actively working to lower your glucose for 6 hours. This setting cannot be changed.", comment: "Information about insulin action duration"))
  35. }
  36. private var modelPeakInfo: some View {
  37. VStack (alignment: .leading, spacing: 20) {
  38. Text(LocalizedString("You can choose how \(appName) measures rapid acting insulin's peak activity according to one of these two insulin models.", comment: "Information about insulin model"))
  39. HStack(spacing: 10) {
  40. bulletCircle
  41. Text(LocalizedString("The rapid-acting adult model assumes peak activity at 75 minutes.", comment: "Information about adult insulin model"))
  42. }
  43. HStack(spacing: 10) {
  44. bulletCircle
  45. Text(LocalizedString("The rapid-acting child model assumes peak activity at 65 minutes.", comment: "Information about child insulin model"))
  46. }
  47. }
  48. }
  49. private var bulletCircle: some View {
  50. Image(systemName: "circle.fill")
  51. .resizable()
  52. .frame(width: 10, height: 10)
  53. }
  54. }