Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Ref #1499: Add link preview to long press context.
Browse files Browse the repository at this point in the history
  • Loading branch information
iccub committed Oct 10, 2019
1 parent 41ef43f commit 44946a9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2511,11 +2511,21 @@ extension BrowserViewController: WKUIDelegate {
return UIMenu(title: url.absoluteString, children: actions)
}

let config = UIContextMenuConfiguration(identifier: nil, previewProvider: nil, actionProvider: actionProvider)
let linkPreview: UIContextMenuContentPreviewProvider = {
return SFSafariViewController(url: url)
}

let config = UIContextMenuConfiguration(identifier: nil, previewProvider: linkPreview, actionProvider: actionProvider)

completionHandler(config)
}

@available(iOS 13.0, *)
func webView(_ webView: WKWebView, contextMenuForElement elementInfo: WKContextMenuElementInfo, willCommitWithAnimator animator: UIContextMenuInteractionCommitAnimating) {
guard let url = elementInfo.linkURL else { return }
webView.load(URLRequest(url: url))
}

fileprivate func addTab(url: URL, inPrivateMode: Bool, currentTab: Tab) {
let tab = self.tabManager.addTab(URLRequest(url: url), afterTab: currentTab, isPrivate: inPrivateMode)
if inPrivateMode && !PrivateBrowsingManager.shared.isPrivateBrowsing {
Expand Down

0 comments on commit 44946a9

Please sign in to comment.