BolusRootView.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import SwiftUI
  2. import Swinject
  3. extension Bolus {
  4. struct RootView: View {
  5. let resolver: Resolver
  6. let waitForSuggestion: Bool
  7. let fetch: Bool
  8. let editMode: Bool
  9. let override: Bool
  10. @StateObject var state = StateModel()
  11. var body: some View {
  12. if state.useCalc {
  13. // show alternative bolus calc based on toggle in bolus calc settings
  14. AlternativeBolusCalcRootView(
  15. resolver: resolver,
  16. state: state
  17. )
  18. } else {
  19. // show iAPS standard bolus calc
  20. DefaultBolusCalcRootView(
  21. resolver: resolver,
  22. waitForSuggestion: waitForSuggestion,
  23. fetch: fetch,
  24. state: state
  25. )
  26. }
  27. }
  28. }
  29. }
  30. // fix iOS 15 bug
  31. struct ActivityIndicator: UIViewRepresentable {
  32. @Binding var isAnimating: Bool
  33. let style: UIActivityIndicatorView.Style
  34. func makeUIView(context _: UIViewRepresentableContext<ActivityIndicator>) -> UIActivityIndicatorView {
  35. UIActivityIndicatorView(style: style)
  36. }
  37. func updateUIView(_ uiView: UIActivityIndicatorView, context _: UIViewRepresentableContext<ActivityIndicator>) {
  38. isAnimating ? uiView.startAnimating() : uiView.stopAnimating()
  39. }
  40. }