From c2a9943d4c6b032e9b4a4c10f9d7ae8fc12f0600 Mon Sep 17 00:00:00 2001 From: FuelBoard Contributor Date: Wed, 12 Aug 2026 23:03:35 +0100 Subject: [PATCH] Favourites tab: fuel-type selector gets the same coloured pump icons - FuelTypeSegmentedPicker promoted to shared (was private in StationsView) and parameterised by fuel list so Favourites passes only fuels with favourites - Favourites tab swaps native .segmented picker for the capsule control with green/purple/grey fuelpump icons, matching Stations --- FuelBoard/FavouritesView.swift | 10 ++++------ FuelBoard/StationsView.swift | 12 ++++++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/FuelBoard/FavouritesView.swift b/FuelBoard/FavouritesView.swift index de7ac2e..1baf7fe 100644 --- a/FuelBoard/FavouritesView.swift +++ b/FuelBoard/FavouritesView.swift @@ -84,12 +84,10 @@ struct FavouritesView: View { } } else { Section("Fuel type") { - Picker("Fuel type", selection: $fuel) { - ForEach(availableFuels) { fuel in - Text(fuel.shortName).tag(fuel) - } - } - .pickerStyle(.segmented) + FuelTypeSegmentedPicker( + selection: $fuel, + fuels: availableFuels + ) } Section("\(activeFuel.displayName) favourites — cheapest first") { diff --git a/FuelBoard/StationsView.swift b/FuelBoard/StationsView.swift index 72400f2..9affa12 100644 --- a/FuelBoard/StationsView.swift +++ b/FuelBoard/StationsView.swift @@ -204,14 +204,18 @@ extension FuelType { /// Fuel-type selector styled like a segmented control, with a coloured pump /// icon per fuel (green = unleaded, purple = premium, grey = diesel). Built /// custom because the native `.segmented` picker tints every segment the same -/// accent colour — it can't show per-fuel pump colours. -private struct FuelTypeSegmentedPicker: View { +/// accent colour — it can't show per-fuel pump colours. Shared by the Stations +/// and Favourites tabs. +struct FuelTypeSegmentedPicker: View { @Binding var selection: FuelType - var onSelect: (FuelType) -> Void + /// Which fuels to show. Defaults to all; the Favourites tab passes only + /// the fuels that actually have favourites. + var fuels: [FuelType] = FuelType.allCases + var onSelect: (FuelType) -> Void = { _ in } var body: some View { HStack(spacing: 3) { - ForEach(FuelType.allCases) { fuel in + ForEach(fuels) { fuel in let isSelected = fuel == selection Button { selection = fuel