Hi there,
I'm trying to use an enum as a @Parameter for my Widget configuration:
enum InteractivePlacesWidgetMode: Int, CaseIterable, AppEnum, Comparable, Equatable {
typealias RawValue = Int
case favourites = 0, recents, nearbyCategory, collections
static var typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation(name: LocalizedStringResource("Mode"))
static var caseDisplayRepresentations: [InteractivePlacesWidgetMode: DisplayRepresentation] = [
.favourites: DisplayRepresentation(title: LocalizedStringResource("Favorites")),
.recents: DisplayRepresentation(title: LocalizedStringResource("Recents")),
.nearbyCategory: DisplayRepresentation(title: LocalizedStringResource("Categories")),
.collections: DisplayRepresentation(title: LocalizedStringResource("Collections"))
]
static func < (lhs: InteractivePlacesWidgetMode, rhs: InteractivePlacesWidgetMode) -> Bool {
lhs.rawValue < rhs.rawValue
}
static func == (lhs: InteractivePlacesWidgetMode, rhs: InteractivePlacesWidgetMode) -> Bool {
lhs.rawValue == rhs.rawValue
}
}
Then on the ConfigurationAppIntent I would like to show some more option only for specific cases, with the following:
struct ConfigurationAppIntent: WidgetConfigurationIntent {
static var title: LocalizedStringResource = "Configuration"
static var description = IntentDescription("Choose what to show")
@Parameter(title: LocalizedStringResource("Show"), default: .favourites)
var widgetMode: InteractivePlacesWidgetMode
@Parameter (title: "Category")
var category: CategoryDetail?
static var parameterSummary: some ParameterSummary {
When(\.$widgetMode, .equalTo, .nearbyCategory) {
Summary {
\.$widgetMode
\.$category
}
} otherwise: {
Summary {
\.$widgetMode
}
}
}
}
But the widget seems to ignore the When clausole at all. Is this a limitation of the When clausole? Is there something wrong with my approach? I already used that with standard types in previous work and it seems to work quite well.
Thanks in advance for your help.
c.