Small widget favourites: fuel row returns to the config sheet (picks the default favourite); pinned favourite wins, fuel-tagged picker rows when favourites span >1 fuel; fallback = selected fuel's cheapest favourite

This commit is contained in:
FuelBoard Contributor
2026-08-13 16:51:21 +01:00
parent 1bdef59d78
commit 7357eb98c3
2 changed files with 35 additions and 22 deletions
+11 -9
View File
@@ -84,12 +84,12 @@ struct WidgetFavourite: AppEntity, Identifiable, Hashable, Codable {
return DisplayRepresentation(stringLiteral: "Favourite")
}
let name = entry.station.name
// Same station pinned for another fuel? Disambiguate with the fuel tag.
let hasOtherFuel = favourites.contains {
$0.station.id == entry.station.id && $0.fuel != entry.fuel
}
// If favourites span more than one fuel type, tag EVERY option with its
// fuel so the picker stays unambiguous (different stations can share a
// name; the same station can be pinned for two fuels).
let multiFuel = Set(favourites.map(\.fuel)).count > 1
return DisplayRepresentation(
stringLiteral: hasOtherFuel ? "\(name) · \(entry.fuel.displayName)" : name
stringLiteral: multiFuel ? "\\(name) · \\(entry.fuel.displayName)" : name
)
}
@@ -167,9 +167,10 @@ struct FuelBoardWidgetConfigurationIntent: WidgetConfigurationIntent, WidgetConf
// SMALL widget intent: same knobs as the list widget, PLUS a pinned-favourite
// picker for Favourites sort (a small widget shows exactly ONE station, so the
// user chooses which favourite). In Favourites mode the Fuel + Distance rows
// are hidden the chosen favourite carries its own fuel, and there is no
// radius when a station is pinned.
// user chooses which favourite). Favourites mode keeps the Fuel row it
// mirrors the app's Favourites tab: pick the fuel, then the favourite. The
// pinned favourite wins when set; the Fuel row picks the default favourite on
// a fresh widget. Distance stays hidden (a pinned station has no radius).
struct FuelBoardSmallWidgetConfigurationIntent: WidgetConfigurationIntent, WidgetConfigValues {
static var title: LocalizedStringResource = "Fuel & Sort"
static var description = IntentDescription("Which fuel, ordering, radius and pinned favourite this small widget shows.")
@@ -190,8 +191,9 @@ struct FuelBoardSmallWidgetConfigurationIntent: WidgetConfigurationIntent, Widge
static var parameterSummary: some ParameterSummary {
When(\.$sort, .equalTo, WidgetSort.favourites) {
Summary("Show \(\.$favourite)") {
Summary("Show \(\.$fuel) favourite \(\.$favourite)") {
\.$sort
\.$fuel
\.$favourite
}
} otherwise: {