// The acts Siri, Shortcuts, the Action Button, Control Centre and the Live // Activity can ask of Cotton Meetings. Each runs in the app's process and // hands its act to the recorder (`MeetingsIntentBridge`). // // The titles and phrases are App Intents metadata, read by the system at // build time, so they must be literals: each is a KEY here, and its words are // the kit's `meetings` lines `intent.*`, written into `Meetings.strings` and // `AppShortcuts.strings` (`App/MeetingsWidgets/Strings`, held equal to the // kit by `meetings-intents.test.ts`). import AppIntents import Foundation /// Start recording a meeting, without opening the app. public struct StartMeetingRecording: AudioRecordingIntent { public static let title: LocalizedStringResource = LocalizedStringResource("intent.start_meeting", table: "Meetings") public static let openAppWhenRun = false public init() {} @MainActor public func perform() async throws -> some IntentResult { try await MeetingsIntentBridge.run(.startMeeting) return .result() } } /// Start recording a memo, without opening the app. struct StartMemoRecording: AudioRecordingIntent { static let title: LocalizedStringResource = LocalizedStringResource("intent.start_memo", table: "Meetings") static let openAppWhenRun = false init() {} @MainActor func perform() async throws -> some IntentResult { try await MeetingsIntentBridge.run(.startMemo) return .result() } } public struct PauseMeetingRecording: LiveActivityIntent { public static let title: LocalizedStringResource = LocalizedStringResource("intent.pause", table: "Meetings") public init() {} @MainActor public func perform() async throws -> some IntentResult { try await MeetingsIntentBridge.run(.pause) return .result() } } public struct ResumeMeetingRecording: LiveActivityIntent { public static let title: LocalizedStringResource = LocalizedStringResource("intent.resume", table: "Meetings") public init() {} @MainActor public func perform() async throws -> some IntentResult { try await MeetingsIntentBridge.run(.resume) return .result() } } public struct MarkMeetingMoment: LiveActivityIntent { public static let title: LocalizedStringResource = LocalizedStringResource("intent.mark", table: "Meetings") public init() {} @MainActor public func perform() async throws -> some IntentResult { try await MeetingsIntentBridge.run(.mark) return .result() } } public struct StopMeetingRecording: LiveActivityIntent { public static let title: LocalizedStringResource = LocalizedStringResource("intent.stop", table: "Meetings") public init() {} @MainActor public func perform() async throws -> some IntentResult { try await MeetingsIntentBridge.run(.stop) return .result() } } /// What Siri and the Shortcuts app offer without setup, and what the Action /// Button lists. struct MeetingsShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: StartMeetingRecording(), phrases: ["intent.phrase_record \(.applicationName)", "intent.phrase_start \(.applicationName)"], shortTitle: LocalizedStringResource("intent.start_meeting", table: "Meetings"), systemImageName: "record.circle") AppShortcut( intent: StartMemoRecording(), phrases: ["intent.phrase_memo \(.applicationName)"], shortTitle: LocalizedStringResource("intent.start_memo", table: "Meetings"), systemImageName: "waveform") AppShortcut( intent: StopMeetingRecording(), phrases: ["intent.phrase_stop \(.applicationName)"], shortTitle: LocalizedStringResource("intent.stop", table: "Meetings"), systemImageName: "stop.circle") } } /// Lets the app's own target discover the intents declared in this package. public struct MeetingsLivePackage: AppIntentsPackage {}