From 85f601fffd832cb87c7dcfd0275e777cacd10ffc Mon Sep 17 00:00:00 2001 From: FuelBoard Contributor Date: Sun, 11 Oct 2026 19:15:26 +0100 Subject: [PATCH] Fuel Savings: the feature's own settings grey out when it is switched off MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With "Enable Worth the Drive" off, the MPG slider, the fill-up unit picker and the fill-up slider stayed live — editable settings for a switched-off feature. They now sit in a Group disabled by `enabled`, so they grey out but stay on screen and keep their values (the same rule as the distance picker in Closest mode), and re-enabling restores exactly what was there. The surfaces that USE the feature were already gated on `isConfigured` (which includes `enabled`), so the in-list fill-up control and the Worth the Drive sort option still disappear entirely rather than greying out. Verified on the simulator with the toggle off vs forced on: the MPG slider row and the unit picker row both measurably dim — MPG row mean RGB 33.06/35.62/39.49 off vs 37.61/42.70/48.43 on; picker 40.00/40.00/42.62 vs 53.35/53.36/56.82 — while the toggle row itself changes as expected (54.85/64.77/58.96 with the switch on). --- FuelBoard/SettingsView.swift | 76 ++++++++++++++++++++---------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/FuelBoard/SettingsView.swift b/FuelBoard/SettingsView.swift index 54f3661..75766e3 100644 --- a/FuelBoard/SettingsView.swift +++ b/FuelBoard/SettingsView.swift @@ -151,41 +151,51 @@ struct SettingsView: View { Section { Toggle("Enable Worth the Drive", isOn: fuelSavingsEnabledBinding) - HStack { - Text("Average fuel economy") - Spacer() - Text(mpgText) - .monospacedDigit() - .foregroundStyle(.secondary) - } - Slider(value: fuelSavingsMPGBinding, - in: FuelSavingsCalculator.mpgSliderRange, - step: FuelSavingsCalculator.mpgSliderStep) - .accessibilityLabel("Average fuel economy") - .accessibilityValue(mpgText) - Picker("Fill-up unit", selection: fuelSavingsUnitBinding) { - ForEach(FuelSavingsFillUnit.allCases) { unit in - Text(unit.displayName).tag(unit) + // The feature's own controls follow its toggle: switched + // off they grey out but stay on screen (same rule as the + // distance picker in Closest mode) and keep their values, so + // re-enabling restores exactly what was there. The sections + // that USE the feature — the in-list fill-up control and the + // Worth the Drive sort option — are gated on `isConfigured`, + // which already includes `enabled`, so they hide entirely. + Group { + HStack { + Text("Average fuel economy") + Spacer() + Text(mpgText) + .monospacedDigit() + .foregroundStyle(.secondary) + } + Slider(value: fuelSavingsMPGBinding, + in: FuelSavingsCalculator.mpgSliderRange, + step: FuelSavingsCalculator.mpgSliderStep) + .accessibilityLabel("Average fuel economy") + .accessibilityValue(mpgText) + Picker("Fill-up unit", selection: fuelSavingsUnitBinding) { + ForEach(FuelSavingsFillUnit.allCases) { unit in + Text(unit.displayName).tag(unit) + } + } + .pickerStyle(.segmented) + HStack { + Text("Typical fill-up") + Spacer() + Text(fillUpText) + .monospacedDigit() + .foregroundStyle(.secondary) + } + Slider(value: fuelSavingsAmountBinding, + in: FuelSavingsCalculator.fillAmountSliderRange(for: fuelSavingsSettings.preferredAmount.unit), + step: FuelSavingsCalculator.fillAmountSliderStep(for: fuelSavingsSettings.preferredAmount.unit)) + .accessibilityLabel("Typical fill-up") + .accessibilityValue(fillUpText) + if !fuelSavingsSettings.isConfigured && fuelSavingsSettings.enabled { + Text("Set a realistic UK MPG and fill-up amount before Worth the Drive appears in sorting.") + .font(.caption) + .foregroundStyle(.orange) } } - .pickerStyle(.segmented) - HStack { - Text("Typical fill-up") - Spacer() - Text(fillUpText) - .monospacedDigit() - .foregroundStyle(.secondary) - } - Slider(value: fuelSavingsAmountBinding, - in: FuelSavingsCalculator.fillAmountSliderRange(for: fuelSavingsSettings.preferredAmount.unit), - step: FuelSavingsCalculator.fillAmountSliderStep(for: fuelSavingsSettings.preferredAmount.unit)) - .accessibilityLabel("Typical fill-up") - .accessibilityValue(fillUpText) - if !fuelSavingsSettings.isConfigured && fuelSavingsSettings.enabled { - Text("Set a realistic UK MPG and fill-up amount before Worth the Drive appears in sorting.") - .font(.caption) - .foregroundStyle(.orange) - } + .disabled(!fuelSavingsSettings.enabled) } header: { Text("Fuel Savings") } footer: {