BolusRootView.swift 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. @StateObject var state = StateModel()
  9. var body: some View {
  10. if state.useCalc {
  11. // show alternative bolus calc based on toggle in bolus calc settings
  12. AlternativeBolusCalcRootView(
  13. resolver: resolver,
  14. state: state
  15. )
  16. } else {
  17. // show iAPS standard bolus calc
  18. DefaultBolusCalcRootView(
  19. resolver: resolver,
  20. waitForSuggestion: waitForSuggestion,
  21. fetch: fetch,
  22. state: state
  23. )
  24. }
  25. }
  26. }
  27. }
  28. // fix iOS 15 bug
  29. struct ActivityIndicator: UIViewRepresentable {
  30. @Binding var isAnimating: Bool
  31. let style: UIActivityIndicatorView.Style
  32. func makeUIView(context _: UIViewRepresentableContext<ActivityIndicator>) -> UIActivityIndicatorView {
  33. UIActivityIndicatorView(style: style)
  34. }
  35. func updateUIView(_ uiView: UIActivityIndicatorView, context _: UIViewRepresentableContext<ActivityIndicator>) {
  36. isAnimating ? uiView.startAnimating() : uiView.stopAnimating()
  37. }
  38. }