Favourites: drag-and-drop reorder per fuel; stored order drives single-widget favourite

This commit is contained in:
FuelBoard Contributor
2026-08-14 10:48:53 +01:00
parent aa95d214e8
commit fbf8c79feb
5 changed files with 139 additions and 43 deletions
+13 -1
View File
@@ -159,7 +159,8 @@ struct ContentView: View {
selectedFuel: selectedFuel,
location: location,
distanceUnit: distanceUnit,
onToggleFavourite: toggleFavourite
onToggleFavourite: toggleFavourite,
onReorder: reorderFavourites
)
.tabItem { Label("Favourites", systemImage: "star.fill") }
@@ -395,6 +396,17 @@ struct ContentView: View {
fuel: alertsFuel, radiusKM: effectiveAlertsRadiusKM)
}
/// Drag-and-drop reorder from the Favourites tab persists the new order
/// and refreshes every surface that consumes it (widgets + geofence
/// priority, which follows the stored order).
private func reorderFavourites(_ newOrder: [FavouriteEntry]) {
favourites = newOrder
FuelStore.saveFavourites(favourites)
WidgetCenter.shared.reloadAllTimelines()
monitor.update(stations: stations, favourites: refreshedFavourites,
fuel: alertsFuel, radiusKM: effectiveAlertsRadiusKM)
}
/// Fetches fresh prices, but only when the cache is stale unless
/// `force` is true (pull-to-refresh is the manual override).
private func refresh(force: Bool = false) async {