소스 검색

Remove waitForSuggestion for AlternativeBolusCalc; fix popup glitches

dnzxy 2 년 전
부모
커밋
321f212418
2개의 변경된 파일30개의 추가작업 그리고 20개의 파일을 삭제
  1. 30 19
      FreeAPS/Sources/Modules/Bolus/View/AlternativeBolusCalcRootView.swift
  2. 0 1
      FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift

+ 30 - 19
FreeAPS/Sources/Modules/Bolus/View/AlternativeBolusCalcRootView.swift

@@ -6,7 +6,6 @@ import Swinject
 extension Bolus {
 extension Bolus {
     struct AlternativeBolusCalcRootView: BaseView {
     struct AlternativeBolusCalcRootView: BaseView {
         let resolver: Resolver
         let resolver: Resolver
-        let waitForSuggestion: Bool
 
 
         @StateObject var state: StateModel
         @StateObject var state: StateModel
 
 
@@ -602,7 +601,7 @@ extension Bolus {
 
 
                 let iobFormatted = self.insulinRounder(state.iob).formatted()
                 let iobFormatted = self.insulinRounder(state.iob).formatted()
                 HStack {
                 HStack {
-                    Text((state.iob != 0 ? "-" : "") + (state.iob >= 0 ? iobFormatted : "(" + iobFormatted + ")"))
+                    Text((state.iob >= 0 ? "-" : "") + (state.iob >= 0 ? iobFormatted : "(" + iobFormatted + ")"))
                     Text("U").foregroundColor(.secondary)
                     Text("U").foregroundColor(.secondary)
                 }.fontWeight(.bold)
                 }.fontWeight(.bold)
                     .gridColumnAlignment(.trailing)
                     .gridColumnAlignment(.trailing)
@@ -774,7 +773,7 @@ extension Bolus {
                 HStack {
                 HStack {
                     Text(self.insulinRounder(state.insulinCalculated).formatted())
                     Text(self.insulinRounder(state.insulinCalculated).formatted())
                         .fontWeight(.bold)
                         .fontWeight(.bold)
-                        .foregroundColor(.blue)
+                        .foregroundColor(state.wholeCalc >= state.maxBolus ? Color.loopRed : Color.blue)
                     Text("U").foregroundColor(.secondary)
                     Text("U").foregroundColor(.secondary)
                 }
                 }
                 .gridColumnAlignment(.trailing)
                 .gridColumnAlignment(.trailing)
@@ -785,25 +784,37 @@ extension Bolus {
         var calcResultFormulaRow: some View {
         var calcResultFormulaRow: some View {
             GridRow(alignment: .bottom) {
             GridRow(alignment: .bottom) {
                 if state.useFattyMealCorrectionFactor {
                 if state.useFattyMealCorrectionFactor {
-                    Text("Factor x Fatty Meal Factor x Full Bolus")
-                        .foregroundColor(.secondary.opacity(colorScheme == .dark ? 0.65 : 0.8))
-                        .font(.caption)
-                        .gridCellAnchor(.center)
-                        .gridCellColumns(3)
+                    Group {
+                        Text("Factor x Fatty Meal Factor x Full Bolus")
+                            .foregroundColor(.secondary.opacity(colorScheme == .dark ? 0.65 : 0.8))
+                            +
+                            Text(state.wholeCalc > state.maxBolus ? " ≈ Max Bolus" : "").foregroundColor(Color.loopRed)
+                    }
+                    .font(.caption)
+                    .gridCellAnchor(.center)
+                    .gridCellColumns(3)
                 } else if state.useSuperBolus {
                 } else if state.useSuperBolus {
-                    Text("(Factor x Full Bolus) + Super Bolus")
-                        .foregroundColor(.secondary.opacity(colorScheme == .dark ? 0.65 : 0.8))
-                        .font(.caption)
-                        .gridCellAnchor(.center)
-                        .gridCellColumns(3)
+                    Group {
+                        Text("(Factor x Full Bolus) + Super Bolus")
+                            .foregroundColor(.secondary.opacity(colorScheme == .dark ? 0.65 : 0.8))
+                            +
+                            Text(state.wholeCalc > state.maxBolus ? " ≈ Max Bolus" : "").foregroundColor(Color.loopRed)
+                    }
+                    .font(.caption)
+                    .gridCellAnchor(.center)
+                    .gridCellColumns(3)
                 } else {
                 } else {
                     Color.clear.gridCellUnsizedAxes([.horizontal, .vertical])
                     Color.clear.gridCellUnsizedAxes([.horizontal, .vertical])
-                    Text("Factor x Full Bolus")
-                        .foregroundColor(.secondary.opacity(colorScheme == .dark ? 0.65 : 0.8))
-                        .font(.caption)
-                        .padding(.top, 5)
-                        .gridCellAnchor(.leading)
-                        .gridCellColumns(2)
+                    Group {
+                        Text("Factor x Full Bolus")
+                            .foregroundColor(.secondary.opacity(colorScheme == .dark ? 0.65 : 0.8))
+                            +
+                            Text(state.wholeCalc > state.maxBolus ? " ≈ Max Bolus" : "").foregroundColor(Color.loopRed)
+                    }
+                    .font(.caption)
+                    .padding(.top, 5)
+                    .gridCellAnchor(.leading)
+                    .gridCellColumns(2)
                 }
                 }
             }
             }
         }
         }

+ 0 - 1
FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift

@@ -13,7 +13,6 @@ extension Bolus {
                 // show alternative bolus calc based on toggle in bolus calc settings
                 // show alternative bolus calc based on toggle in bolus calc settings
                 AlternativeBolusCalcRootView(
                 AlternativeBolusCalcRootView(
                     resolver: resolver,
                     resolver: resolver,
-                    waitForSuggestion: waitForSuggestion,
                     state: state
                     state: state
                 )
                 )
             } else {
             } else {