HomeRootView.swift 3.3 KB

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