HomeRootView.swift 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import SwiftUI
  2. extension Home {
  3. struct RootView: BaseView {
  4. @EnvironmentObject var viewModel: ViewModel<Provider>
  5. var body: some View {
  6. GeometryReader { geo in
  7. VStack {
  8. Group {
  9. Text("Header")
  10. }
  11. ScrollView(.vertical, showsIndicators: false) {
  12. GlucoseChartView(glucose: $viewModel.glucose, suggestion: $viewModel.suggestion).frame(height: 150)
  13. if let reason = viewModel.suggestion?.reason {
  14. Text(reason).font(.caption).padding()
  15. }
  16. Button(action: viewModel.runLoop) {
  17. Text("Run loop now").buttonBackground().padding()
  18. }.foregroundColor(.white)
  19. }
  20. ZStack {
  21. Rectangle().fill(Color.gray.opacity(0.2)).frame(height: 50 + geo.safeAreaInsets.bottom)
  22. HStack {
  23. Button { viewModel.showModal(for: .addCarbs) }
  24. label: {
  25. Image(systemName: "circlebadge.2.fill")
  26. }.foregroundColor(.green)
  27. Spacer()
  28. Button { viewModel.showModal(for: .addTempTarget) }
  29. label: {
  30. Image(systemName: "target")
  31. }.foregroundColor(.green)
  32. Spacer()
  33. Button { viewModel.showModal(for: .bolus) }
  34. label: {
  35. Image(systemName: "drop.fill")
  36. }.foregroundColor(.orange)
  37. Spacer()
  38. if viewModel.allowManualTemp {
  39. Button { viewModel.showModal(for: .manualTempBasal) }
  40. label: {
  41. Image(systemName: "circle.bottomhalf.fill")
  42. }.foregroundColor(.blue)
  43. Spacer()
  44. }
  45. Button { viewModel.showModal(for: .settings) }
  46. label: {
  47. Image(systemName: "gearshape")
  48. }.foregroundColor(.gray)
  49. }
  50. .padding(.horizontal, 24)
  51. .padding(.bottom, geo.safeAreaInsets.bottom)
  52. }
  53. }
  54. .edgesIgnoringSafeArea(.bottom)
  55. }
  56. .navigationTitle("Home")
  57. .navigationBarHidden(true)
  58. }
  59. }
  60. }