| 1234567891011121314151617181920212223242526272829303132333435363738 |
- // LoopFollow
- // ContactColorMode.swift
- import UIKit
- enum ContactColorMode: String, Codable, CaseIterable {
- case staticColor = "Static"
- case dynamic = "Dynamic"
- var displayName: String {
- switch self {
- case .staticColor:
- return String(localized: "Static")
- case .dynamic:
- return String(localized: "Dynamic (BG Range)")
- }
- }
- /// Returns the appropriate text color based on the mode and BG value
- func textColor(for bgValue: Double, staticColor: UIColor) -> UIColor {
- switch self {
- case .staticColor:
- return staticColor
- case .dynamic:
- let highLine = Storage.shared.highLine.value
- let lowLine = Storage.shared.lowLine.value
- if bgValue >= highLine {
- return .systemYellow
- } else if bgValue <= lowLine {
- return .systemRed
- } else {
- return .systemGreen
- }
- }
- }
- }
|