diff --git a/apple/OmnivoreKit/Sources/App/AppExtensions/Intents/SavePasteboardToOmnivore.swift b/apple/OmnivoreKit/Sources/App/AppExtensions/Intents/SavePasteboardToOmnivore.swift new file mode 100644 index 000000000..6737748db --- /dev/null +++ b/apple/OmnivoreKit/Sources/App/AppExtensions/Intents/SavePasteboardToOmnivore.swift @@ -0,0 +1,57 @@ +// +// SavePasteboardToOmnivore.swift +// +// +// Created by Jackson Harper on 2/6/23. +// + +import AppIntents +import Services +import SwiftUI + +@available(iOS 16.0, *) +struct SaveLinkToOmnivoreIntent: AppIntent { + static var title: LocalizedStringResource = "Show Sport Progress" + + static var parameterSummary: some ParameterSummary { + Summary("Save \(\.$link) to your Omnivore library.") + } + + @Parameter(title: "link") + var link: URL + + @MainActor + func perform() async throws -> some IntentResult { + do { + let services = Services() + let requestId = UUID().uuidString.lowercased() + let saveResult = try await services.dataService.saveURL(id: requestId, url: link.absoluteString) + + return .result(dialog: "Link saved to Omnivore") + } catch { + print("error saving URL: ", error) + } + return .result(dialog: "Error saving link") + } +} + +// @available(iOS 16.0, *) +// struct ReadInOmnivoreIntent: AppIntent { +// static var title: LocalizedStringResource = "Read saved link" +// static var description = IntentDescription("Reads a link you have already saved to your library") +// static var openAppWhenRun: Bool = true +// +// @Parameter(title: "requestID") +// var link: String +// +// func perform() async throws -> some IntentResult { +// .result(dialog: "Opening in Omnivore") +// } +// } +// +// @available(iOS 16.0, *) +// struct OmnivoreShortcuts: AppShortcutsProvider { +// static var appShortcuts: [AppShortcut] { +// AppShortcut(intent: SaveLinkToOmnivoreIntent(), phrases: ["Save to \(.applicationName)"]) +// } +// } diff --git a/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings b/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings index bdf14959d..bf38eb699 100644 --- a/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings +++ b/apple/OmnivoreKit/Sources/Views/Resources/en.lproj/Localizable.strings @@ -6,6 +6,7 @@ "saveArticleSavedState" = "Saved to Omnivore"; "saveArticleProcessingState" = "Saved to Omnivore"; "extensionAppUnauthorized" = "Please login to Omnivore from the app before saving your first link."; +"saveToOmnivore" = "Save to Omnivore"; // audio player "audioPlayerReplay" = "Replay"; diff --git a/apple/OmnivoreKit/Sources/Views/Resources/zh-Hans.lproj/Localizable.strings b/apple/OmnivoreKit/Sources/Views/Resources/zh-Hans.lproj/Localizable.strings index 21997d684..616515f33 100644 --- a/apple/OmnivoreKit/Sources/Views/Resources/zh-Hans.lproj/Localizable.strings +++ b/apple/OmnivoreKit/Sources/Views/Resources/zh-Hans.lproj/Localizable.strings @@ -7,6 +7,8 @@ "saveArticleProcessingState" = "已经保存到 Omnivore 中"; "extensionAppUnauthorized" = "请在保存您的第一个链接之前从应用程序登录 Omnivore."; +"saveToOmnivore" = "Save to Omnivore"; + // audio player "audioPlayerReplay" = "重播";