BolusRootView.swift 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. waitForSuggestion: waitForSuggestion,
  15. state: state
  16. )
  17. } else {
  18. // show iAPS standard bolus calc
  19. DefaultBolusCalcRootView(
  20. resolver: resolver,
  21. waitForSuggestion: waitForSuggestion,
  22. fetch: fetch,
  23. state: state
  24. )
  25. }
  26. }
  27. }
  28. }
  29. // fix iOS 15 bug
  30. struct ActivityIndicator: UIViewRepresentable {
  31. @Binding var isAnimating: Bool
  32. let style: UIActivityIndicatorView.Style
  33. func makeUIView(context _: UIViewRepresentableContext<ActivityIndicator>) -> UIActivityIndicatorView {
  34. UIActivityIndicatorView(style: style)
  35. }
  36. func updateUIView(_ uiView: UIActivityIndicatorView, context _: UIViewRepresentableContext<ActivityIndicator>) {
  37. isAnimating ? uiView.startAnimating() : uiView.stopAnimating()
  38. }
  39. }