Widget pump icon flexes to the chosen fuel's colour

The pump glyph in the widget header (both the small single-station face and
the medium list face) was hardcoded green; it now uses the app's fuel
colour wheel — green #30D158 unleaded, yellow #FFD60A premium, cyan
#64D2FF diesel — mirroring the per-fuel pumps in the app's segmented
picker. Palette duplicated in the widget target (Shared is Foundation-only
by design); cross-referenced to StationsView.swift's FuelType.tintColor.
This commit is contained in:
FuelBoard Contributor
2026-08-13 20:53:20 +01:00
parent dafc96f845
commit cd88e23601
+17 -2
View File
@@ -2,6 +2,21 @@ import WidgetKit
import SwiftUI
import AppIntents
// Fuel colour wheel — mirrors the app's palette in StationsView.swift
// (FuelType.tintColor): green = unleaded (#30D158), yellow = premium
// (#FFD60A), cyan = diesel (#64D2FF). Kept here (widget target) because
// Shared/FuelStore.swift is Foundation-only by design; if the app's copy
// ever moves to Shared, DELETE this duplicate to avoid redeclaration.
private extension FuelType {
var fuelColor: Color {
switch self {
case .e10: return Color(red: 48/255.0, green: 209/255.0, blue: 88/255.0) // #30D158
case .e5: return Color(red: 255/255.0, green: 214/255.0, blue: 10/255.0) // #FFD60A
case .diesel: return Color(red: 100/255.0, green: 210/255.0, blue: 255/255.0) // #64D2FF
}
}
}
// FuelBoard widget — petrol stations near you.
// FuelPriceWidget (medium): top 3 stations with price + distance, each row
// opens Maps. Per-widget fuel + sort (+ distance for Cheapest).
@@ -398,7 +413,7 @@ struct FuelPriceWidgetView: View {
return VStack(alignment: .leading, spacing: 6) {
HStack {
Image(systemName: "fuelpump.fill")
.foregroundStyle(.green)
.foregroundStyle(entry.fuel.fuelColor)
Text(heading)
.font(.caption2)
.foregroundStyle(.secondary)
@@ -440,7 +455,7 @@ struct FuelPriceWidgetView: View {
return VStack(alignment: .leading, spacing: 6) {
HStack {
Image(systemName: "fuelpump.fill")
.foregroundStyle(.green)
.foregroundStyle(entry.fuel.fuelColor)
Text(heading)
.font(.caption2)
.foregroundStyle(.secondary)