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: {