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:
@@ -151,41 +151,51 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
Section {
|
Section {
|
||||||
Toggle("Enable Worth the Drive", isOn: fuelSavingsEnabledBinding)
|
Toggle("Enable Worth the Drive", isOn: fuelSavingsEnabledBinding)
|
||||||
HStack {
|
// The feature's own controls follow its toggle: switched
|
||||||
Text("Average fuel economy")
|
// off they grey out but stay on screen (same rule as the
|
||||||
Spacer()
|
// distance picker in Closest mode) and keep their values, so
|
||||||
Text(mpgText)
|
// re-enabling restores exactly what was there. The sections
|
||||||
.monospacedDigit()
|
// that USE the feature — the in-list fill-up control and the
|
||||||
.foregroundStyle(.secondary)
|
// Worth the Drive sort option — are gated on `isConfigured`,
|
||||||
}
|
// which already includes `enabled`, so they hide entirely.
|
||||||
Slider(value: fuelSavingsMPGBinding,
|
Group {
|
||||||
in: FuelSavingsCalculator.mpgSliderRange,
|
HStack {
|
||||||
step: FuelSavingsCalculator.mpgSliderStep)
|
Text("Average fuel economy")
|
||||||
.accessibilityLabel("Average fuel economy")
|
Spacer()
|
||||||
.accessibilityValue(mpgText)
|
Text(mpgText)
|
||||||
Picker("Fill-up unit", selection: fuelSavingsUnitBinding) {
|
.monospacedDigit()
|
||||||
ForEach(FuelSavingsFillUnit.allCases) { unit in
|
.foregroundStyle(.secondary)
|
||||||
Text(unit.displayName).tag(unit)
|
}
|
||||||
|
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)
|
.disabled(!fuelSavingsSettings.enabled)
|
||||||
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)
|
|
||||||
}
|
|
||||||
} header: {
|
} header: {
|
||||||
Text("Fuel Savings")
|
Text("Fuel Savings")
|
||||||
} footer: {
|
} footer: {
|
||||||
|
|||||||
Reference in New Issue
Block a user