ListTempPresetsIntent.swift 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import AppIntents
  2. import Foundation
  3. @available(iOS 16.0, *) struct ListTempPresetsIntent: AppIntent {
  4. // Title of the action in the Shortcuts app
  5. static var title: LocalizedStringResource = "Choose Temporary Presets"
  6. // Description of the action in the Shortcuts app
  7. static var description = IntentDescription(
  8. "Allow to list and choose a specific temporary Preset.",
  9. categoryName: "Navigation"
  10. )
  11. @Parameter(title: "Preset") var preset: tempPreset?
  12. static var parameterSummary: some ParameterSummary {
  13. Summary("Choose the temp preset \(\.$preset)")
  14. }
  15. @MainActor func perform() async throws -> some ReturnsValue<tempPreset> {
  16. .result(
  17. value: preset!
  18. )
  19. }
  20. }
  21. @available(iOS 16.0, *) struct tempPresetsQuery: EntityQuery {
  22. internal var intentRequest: TempPresetsIntentRequest
  23. init() {
  24. intentRequest = TempPresetsIntentRequest()
  25. }
  26. func entities(for identifiers: [tempPreset.ID]) async throws -> [tempPreset] {
  27. let tempTargets = intentRequest.fetchIDs(identifiers)
  28. return tempTargets
  29. }
  30. func suggestedEntities() async throws -> [tempPreset] {
  31. let tempTargets = intentRequest.fetchAll()
  32. return tempTargets
  33. }
  34. }