Allow library items to be dragged into other apps
This commit is contained in:
@ -66,6 +66,13 @@ public extension LinkedItem {
|
||||
var unwrappedSavedAt: Date { savedAt ?? Date() }
|
||||
var unwrappedCreatedAt: Date { createdAt ?? Date() }
|
||||
|
||||
var deepLink: URL? {
|
||||
if let id = id {
|
||||
return URL(string: "omnivore://read/\(id)")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var hasLabels: Bool {
|
||||
(labels?.count ?? 0) > 0
|
||||
}
|
||||
|
||||
@ -40,8 +40,7 @@ public extension DeepLink {
|
||||
case "saved-search":
|
||||
let named = url.path.replacingOccurrences(of: "/", with: "")
|
||||
return .savedSearch(named: named)
|
||||
case "read":
|
||||
case "shareExtensionRequestID":
|
||||
case "read", "shareExtensionRequestID":
|
||||
let requestID = url.path.replacingOccurrences(of: "/", with: "")
|
||||
return .webAppLinkRequest(requestID: requestID)
|
||||
default:
|
||||
|
||||
@ -2,6 +2,17 @@ import Models
|
||||
import SwiftUI
|
||||
import Utils
|
||||
|
||||
public extension View {
|
||||
func draggableItem(item: LinkedItem) -> some View {
|
||||
if #available(iOS 16.0, *), let url = item.deepLink {
|
||||
return AnyView(self.draggable(url) {
|
||||
Label(item.unwrappedTitle, systemImage: "link")
|
||||
})
|
||||
}
|
||||
return AnyView(self)
|
||||
}
|
||||
}
|
||||
|
||||
public struct LibraryItemCard: View {
|
||||
let viewer: Viewer?
|
||||
let tapHandler: () -> Void
|
||||
@ -27,6 +38,7 @@ public struct LibraryItemCard: View {
|
||||
}
|
||||
}
|
||||
.padding(.bottom, 8)
|
||||
.draggableItem(item: item)
|
||||
}
|
||||
|
||||
var isFullyRead: Bool {
|
||||
|
||||
Reference in New Issue
Block a user