|
@@ -1,11 +1,24 @@
|
|
|
|
|
+import CoreData
|
|
|
|
|
+import Foundation
|
|
|
import SwiftUI
|
|
import SwiftUI
|
|
|
|
|
|
|
|
// Helper function to decide how to pick the BG color
|
|
// Helper function to decide how to pick the BG color
|
|
|
-public func setBGColor(bgValue: Int, lowGlucose: Int, highGlucose: Int, targetGlucose: Int) -> Color {
|
|
|
|
|
|
|
+public func setBGColor(bgValue: Int, highBGColorValue: Decimal, lowBGColorValue: Decimal, dynamicBGColor: Bool) -> Color {
|
|
|
|
|
+ // Auggie - injected fails here
|
|
|
|
|
+ // Convert Decimal to Int for high and low glucose values
|
|
|
|
|
+ let lowGlucose = NSDecimalNumber(decimal: lowBGColorValue).intValue - 20
|
|
|
|
|
+ let highGlucose = NSDecimalNumber(decimal: highBGColorValue).intValue + 20
|
|
|
|
|
+ let targetGlucose = 90
|
|
|
|
|
+
|
|
|
// TODO:
|
|
// TODO:
|
|
|
// Only use setDynamicBGColor if the setting is enabled in preferences
|
|
// Only use setDynamicBGColor if the setting is enabled in preferences
|
|
|
- if true {
|
|
|
|
|
- return setDynamicBGColor(bgValue: bgValue, lowGlucose: lowGlucose, highGlucose: highGlucose, targetGlucose: targetGlucose)
|
|
|
|
|
|
|
+ if dynamicBGColor {
|
|
|
|
|
+ return setDynamicBGColor(
|
|
|
|
|
+ bgValue: bgValue,
|
|
|
|
|
+ highGlucose: Int(highGlucose),
|
|
|
|
|
+ lowGlucose: Int(lowGlucose),
|
|
|
|
|
+ targetGlucose: targetGlucose
|
|
|
|
|
+ )
|
|
|
}
|
|
}
|
|
|
// Otheriwse, use static (orange = high, red = low, green = range)
|
|
// Otheriwse, use static (orange = high, red = low, green = range)
|
|
|
else {
|
|
else {
|
|
@@ -23,7 +36,7 @@ public func setBGColor(bgValue: Int, lowGlucose: Int, highGlucose: Int, targetGl
|
|
|
// We'll shift color gradually one BG point at a time
|
|
// We'll shift color gradually one BG point at a time
|
|
|
// We'll shift through the rainbow colors of ROY-G-BIV from low to high
|
|
// We'll shift through the rainbow colors of ROY-G-BIV from low to high
|
|
|
// Start at red for lowGlucose, green for targetGlucose, and violet for highGlucose
|
|
// Start at red for lowGlucose, green for targetGlucose, and violet for highGlucose
|
|
|
-public func setDynamicBGColor(bgValue: Int, lowGlucose: Int, highGlucose: Int, targetGlucose: Int) -> Color {
|
|
|
|
|
|
|
+public func setDynamicBGColor(bgValue: Int, highGlucose: Int, lowGlucose: Int, targetGlucose: Int) -> Color {
|
|
|
let redHue: CGFloat = 0.0 / 360.0 // 0 degrees
|
|
let redHue: CGFloat = 0.0 / 360.0 // 0 degrees
|
|
|
let greenHue: CGFloat = 120.0 / 360.0 // 120 degrees
|
|
let greenHue: CGFloat = 120.0 / 360.0 // 120 degrees
|
|
|
let purpleHue: CGFloat = 270.0 / 360.0 // 270 degrees
|
|
let purpleHue: CGFloat = 270.0 / 360.0 // 270 degrees
|