Browse Source

Fix dynamic glucose color for contact image on mmol/L

Deniz Cengiz 1 year ago
parent
commit
7e38cca789
1 changed files with 4 additions and 2 deletions
  1. 4 2
      FreeAPS/Sources/Services/ContactImage/ContactImageManager.swift

+ 4 - 2
FreeAPS/Sources/Services/ContactImage/ContactImageManager.swift

@@ -232,9 +232,11 @@ final class BaseContactImageManager: NSObject, ContactImageManager, Injectable {
         let hardCodedLow = Decimal(55)
         let hardCodedHigh = Decimal(220)
         let isDynamicColorScheme = settingsManager.settings.glucoseColorScheme == .dynamicColor
+        let highGlucoseColorValue = isDynamicColorScheme ? hardCodedHigh : settingsManager.settings.highGlucose
+        let lowGlucoseColorValue = isDynamicColorScheme ? hardCodedLow : settingsManager.settings.lowGlucose
 
-        state.highGlucoseColorValue = isDynamicColorScheme ? hardCodedHigh : settingsManager.settings.highGlucose
-        state.lowGlucoseColorValue = isDynamicColorScheme ? hardCodedLow : settingsManager.settings.lowGlucose
+        state.highGlucoseColorValue = units == .mgdL ? highGlucoseColorValue : highGlucoseColorValue.asMmolL
+        state.lowGlucoseColorValue = units == .mgdL ? lowGlucoseColorValue : lowGlucoseColorValue.asMmolL
         state
             .targetGlucose = await getCurrentGlucoseTarget() ??
             (settingsManager.settings.units == .mgdL ? Decimal(100) : 100.asMmolL)