BasalRatesInformationView.swift 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. .foregroundColor(.secondary)
  36. }
  37. }
  38. struct BasalRatesInformationView_Previews: PreviewProvider {
  39. static var previews: some View {
  40. NavigationView {
  41. BasalRatesInformationView(onExit: nil)
  42. }
  43. .colorScheme(.light)
  44. .previewDevice(PreviewDevice(rawValue: "iPod touch (7th generation)"))
  45. .previewDisplayName("SE light")
  46. NavigationView {
  47. BasalRatesInformationView(onExit: nil)
  48. }
  49. .preferredColorScheme(.dark)
  50. .colorScheme(.dark)
  51. .previewDevice(PreviewDevice(rawValue: "iPhone 12 Pro Max"))
  52. .previewDisplayName("12 Pro dark")
  53. }
  54. }