BolusCalculatorConfigRootView.swift 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import SwiftUI
  2. import Swinject
  3. extension BolusCalculatorConfig {
  4. struct RootView: BaseView {
  5. let resolver: Resolver
  6. @StateObject var state = StateModel()
  7. private var conversionFormatter: NumberFormatter {
  8. let formatter = NumberFormatter()
  9. formatter.numberStyle = .decimal
  10. formatter.maximumFractionDigits = 1
  11. return formatter
  12. }
  13. var body: some View {
  14. Form {
  15. Section(header: Text("Calculator settings")) {
  16. HStack {
  17. Toggle("Use alternative Bolus Calculator", isOn: $state.useCalc)
  18. }
  19. HStack {
  20. Text("Override With A Factor Of ")
  21. Spacer()
  22. DecimalTextField("0.8", value: $state.overrideFactor, formatter: conversionFormatter)
  23. }
  24. }
  25. Section(header: Text("Fatty Meals")) {
  26. HStack {
  27. Toggle("Apply factor for fatty meals", isOn: $state.fattyMeals)
  28. }
  29. HStack {
  30. Text("Override With A Factor Of ")
  31. Spacer()
  32. DecimalTextField("0.7", value: $state.fattyMealFactor, formatter: conversionFormatter)
  33. }
  34. }
  35. Section(
  36. footer: Text(
  37. "This is another approach to the bolus calculator integrated in iAPS. If the toggle is on you use this bolus calculator and not the original iAPS calculator. At the end of the calculation a custom factor is applied as it is supposed to be when using smbs (default 0.8).\n\nYou can also add the option in your bolus calculator to apply another (!) customizable factor at the end of the calculation which could be useful for fatty meals, e.g Pizza (default 0.7)."
  38. )
  39. )
  40. {}
  41. }
  42. .onAppear(perform: configureView)
  43. .navigationBarTitle("Bolus Calculator")
  44. .navigationBarTitleDisplayMode(.automatic)
  45. }
  46. }
  47. }