polscm32 1 год назад
Родитель
Сommit
2eb14010cd

+ 43 - 5
FreeAPS/Sources/Modules/Home/View/Chart/MainChartView.swift

@@ -119,6 +119,7 @@ struct MainChartView: View {
                     staticYAxisChart
                     dummyBasalChart
                     dummyCobChart.offset(y: 20)
+                    dummyIobChart.offset(y: 40)
                 }
 
                 ScrollViewReader { scroller in
@@ -127,6 +128,7 @@ struct MainChartView: View {
                             mainChart
                             basalChart
                             cobChart.offset(y: 20)
+                            iobChart.offset(y: 40)
                         }.onChange(of: screenHours) { _ in
                             updateStartEndMarkers()
                             yAxisChartData()
@@ -193,7 +195,7 @@ extension MainChartView {
             }
         }
         .id("DummyMainChart")
-        .frame(minHeight: UIScreen.main.bounds.height * 0.2)
+        .frame(minHeight: UIScreen.main.bounds.height * 0.01)
         .frame(width: screenSize.width - 10)
         .chartYAxis { mainChartYAxis }
         .chartXAxis(.hidden)
@@ -225,7 +227,25 @@ extension MainChartView {
             }
         }
         .id("DummyCobChart")
-        .frame(height: UIScreen.main.bounds.height * 0.1)
+        .frame(height: UIScreen.main.bounds.height * 0.08)
+        .frame(width: screenSize.width - 10)
+        .chartXAxis(.hidden)
+        .chartYAxis { cobChartYAxis }
+        .chartLegend(.hidden)
+    }
+
+    private var dummyIobChart: some View {
+        Chart {
+            ForEach(state.enactedAndNonEnactedDeterminations) { iob in
+                let amount = iob.iob?.decimalValue ?? 0
+                let date: Date = iob.deliverAt ?? Date()
+
+                LineMark(x: .value("Time", date), y: .value("Value", amount)).foregroundStyle(.clear)
+                AreaMark(x: .value("Time", date), y: .value("Value", amount)).foregroundStyle(.clear)
+            }
+        }
+        .id("DummyIobChart")
+        .frame(height: UIScreen.main.bounds.height * 0.08)
         .frame(width: screenSize.width - 10)
         .chartXAxis(.hidden)
         .chartYAxis { cobChartYAxis }
@@ -269,7 +289,7 @@ extension MainChartView {
             .onChange(of: didAppearTrigger) { _ in
                 calculateTTs()
             }
-            .frame(minHeight: UIScreen.main.bounds.height * 0.2)
+            .frame(minHeight: UIScreen.main.bounds.height * 0.01)
             .frame(width: fullWidth(viewWidth: screenSize.width))
             .chartXScale(domain: startMarker ... endMarker)
             .chartXAxis { mainChartXAxis }
@@ -353,11 +373,29 @@ extension MainChartView {
                 AreaMark(x: .value("Time", date), y: .value("Value", amount)).foregroundStyle(Color.orange.gradient.opacity(0.3))
             }
         }
-        .frame(height: UIScreen.main.bounds.height * 0.1)
+        .frame(height: UIScreen.main.bounds.height * 0.08)
+        .frame(width: fullWidth(viewWidth: screenSize.width))
+        .chartXScale(domain: startMarker ... endMarker)
+        .chartXAxis { basalChartXAxis }
+        .chartXAxis(.hidden)
+        .chartYAxis(.hidden)
+    }
+
+    private var iobChart: some View {
+        Chart {
+            drawCurrentTimeMarker()
+            ForEach(state.enactedAndNonEnactedDeterminations) { iob in
+                let amount: Decimal = iob.iob?.decimalValue ?? 0
+                let date: Date = iob.deliverAt ?? Date()
+
+                LineMark(x: .value("Time", date), y: .value("Value", amount)).foregroundStyle(Color.insulin.gradient)
+                AreaMark(x: .value("Time", date), y: .value("Value", amount)).foregroundStyle(Color.insulin.gradient.opacity(0.3))
+            }
+        }
+        .frame(height: UIScreen.main.bounds.height * 0.08)
         .frame(width: fullWidth(viewWidth: screenSize.width))
         .chartXScale(domain: startMarker ... endMarker)
         .chartXAxis { basalChartXAxis }
-//        .chartYAxis { cobChartYAxis }
         .chartYAxis(.hidden)
     }
 

+ 2 - 2
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -720,12 +720,12 @@ extension Home {
 
                     mainChart
 
-                    timeInterval.padding(.top, 20).padding(.bottom, 40)
+                    timeInterval.padding(.top, 20).padding(.bottom, 15)
 
                     if let progress = state.bolusProgress {
                         bolusView(geo, progress).padding(.bottom, 10)
                     } else {
-                        profileView(geo).padding(.bottom, 10)
+//                        profileView(geo).padding(.bottom, 10)
                     }
                 }
                 .background(color)