mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
add share option to web reader context menu
This commit is contained in:
parent
05925c42d2
commit
954d84fab2
4 changed files with 17 additions and 0 deletions
|
|
@ -17,6 +17,7 @@ import WebKit
|
|||
@Binding var decreaseFontActionID: UUID?
|
||||
@Binding var annotationSaveTransactionID: UUID?
|
||||
@Binding var showNavBarActionID: UUID?
|
||||
@Binding var shareActionID: UUID?
|
||||
@Binding var annotation: String
|
||||
|
||||
func makeCoordinator() -> WebReaderCoordinator {
|
||||
|
|
@ -81,6 +82,11 @@ import WebKit
|
|||
context.coordinator.showNavBar()
|
||||
}
|
||||
|
||||
if shareActionID != context.coordinator.previousShareActionID {
|
||||
context.coordinator.previousShareActionID = shareActionID
|
||||
(webView as? WebView)?.shareOriginalItem()
|
||||
}
|
||||
|
||||
// If the webview had been terminated `needsReload` will have been set to true
|
||||
if context.coordinator.needsReload {
|
||||
loadContent(webView: webView)
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import WebKit
|
|||
@State var decreaseFontActionID: UUID?
|
||||
@State var annotationSaveTransactionID: UUID?
|
||||
@State var showNavBarActionID: UUID?
|
||||
@State var shareActionID: UUID?
|
||||
@State var annotation = String()
|
||||
|
||||
@EnvironmentObject var dataService: DataService
|
||||
|
|
@ -104,6 +105,10 @@ import WebKit
|
|||
)
|
||||
}
|
||||
)
|
||||
Button(
|
||||
action: { shareActionID = UUID() },
|
||||
label: { Label("Share", systemImage: "square.and.arrow.up") }
|
||||
)
|
||||
Button(
|
||||
action: { showDeleteConfirmation = true },
|
||||
label: { Label("Delete", systemImage: "trash") }
|
||||
|
|
@ -156,6 +161,7 @@ import WebKit
|
|||
decreaseFontActionID: $decreaseFontActionID,
|
||||
annotationSaveTransactionID: $annotationSaveTransactionID,
|
||||
showNavBarActionID: $showNavBarActionID,
|
||||
shareActionID: $shareActionID,
|
||||
annotation: $annotation
|
||||
)
|
||||
.onTapGesture {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ final class WebReaderCoordinator: NSObject {
|
|||
var previousIncreaseFontActionID: UUID?
|
||||
var previousDecreaseFontActionID: UUID?
|
||||
var previousShowNavBarActionID: UUID?
|
||||
var previousShareActionID: UUID?
|
||||
var updateNavBarVisibilityRatio: (Double) -> Void = { _ in }
|
||||
private var yOffsetAtStartOfDrag: Double?
|
||||
private var lastYOffset: Double = 0
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@ public final class WebView: WKWebView {
|
|||
dispatchEvent("decreaseFontSize")
|
||||
}
|
||||
|
||||
public func shareOriginalItem() {
|
||||
dispatchEvent("share")
|
||||
}
|
||||
|
||||
func dispatchEvent(_ name: String) {
|
||||
let dispatch = "document.dispatchEvent(new Event('\(name)'));"
|
||||
evaluateJavaScript(dispatch) { obj, err in
|
||||
|
|
|
|||
Loading…
Reference in a new issue