Ivan Valkou 5 лет назад
Родитель
Сommit
18b37c8e71

+ 3 - 0
FreeAPS/Sources/Modules/Home/HomeViewModel.swift

@@ -40,6 +40,7 @@ extension Home {
         @Published var errorMessage: String? = nil
         @Published var errorMessage: String? = nil
         @Published var errorDate: Date? = nil
         @Published var errorDate: Date? = nil
         @Published var bolusProgress: Decimal?
         @Published var bolusProgress: Decimal?
+        @Published var eventualBG: Int?
 
 
         @Published var allowManualTemp = false
         @Published var allowManualTemp = false
         @Published var units: GlucoseUnits = .mmolL
         @Published var units: GlucoseUnits = .mmolL
@@ -234,6 +235,8 @@ extension Home {
             } else {
             } else {
                 statusTitle = "Suggested"
                 statusTitle = "Suggested"
             }
             }
+
+            eventualBG = suggestion.eventualBG
         }
         }
 
 
         private func setupReservoir() {
         private func setupReservoir() {

+ 15 - 1
FreeAPS/Sources/Modules/Home/View/Header/CurrentGlucoseView.swift

@@ -4,6 +4,7 @@ struct CurrentGlucoseView: View {
     @Binding var recentGlucose: BloodGlucose?
     @Binding var recentGlucose: BloodGlucose?
     @Binding var delta: Int?
     @Binding var delta: Int?
     @Binding var units: GlucoseUnits
     @Binding var units: GlucoseUnits
+    @Binding var eventualBG: Int?
 
 
     private var glucoseFormatter: NumberFormatter {
     private var glucoseFormatter: NumberFormatter {
         let formatter = NumberFormatter()
         let formatter = NumberFormatter()
@@ -42,7 +43,20 @@ struct CurrentGlucoseView: View {
                 )
                 )
                 .font(.system(size: 24, weight: .bold))
                 .font(.system(size: 24, weight: .bold))
                 .fixedSize()
                 .fixedSize()
-                image.padding(.bottom, 2)
+                VStack {
+                    image
+                    if let eventualBG = eventualBG {
+                        if units == .mmolL {
+                            Text(
+                                glucoseFormatter
+                                    .string(from: Decimal(eventualBG).asMmolL as NSNumber)!
+                            )
+                            .font(.system(size: 10, weight: .regular)).foregroundColor(.secondary)
+                        } else {
+                            Text("\(eventualBG)").font(.system(size: 10, weight: .regular)).foregroundColor(.secondary)
+                        }
+                    }
+                }
 
 
             }.padding(.leading, 4)
             }.padding(.leading, 4)
             HStack(alignment: .lastTextBaseline, spacing: 2) {
             HStack(alignment: .lastTextBaseline, spacing: 2) {

+ 33 - 22
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -46,7 +46,8 @@ extension Home {
                 CurrentGlucoseView(
                 CurrentGlucoseView(
                     recentGlucose: $viewModel.recentGlucose,
                     recentGlucose: $viewModel.recentGlucose,
                     delta: $viewModel.glucoseDelta,
                     delta: $viewModel.glucoseDelta,
-                    units: $viewModel.units
+                    units: $viewModel.units,
+                    eventualBG: $viewModel.eventualBG
                 )
                 )
                 .onTapGesture {
                 .onTapGesture {
                     viewModel.openCGM()
                     viewModel.openCGM()
@@ -155,27 +156,37 @@ extension Home {
         }
         }
 
 
         var legendPanal: some View {
         var legendPanal: some View {
-            HStack(alignment: .firstTextBaseline) {
-                Circle().fill(Color.loopGreen).frame(width: 8, height: 8)
-                    .padding(.leading, 8)
-                Text("BG")
-                    .font(.system(size: 12, weight: .bold)).foregroundColor(.loopGreen)
-                Circle().fill(Color.insulin).frame(width: 8, height: 8)
-                    .padding(.leading, 8)
-                Text("IOB")
-                    .font(.system(size: 12, weight: .bold)).foregroundColor(.insulin)
-                Circle().fill(Color.zt).frame(width: 8, height: 8)
-                    .padding(.leading, 8)
-                Text("ZT")
-                    .font(.system(size: 12, weight: .bold)).foregroundColor(.zt)
-                Circle().fill(Color.loopYellow).frame(width: 8, height: 8)
-                    .padding(.leading, 8)
-                Text("COB")
-                    .font(.system(size: 12, weight: .bold)).foregroundColor(.loopYellow)
-                Circle().fill(Color.uam).frame(width: 8, height: 8)
-                    .padding(.leading, 8)
-                Text("UAM")
-                    .font(.system(size: 12, weight: .bold)).foregroundColor(.uam)
+            HStack(alignment: .center) {
+                Group {
+                    Circle().fill(Color.loopGreen).frame(width: 8, height: 8)
+                        .padding(.leading, 8)
+                    Text("BG")
+                        .font(.system(size: 12, weight: .bold)).foregroundColor(.loopGreen)
+                }
+                Group {
+                    Circle().fill(Color.insulin).frame(width: 8, height: 8)
+                        .padding(.leading, 8)
+                    Text("IOB")
+                        .font(.system(size: 12, weight: .bold)).foregroundColor(.insulin)
+                }
+                Group {
+                    Circle().fill(Color.zt).frame(width: 8, height: 8)
+                        .padding(.leading, 8)
+                    Text("ZT")
+                        .font(.system(size: 12, weight: .bold)).foregroundColor(.zt)
+                }
+                Group {
+                    Circle().fill(Color.loopYellow).frame(width: 8, height: 8)
+                        .padding(.leading, 8)
+                    Text("COB")
+                        .font(.system(size: 12, weight: .bold)).foregroundColor(.loopYellow)
+                }
+                Group {
+                    Circle().fill(Color.uam).frame(width: 8, height: 8)
+                        .padding(.leading, 8)
+                    Text("UAM")
+                        .font(.system(size: 12, weight: .bold)).foregroundColor(.uam)
+                }
             }
             }
             .frame(maxWidth: .infinity, maxHeight: 30)
             .frame(maxWidth: .infinity, maxHeight: 30)
         }
         }