HomeRootView.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. Button { viewModel.showModal(for: .manualTempBasal) }
  39. label: {
  40. Image(systemName: "circle.bottomhalf.fill")
  41. }.foregroundColor(.blue)
  42. Spacer()
  43. Button { viewModel.showModal(for: .settings) }
  44. label: {
  45. Image(systemName: "gearshape")
  46. }.foregroundColor(.gray)
  47. }
  48. .padding(.horizontal, 24)
  49. .padding(.bottom, geo.safeAreaInsets.bottom)
  50. }
  51. }
  52. .edgesIgnoringSafeArea(.bottom)
  53. }
  54. .navigationTitle("Home")
  55. .navigationBarHidden(true)
  56. }
  57. }
  58. }