diff --git a/FuelBoardWidgets/FuelPriceWidget.swift b/FuelBoardWidgets/FuelPriceWidget.swift index c28205c..0f20f60 100644 --- a/FuelBoardWidgets/FuelPriceWidget.swift +++ b/FuelBoardWidgets/FuelPriceWidget.swift @@ -64,7 +64,7 @@ struct FuelPriceTimelineProvider: AppIntentTimelineProvider { .filter { $0.prices[.e10] != nil } .sorted { $0.prices[.e10]! < $1.prices[.e10]! } return FuelPriceEntry( - date: Date(), stations: Array(sample.prefix(4)), + date: Date(), stations: Array(sample.prefix(8)), fuel: .e10, sort: .cheapest, isFavourites: false, location: nil, locationSource: "none", unit: unit ) @@ -189,7 +189,7 @@ struct FuelPriceTimelineProvider: AppIntentTimelineProvider { } return FuelPriceEntry( - date: Date(), stations: Array(ordered.prefix(4)), + date: Date(), stations: Array(ordered.prefix(8)), fuel: fuel, sort: sort, isFavourites: isFavourites, location: location, locationSource: source, unit: unit @@ -287,6 +287,16 @@ struct FuelPriceWidgetView: View { .widgetURL(station.widgetDirectionsURL) } + /// How many station rows each family can fit: medium widgets are short + /// (158pt) so 3 rows is the safe cap; large/extraLarge have ~2× the height + /// and fit 5 compact rows. Small widgets use singleStation instead. + private var maxRows: Int { + switch family { + case .systemMedium: return 3 + default: return 5 + } + } + private var stationList: some View { let cheapest = entry.stations.compactMap { $0.prices[entry.fuel] }.min() return VStack(alignment: .leading, spacing: 6) { @@ -302,7 +312,7 @@ struct FuelPriceWidgetView: View { .font(.caption2) .foregroundStyle(.secondary) } - ForEach(entry.stations.prefix(3)) { station in + ForEach(entry.stations.prefix(maxRows)) { station in Link(destination: station.widgetDirectionsURL ?? URL(string: "maps://")!) { HStack(spacing: 8) { Text(station.name)