From cd88e2360133aaafc8048b71f8433ec05b10662f Mon Sep 17 00:00:00 2001 From: FuelBoard Contributor Date: Thu, 13 Aug 2026 20:53:20 +0100 Subject: [PATCH] Widget pump icon flexes to the chosen fuel's colour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- FuelBoardWidgets/FuelPriceWidget.swift | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/FuelBoardWidgets/FuelPriceWidget.swift b/FuelBoardWidgets/FuelPriceWidget.swift index 6e67dbb..9eee29e 100644 --- a/FuelBoardWidgets/FuelPriceWidget.swift +++ b/FuelBoardWidgets/FuelPriceWidget.swift @@ -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)