Fuel Savings: the feature's own settings grey out when it is switched off

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).
This commit is contained in:
FuelBoard Contributor
2026-10-11 19:15:26 +01:00
parent cf3abb3fa7
commit 85f601fffd
+10
View File
@@ -151,6 +151,14 @@ struct SettingsView: View {
Section { Section {
Toggle("Enable Worth the Drive", isOn: fuelSavingsEnabledBinding) Toggle("Enable Worth the Drive", isOn: fuelSavingsEnabledBinding)
// 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 { HStack {
Text("Average fuel economy") Text("Average fuel economy")
Spacer() Spacer()
@@ -186,6 +194,8 @@ struct SettingsView: View {
.font(.caption) .font(.caption)
.foregroundStyle(.orange) .foregroundStyle(.orange)
} }
}
.disabled(!fuelSavingsSettings.enabled)
} header: { } header: {
Text("Fuel Savings") Text("Fuel Savings")
} footer: { } footer: {