Unify disabled states and preserve station verdicts

This commit is contained in:
FuelBoard Contributor
2026-10-17 18:22:55 +01:00
parent ff6cbbe07d
commit 7111ce38af
6 changed files with 77 additions and 83 deletions
+29 -24
View File
@@ -166,9 +166,8 @@ struct AlertsView: View {
}
/// An option row that belongs to a toggle. When the toggle is off the control
/// is replaced by a dimmed, static value row: `.disabled` is not enough here
/// because an inline-style picker in a List still expands its options when
/// tapped while disabled.
/// is replaced by a static value row. The enclosing dependent group applies
/// FuelBoard's shared disabled interaction and appearance once.
@ViewBuilder
private func optionRow<Content: View>(_ title: String,
value: String,
@@ -182,7 +181,6 @@ struct AlertsView: View {
Spacer()
Text(value)
}
.foregroundStyle(.tertiary)
}
}
@@ -191,28 +189,30 @@ struct AlertsView: View {
List {
Section {
Toggle(String(localized: "Cheapest favourite", comment: "Favourite price-drop alert toggle"), isOn: $favouriteDropEnabled)
optionRow(String(localized: "Fuel", comment: "Fuel picker title"),
value: favouriteDropFuel.displayName,
isEnabled: favouriteDropEnabled) {
Picker(String(localized: "Fuel", comment: "Fuel picker title"), selection: $favouriteDropFuel) {
ForEach(FuelType.allCases) { fuel in
Text(fuel.displayName).tag(fuel)
Group {
optionRow(String(localized: "Fuel", comment: "Fuel picker title"),
value: favouriteDropFuel.displayName,
isEnabled: favouriteDropEnabled) {
Picker(String(localized: "Fuel", comment: "Fuel picker title"), selection: $favouriteDropFuel) {
ForEach(FuelType.allCases) { fuel in
Text(fuel.displayName).tag(fuel)
}
}
}
Button(String(localized: "Check now", comment: "Manual favourite price-drop check button"), action: onCheckFavouriteDropNow)
Text(String(localized: "Get notified when a different favourite becomes the cheapest, or your cheapest favourite drops in price.", comment: "Favourite price alerts section description"))
.font(.footnote)
.foregroundStyle(.secondary)
}
Button(String(localized: "Check now", comment: "Manual favourite price-drop check button"), action: onCheckFavouriteDropNow)
.disabled(!favouriteDropEnabled)
.allowsHitTesting(favouriteDropEnabled)
Text(String(localized: "Get notified when a different favourite becomes the cheapest, or your cheapest favourite drops in price.", comment: "Favourite price alerts section description"))
.font(.footnote)
.foregroundStyle(.secondary)
.fuelBoardDisabledState(isEnabled: favouriteDropEnabled)
} header: {
Text(String(localized: "Favourite price alerts", comment: "Favourite price alerts section title"))
}
Section {
Toggle(String(localized: "Cheapest station", comment: "Proximity alert toggle"), isOn: $enabled)
optionRow(String(localized: "Alert type", comment: "Proximity alert type picker title"),
Group {
optionRow(String(localized: "Alert type", comment: "Proximity alert type picker title"),
value: alertMode.displayName,
isEnabled: enabled) {
Picker(String(localized: "Alert type", comment: "Proximity alert type picker title"), selection: $alertMode) {
@@ -265,9 +265,11 @@ struct AlertsView: View {
.font(.footnote)
.foregroundStyle(.secondary)
}
Text(String(localized: "Background alerts depend on when your iPhone allows them; each station alerts at most once an hour.", comment: "Proximity alerts background limitation note"))
.font(.footnote)
.foregroundStyle(.secondary)
Text(String(localized: "Background alerts depend on when your iPhone allows them; each station alerts at most once an hour.", comment: "Proximity alerts background limitation note"))
.font(.footnote)
.foregroundStyle(.secondary)
}
.fuelBoardDisabledState(isEnabled: enabled)
} header: {
Text(String(localized: "Proximity alerts", comment: "Proximity alerts section title"))
}
@@ -281,7 +283,8 @@ struct AlertsView: View {
Section {
Toggle(String(localized: "Cheapest station", comment: "Live Activity toggle"), isOn: $liveActivityEnabled)
optionRow(String(localized: "Fuel", comment: "Fuel picker title"),
Group {
optionRow(String(localized: "Fuel", comment: "Fuel picker title"),
value: liveActivityFuel.displayName,
isEnabled: liveActivityEnabled) {
Picker(String(localized: "Fuel", comment: "Fuel picker title"), selection: $liveActivityFuel) {
@@ -305,9 +308,11 @@ struct AlertsView: View {
.font(.footnote)
.foregroundStyle(.secondary)
}
Text(String(localized: "See the cheapest nearby station on your Lock Screen and Dynamic Island, with updates as you travel.", comment: "Live Activity section description"))
.font(.footnote)
.foregroundStyle(.secondary)
Text(String(localized: "See the cheapest nearby station on your Lock Screen and Dynamic Island, with updates as you travel.", comment: "Live Activity section description"))
.font(.footnote)
.foregroundStyle(.secondary)
}
.fuelBoardDisabledState(isEnabled: liveActivityEnabled)
} header: {
Text(String(localized: "Live Activity", comment: "Live Activity section title"))
}