import AppIntents import Foundation // MARK: - App Intents (Siri / Shortcuts / Spotlight) // // Surfaces the core monthly habit outside the app: "Update my portfolio" opens // Quick Update directly, "Check my portfolio" opens the dashboard. Registering an // AppShortcutsProvider also lists these actions in Spotlight and the Shortcuts app // with zero user setup — a discovery/retention surface the app didn't have. struct QuickUpdateIntent: AppIntent { static let title: LocalizedStringResource = "Update Portfolio" static let description = IntentDescription("Open Quick Update to record your latest portfolio values.") static let openAppWhenRun = true @MainActor func perform() async throws -> some IntentResult { // Same signal the widget deep link uses; ContentView routes it to the sheet. NotificationCenter.default.post(name: .openQuickUpdate, object: nil) return .result() } } struct OpenDashboardIntent: AppIntent { static let title: LocalizedStringResource = "Check Portfolio" static let description = IntentDescription("Open the dashboard to see your net worth and charts.") static let openAppWhenRun = true @MainActor func perform() async throws -> some IntentResult { NotificationCenter.default.post(name: .openDashboard, object: nil) return .result() } } struct PortfolioJournalShortcuts: AppShortcutsProvider { static var appShortcuts: [AppShortcut] { AppShortcut( intent: QuickUpdateIntent(), phrases: [ "Update my portfolio in \(.applicationName)", "Add a snapshot in \(.applicationName)" ], shortTitle: "Update Portfolio", systemImageName: "plus.circle.fill" ) AppShortcut( intent: OpenDashboardIntent(), phrases: [ "Check my portfolio in \(.applicationName)", "Show my net worth in \(.applicationName)" ], shortTitle: "Check Portfolio", systemImageName: "chart.line.uptrend.xyaxis" ) } }