InsulinModelInformationView.swift 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. },
  28. onExit: onExit ?? { self.presentationMode.wrappedValue.dismiss() },
  29. mode: mode
  30. )
  31. }
  32. private var diaInfo: Text {
  33. Text(String(format: LocalizedString("%1$@ 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 (1: app name)"), appName))
  34. }
  35. private var modelPeakInfo: some View {
  36. VStack (alignment: .leading, spacing: 20) {
  37. Text(String(format: LocalizedString("You can choose how %1$@ measures rapid acting insulin's peak activity according to one of these two insulin models.", comment: "Information about insulin model (1: app name)"), appName))
  38. HStack(spacing: 10) {
  39. bulletCircle
  40. Text(LocalizedString("The rapid-acting adult model assumes peak activity at 75 minutes.", comment: "Information about adult insulin model"))
  41. }
  42. HStack(spacing: 10) {
  43. bulletCircle
  44. Text(LocalizedString("The rapid-acting child model assumes peak activity at 65 minutes.", comment: "Information about child insulin model"))
  45. }
  46. }
  47. }
  48. private var bulletCircle: some View {
  49. Image(systemName: "circle.fill")
  50. .resizable()
  51. .frame(width: 10, height: 10)
  52. }
  53. }