BolusRootView.swift 1.5 KB

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