import AppIntents import Foundation // Per-widget configuration intent (iOS 17+). Every widget instance carries // its OWN fuel + sort choices, edited directly on the home screen (long-press // → Edit Widget), independent of what the app has selected. This is what // allows several FuelBoard widgets to show different fuels/orderings side by // side. enum WidgetFuel: String, AppEnum, CaseIterable, Codable { case e10 case e5 case diesel static var typeDisplayRepresentation: TypeDisplayRepresentation = "Fuel" static var caseDisplayRepresentations: [WidgetFuel: DisplayRepresentation] = [ .e10: "Unleaded", .e5: "Premium", .diesel: "Diesel", ] } enum WidgetSort: String, AppEnum, CaseIterable, Codable { case cheapest case closest static var typeDisplayRepresentation: TypeDisplayRepresentation = "Sort by" static var caseDisplayRepresentations: [WidgetSort: DisplayRepresentation] = [ .cheapest: "Cheapest", .closest: "Closest", ] } struct FuelBoardWidgetConfigurationIntent: WidgetConfigurationIntent { static var title: LocalizedStringResource = "Fuel & Sort" static var description = IntentDescription("Which fuel and ordering this widget shows.") @Parameter(title: "Fuel", default: .e10) var fuel: WidgetFuel @Parameter(title: "Sort by", default: .cheapest) var sort: WidgetSort }