BasalRatesInformationView.swift 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // BasalRatesInformationView.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 BasalRatesInformationView: View {
  11. var onExit: (() -> Void)?
  12. var mode: SettingsPresentationMode
  13. var maximumScheduleEntryCount: Int
  14. @Environment(\.presentationMode) var presentationMode
  15. @Environment(\.appName) var appName
  16. public init(onExit: (() -> Void)?, mode: SettingsPresentationMode = .acceptanceFlow, maximumScheduleEntryCount: Int? = nil) {
  17. self.onExit = onExit
  18. self.mode = mode
  19. self.maximumScheduleEntryCount = maximumScheduleEntryCount ?? 48
  20. }
  21. public var body: some View {
  22. InformationView(
  23. title: Text(TherapySetting.basalRate.title),
  24. informationalContent: {text},
  25. onExit: onExit ?? { self.presentationMode.wrappedValue.dismiss() },
  26. mode: mode
  27. )
  28. }
  29. private var text: some View {
  30. VStack(alignment: .leading, spacing: 25) {
  31. Text(LocalizedString("Your Basal Rate of insulin is the number of units per hour that you want to use to cover your background insulin needs.", comment: "Information about basal rates"))
  32. Text(String(format: LocalizedString("%1$@ supports 1 to %2$@ rates per day.", comment: "Information about max number of basal rates (1: app name) (2: maximum schedule entry count)"), appName, String(describing: maximumScheduleEntryCount)))
  33. Text(LocalizedString("The schedule starts at midnight and cannot contain a rate of 0 U/hr.", comment: "Information about basal rate scheduling"))
  34. }
  35. }
  36. }
  37. struct BasalRatesInformationView_Previews: PreviewProvider {
  38. static var previews: some View {
  39. NavigationView {
  40. BasalRatesInformationView(onExit: nil)
  41. }
  42. .colorScheme(.light)
  43. .previewDevice(PreviewDevice(rawValue: "iPod touch (7th generation)"))
  44. .previewDisplayName("SE light")
  45. NavigationView {
  46. BasalRatesInformationView(onExit: nil)
  47. }
  48. .preferredColorScheme(.dark)
  49. .colorScheme(.dark)
  50. .previewDevice(PreviewDevice(rawValue: "iPhone 12 Pro Max"))
  51. .previewDisplayName("12 Pro dark")
  52. }
  53. }