PredictionPointView.swift 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import SwiftUI
  2. struct PredictionPointView: View {
  3. let predictionType: PredictionType
  4. let value: Int?
  5. var body: some View {
  6. Circle()
  7. .strokeBorder(
  8. predictionColor,
  9. lineWidth: 1.5,
  10. antialiased: true
  11. )
  12. .frame(width: ChartsConfig.glucosePointSize, height: ChartsConfig.glucosePointSize)
  13. }
  14. }
  15. extension PredictionPointView {
  16. var predictionColor: Color {
  17. let color: Color
  18. switch predictionType {
  19. case .iob:
  20. color = Color(.systemTeal)
  21. case .cob:
  22. color = Color(.systemOrange)
  23. case .zt:
  24. color = Color(.systemPink)
  25. case .uam:
  26. color = Color(.systemIndigo)
  27. }
  28. return color.opacity(value != nil ? 1 : 0)
  29. }
  30. }
  31. struct PredictionPointView_Previews: PreviewProvider {
  32. static var previews: some View {
  33. PredictionPointView(predictionType: .iob, value: 3)
  34. .preferredColorScheme(/*@START_MENU_TOKEN@*/ .dark/*@END_MENU_TOKEN@*/)
  35. }
  36. }