import AppIntents import WidgetKit /// Severity filter for widget alert display. enum AlertSeverityFilter: String, AppEnum { case all case critical case high static var typeDisplayRepresentation: TypeDisplayRepresentation = "Alert Severity" static var caseDisplayRepresentations: [AlertSeverityFilter: DisplayRepresentation] = [ .all: DisplayRepresentation( title: "All Alerts", subtitle: "Show alerts of all severity levels" ), .critical: DisplayRepresentation( title: "Critical Only", subtitle: "Only show critical alerts" ), .high: DisplayRepresentation( title: "High & Critical", subtitle: "Only show high and critical alerts" ), ] /// Returns whether an alert with the given severity string passes this filter. func matches(severity: String) -> Bool { switch self { case .all: return true case .critical: return severity == "critical" case .high: return severity == "critical" || severity == "high" } } } /// Configuration intent for Kordant widgets. /// Allows users to filter alerts by severity from the widget gallery. struct KordantWidgetConfigurationIntent: WidgetConfigurationIntent { static var title: LocalizedStringResource = "Widget Configuration" static var description: LocalizedStringResource = "Choose which alerts to display on your widget." @Parameter( title: "Severity Filter", default: .all ) var severityFilter: AlertSeverityFilter }