← All repositories

reportage

A life-logging app for iPhone

git clone https://code.inqk.net/reportage.git


Shared/Intents/LogPassiveReportIntent.swift (1294B)

1import AppIntents
2
3/// Logs an instant report from Shortcuts, Siri, the Action button, the
4/// Control Center control and the Lock Screen widget.
5///
6/// Controls and widgets live in the widget extension, and by default an
7/// intent they trigger runs there. Conforming to `LiveActivityIntent` makes
8/// the system run it in the app's process instead, launched in the
9/// background if need be. Capturing the moment needs the app: location is
10/// live context, and the store lives in the app's container.
11struct LogPassiveReportIntent: AppIntent, LiveActivityIntent {
12    static let title: LocalizedStringResource = "Instant Report"
13    static let description = IntentDescription(
14        "Files this report without a survey. You can fill it in later, or leave it as it is.")
15    static let supportedModes: IntentModes = .background
16
17    @Dependency private var logger: any InstantReportLogging
18
19    func perform() async throws -> some IntentResult & ProvidesDialog {
20        try await logger.logInstantReport()
21        return .result(dialog: "Filed.")
22    }
23}
24
25/// What the intent needs from the app. The widget extension compiles the
26/// intent but never performs it, so it only needs to see this protocol.
27protocol InstantReportLogging: Sendable {
28    func logInstantReport() async throws
29}