Align Settings dependent disabled states

This commit is contained in:
FuelBoard Contributor
2026-10-17 14:40:44 +01:00
parent f261b0b10a
commit ff6cbbe07d
+12 -2
View File
@@ -198,7 +198,7 @@ struct SettingsView: View {
.foregroundStyle(.orange)
}
}
.disabled(!fuelSavingsSettings.enabled)
.settingsDependencyEnabled(fuelSavingsSettings.enabled)
} header: {
Text("Fuel Savings")
} footer: {
@@ -582,7 +582,7 @@ struct SettingsView: View {
)
}
.buttonStyle(.plain)
.disabled(tipStore.purchaseInProgress)
.settingsDependencyEnabled(!tipStore.purchaseInProgress)
}
}
.listRowBackground(Color.clear)
@@ -925,6 +925,16 @@ struct SettingsView: View {
}
}
/// Applies the native unavailable state to a complete dependent settings group
/// and also dims non-control content (read-outs, icons and explanatory text),
/// which does not automatically adopt a disabled appearance from SwiftUI.
private extension View {
func settingsDependencyEnabled(_ isEnabled: Bool) -> some View {
disabled(!isEnabled)
.opacity(isEnabled ? 1 : 0.65)
}
}
/// Loads the three tip tiers and drives their purchases.
@MainActor
final class TipStore: ObservableObject {