CorrectionRangeOverridesExtension.swift 796 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // CorrectionRangeOverridesExtension.swift
  3. // LoopKitUI
  4. //
  5. // Created by Rick Pasetto on 7/15/20.
  6. // Copyright © 2020 LoopKit Authors. All rights reserved.
  7. //
  8. import LoopKit
  9. import SwiftUI
  10. extension CorrectionRangeOverrides.Preset {
  11. public func icon(usingCarbTintColor carbTintColor: Color,
  12. orGlucoseTintColor glucoseTintColor: Color) -> some View
  13. {
  14. switch self {
  15. case .preMeal:
  16. return icon(named: "Pre-Meal", tinted: carbTintColor)
  17. case .workout:
  18. return icon(named: "workout", tinted: glucoseTintColor)
  19. }
  20. }
  21. private func icon(named name: String, tinted color: Color) -> some View {
  22. Image(name)
  23. .renderingMode(.template)
  24. .foregroundColor(color)
  25. }
  26. }