import SwiftUI
import AppIntents

enum MovieTypes: String, AppEnum {
   case love
   case hate

   static let typeDisplayRepresentation: TypeDisplayRepresentation = "Type of Movie"
   
   static let caseDisplayRepresentations: [MovieTypes: DisplayRepresentation] = [
      .love: "Love",
      .hate: "Hate"
   ]
}
struct ShowMovie: AppIntent {
   static let title: LocalizedStringResource = "Show Movie"
   static let description = IntentDescription("Shows movies you love or hate.")

   static let supportedModes: IntentModes = .background

   @Parameter
   var movieType: MovieTypes

   @MainActor
   func perform() async throws -> some IntentResult & ProvidesDialog {
      var movie = "Undefined"
      if movieType == .love {
         movie = "Rambo"
      } else if movieType == .hate {
         movie = "Pulp Fiction"
      }
      return .result(
         dialog: IntentDialog("The movie is \(movie)")
      )
   }
}
struct TestIntentsShortcuts: AppShortcutsProvider {
   static var appShortcuts: [AppShortcut] {
      AppShortcut(
         intent: ShowMovie(),
         phrases: [
            "Show me the movie I \(\.$movieType) in \(.applicationName)",
            "Find the movie I \(\.$movieType) in \(.applicationName)"
         ],
         shortTitle: LocalizedStringResource("Get Movie"),
         systemImageName: "star.circle"
      )
   }
}