Update: As a last resort, I tried a totally different approach involving the use of a custom AppEntity type, like follow:
struct WidgetMode: AppEntity, Equatable {
var id: Int
static var defaultQuery = WidgetQuery()
static var typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation(name: LocalizedStringResource("Mode"))
var displayRepresentation: DisplayRepresentation {
switch id {
case 0:
return DisplayRepresentation(title: LocalizedStringResource("Favorites"))
case 1:
return DisplayRepresentation(title: LocalizedStringResource("Recents"))
case 2:
return DisplayRepresentation(title: LocalizedStringResource("Categories"))
case 3:
return DisplayRepresentation(title: LocalizedStringResource("Collections"))
default:
return DisplayRepresentation(title: LocalizedStringResource("Unknown"))
}
}
}
struct WidgetQuery: EntityQuery {
func entities(for identifiers: [Int]) async throws -> [WidgetMode] {
[0, 1, 2, 3].map({ WidgetMode(id: $0)})
}
func suggestedEntities() async throws -> [WidgetMode] {
[0, 1, 2, 3].map({ WidgetMode(id: $0)})
}
}
struct ConfigurationAppIntent: WidgetConfigurationIntent {
static var title: LocalizedStringResource = "Configuration"
static var description = IntentDescription("Choose what to show")
@Parameter(title: LocalizedStringResource("Show"))
var widgetMode: WidgetMode
@Parameter (title: "Category")
var category: CategoryDetail?
static var parameterSummary: some ParameterSummary {
When(\.$widgetMode, .equalTo, WidgetMode(id: 2)) {
Summary {
\.$widgetMode
\.$category
}
} otherwise: {
Summary {
\.$widgetMode
}
}
}
}
But result is always the same: the widget changes the widgetMode option according to the AppEntity custom type, but the When clausole is never honoured.
Please, anyone can help us into the right direction? Is it a bug on iOS17?