mirror of
git://jb55.com/damus
synced 2024-09-18 19:23:49 +00:00
ui: hold tap to preview status URL
Applied a WKWebkitView inside a .contextMenu to show preview status for URL links in user status messages. Closes: https://github.com/damus-io/damus/issues/1523 Changelog-Added: Hold tap to preview status URL Signed-off-by: Jericho Hasselbush <jericho@sal-et-lucem.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
b1e0a62109
commit
c4a9f2fdb2
@ -7,7 +7,7 @@
|
||||
|
||||
import SwiftUI
|
||||
import MediaPlayer
|
||||
|
||||
import WebKit
|
||||
|
||||
struct UserStatusView: View {
|
||||
@ObservedObject var status: UserStatusModel
|
||||
@ -35,6 +35,15 @@ struct UserStatusView: View {
|
||||
openURL(url)
|
||||
}
|
||||
}
|
||||
.contextMenu(
|
||||
menuItems: {
|
||||
if let url = st.url {
|
||||
Button(url.absoluteString, action: { openURL(url) }) }
|
||||
}, preview: {
|
||||
if let url = st.url {
|
||||
URLPreview(url: url)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@ -49,6 +58,19 @@ struct UserStatusView: View {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
struct URLPreview: UIViewRepresentable {
|
||||
var url: URL
|
||||
|
||||
func makeUIView(context: Context) -> WKWebView {
|
||||
return WKWebView()
|
||||
}
|
||||
|
||||
func updateUIView(_ wkView: WKWebView, context: Context) {
|
||||
let request = URLRequest(url: url)
|
||||
wkView.load(request)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user