Repository Public
1// SP Wallet iOS2// File: Intents/WalletIntents.swift3// Description: App Intents (Siri, Shortcuts, Spotlight): open the wallet, an asset, the history, the alerts. Navigation only —4// no intent prepares, approves or sends anything, and none returns a balance to Siri.5//6// Author: Simon-Pierre Boucher7// Contact: contact@spboucher.ai8import AppIntents9import UIKit1011@MainActor12private func openDeepLink(_ s: String) async {13 guard let u = URL(string: s) else { return }14 await UIApplication.shared.open(u)15}1617struct OpenWalletIntent: AppIntent {18 static let title: LocalizedStringResource = "Ouvrir le portefeuille"19 static let description = IntentDescription("Ouvre SP Wallet sur le tableau de bord.")20 static let openAppWhenRun = true21 @MainActor func perform() async throws -> some IntentResult { await openDeepLink("spwallet://home"); return .result() }22}2324struct OpenActivityIntent: AppIntent {25 static let title: LocalizedStringResource = "Afficher l’historique"26 static let description = IntentDescription("Ouvre l’historique des transactions de SP Wallet.")27 static let openAppWhenRun = true28 @MainActor func perform() async throws -> some IntentResult { await openDeepLink("spwallet://activity"); return .result() }29}3031struct OpenAlertsIntent: AppIntent {32 static let title: LocalizedStringResource = "Ouvrir les alertes"33 static let description = IntentDescription("Ouvre le centre d’alertes de SP Wallet.")34 static let openAppWhenRun = true35 @MainActor func perform() async throws -> some IntentResult { await openDeepLink("spwallet://alerts"); return .result() }36}3738struct OpenAssetIntent: AppIntent {39 static let title: LocalizedStringResource = "Consulter un actif"40 static let description = IntentDescription("Ouvre la page d’un actif dans SP Wallet.")41 static let openAppWhenRun = true42 @Parameter(title: "Symbole", description: "Par exemple BTC, ETH, USDC") var symbol: String4344 @MainActor func perform() async throws -> some IntentResult {45 let s = symbol.uppercased().filter { $0.isLetter || $0.isNumber }46 guard !s.isEmpty, s.count <= 16 else { throw $symbol.needsValueError("Quel actif ?") }47 await openDeepLink("spwallet://asset/\(s)")48 return .result()49 }50}5152struct WalletShortcuts: AppShortcutsProvider {53 static var appShortcuts: [AppShortcut] {54 AppShortcut(intent: OpenWalletIntent(), phrases: ["Ouvrir \(.applicationName)", "Open \(.applicationName)"], shortTitle: "Portefeuille", systemImageName: "lock.shield")55 AppShortcut(intent: OpenActivityIntent(), phrases: ["Historique dans \(.applicationName)", "Show history in \(.applicationName)"], shortTitle: "Historique", systemImageName: "list.bullet.rectangle")56 AppShortcut(intent: OpenAlertsIntent(), phrases: ["Alertes dans \(.applicationName)", "Show alerts in \(.applicationName)"], shortTitle: "Alertes", systemImageName: "bell")57 AppShortcut(intent: OpenAssetIntent(), phrases: ["Consulter un actif dans \(.applicationName)", "Show an asset in \(.applicationName)"], shortTitle: "Actif", systemImageName: "bitcoinsign.circle")58 }59}60