DeliveryLimitsInformationView.swift 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. //
  2. // DeliveryLimitsInformationView.swift
  3. // LoopKitUI
  4. //
  5. // Created by Anna Quinlan on 7/3/20.
  6. // Copyright © 2020 LoopKit Authors. All rights reserved.
  7. //
  8. import SwiftUI
  9. import LoopKit
  10. public struct DeliveryLimitsInformationView: View {
  11. var onExit: (() -> Void)?
  12. var mode: SettingsPresentationMode
  13. @Environment(\.presentationMode) var presentationMode
  14. @Environment(\.appName) 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.deliveryLimits.title),
  22. informationalContent: {
  23. VStack (alignment: .leading, spacing: 20) {
  24. deliveryLimitDescription
  25. maxBasalDescription
  26. maxBolusDescription
  27. }
  28. .fixedSize(horizontal: false, vertical: true) // prevent text from being cut off
  29. },
  30. onExit: onExit ?? { self.presentationMode.wrappedValue.dismiss() },
  31. mode: mode
  32. )
  33. }
  34. private var deliveryLimitDescription: some View {
  35. Text(LocalizedString("Delivery Limits are safety guardrails for your insulin delivery.", comment: "Information about delivery limits"))
  36. .foregroundColor(.secondary)
  37. }
  38. private var maxBasalDescription: some View {
  39. VStack(alignment: .leading, spacing: 20) {
  40. Text(DeliveryLimits.Setting.maximumBasalRate.title)
  41. .font(.headline)
  42. VStack(alignment: .leading, spacing: 20) {
  43. Text(String(format: LocalizedString("Maximum Basal Rate is the maximum automatically adjusted basal rate that %1$@ is allowed to enact to help reach your correction range.", comment: "Information about maximum basal rate (1: app name)"), appName))
  44. Text(LocalizedString("Some users choose a value 2, 3, or 4 times their highest scheduled basal rate.", comment: "Information about typical maximum basal rates"))
  45. Text(LocalizedString("Work with your healthcare provider to choose a value that is higher than your highest scheduled basal rate, but as conservative or aggressive as you feel comfortable.", comment: "Disclaimer"))
  46. }
  47. .foregroundColor(.secondary)
  48. }
  49. }
  50. private var maxBolusDescription: some View {
  51. VStack(alignment: .leading, spacing: 20) {
  52. Text(DeliveryLimits.Setting.maximumBolus.title)
  53. .font(.headline)
  54. VStack(alignment: .leading, spacing: 20) {
  55. Text(String(format: LocalizedString("Maximum Bolus is the highest bolus amount that you will allow %1$@ to recommend at one time to cover carbs or bring down high glucose.", comment: "Information about maximum bolus (1: app name)"), appName))
  56. Text(String(format: LocalizedString("This setting will also determine a safety limit for automatic dosing. %1$@ will limit automatic delivery to keep the amount of active insulin below twice your maximum bolus.", comment: "Information about maximum automated insulin on board (1: app name)"), appName))
  57. }
  58. .foregroundColor(.secondary)
  59. }
  60. }
  61. }