PreferredGlucoseUnit.swift 517 B

1234567891011121314151617181920212223
  1. // LoopFollow
  2. // PreferredGlucoseUnit.swift
  3. import Foundation
  4. import HealthKit
  5. enum PreferredGlucoseUnit {
  6. /// LoopFollow’s existing source of truth for unit selection.
  7. static func hkUnit() -> HKUnit {
  8. Localizer.getPreferredUnit()
  9. }
  10. /// Maps HKUnit -> GlucoseSnapshot.Unit (our cross-platform enum).
  11. static func snapshotUnit() -> GlucoseSnapshot.Unit {
  12. switch hkUnit() {
  13. case .millimolesPerLiter:
  14. .mmol
  15. default:
  16. .mgdl
  17. }
  18. }
  19. }