|
|
|
|
@ -10,7 +10,7 @@ import AppIntents |
|
|
|
|
import SwiftUI |
|
|
|
|
|
|
|
|
|
@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *) |
|
|
|
|
struct StartTimerIntent: AudioStartingIntent, CustomIntentMigratedAppIntent { |
|
|
|
|
struct StartTimerIntent: AudioStartingIntent { |
|
|
|
|
|
|
|
|
|
static let intentClassName = "StartTimerIntent" |
|
|
|
|
static var title: LocalizedStringResource = "Launch Timer" |
|
|
|
|
@ -25,7 +25,7 @@ struct StartTimerIntent: AudioStartingIntent, CustomIntentMigratedAppIntent { |
|
|
|
|
|
|
|
|
|
static var openAppWhenRun: Bool = true |
|
|
|
|
|
|
|
|
|
func perform() async throws -> some IntentResult & ProvidesDialog & ShowsSnippetView { |
|
|
|
|
func perform() async throws -> some IntentResult { |
|
|
|
|
|
|
|
|
|
let timerIdentifier: TimerIdentifierAppEntity |
|
|
|
|
if let timer { |
|
|
|
|
@ -38,14 +38,14 @@ struct StartTimerIntent: AudioStartingIntent, CustomIntentMigratedAppIntent { |
|
|
|
|
do { |
|
|
|
|
let _ = try await TimerRouter.performAction(timer: abstractTimer) |
|
|
|
|
print("perform() success !") |
|
|
|
|
return .result(dialog: "Timer \(abstractTimer.displayName) started") |
|
|
|
|
return .result(value: 1) |
|
|
|
|
} catch { |
|
|
|
|
Logger.error(error) |
|
|
|
|
let dialog: IntentDialog = "\(error.localizedDescription)" |
|
|
|
|
return .result(dialog: dialog) |
|
|
|
|
// let dialog: IntentDialog = "\(error.localizedDescription)" |
|
|
|
|
return .result(value: 0) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return .result(dialog: "The timer has not been found in the app") |
|
|
|
|
return .result(value: 0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func timerEntities() -> [TimerIdentifierAppEntity] { |
|
|
|
|
|