Reader Mode
This commit is contained in:
@@ -240,6 +240,23 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
documentControls.navigationControlView.forwardButton.isEnabled = webView.canGoForward
|
||||
}))
|
||||
|
||||
// Reader mode
|
||||
documentControls.readabilityView.addAction(UIAction { [unowned self] _ in
|
||||
tab.bridge.parseDocumentForReaderMode { string in
|
||||
DispatchQueue.main.async {
|
||||
documentControls.dismiss(animated: true, completion: nil)
|
||||
|
||||
let readableViewController = ReaderViewController(readableHTMLString: string, baseURL: tab.bridge.webView.url)
|
||||
readableViewController.title = tab.bridge.webView.title
|
||||
readableViewController.darkModeEnabled = tab.bridge.darkModeEnabled
|
||||
readableViewController.delegate = self
|
||||
|
||||
let navigationController = UINavigationController(rootViewController: readableViewController)
|
||||
present(navigationController, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
}, for: .touchUpInside)
|
||||
|
||||
present(documentControls, animated: true, completion: nil)
|
||||
}), for: .touchUpInside)
|
||||
|
||||
@@ -708,3 +725,10 @@ class BrowserViewController: UIViewController, WKNavigationDelegate, WKUIDelegat
|
||||
tab.webView._viewScale -= 0.10
|
||||
}
|
||||
}
|
||||
|
||||
extension BrowserViewController: ReaderViewControllerDelegate
|
||||
{
|
||||
func readerViewController(_ reader: ReaderViewController, didRequestNavigationToURL navigationURL: URL) {
|
||||
tab.beginLoadingURL(navigationURL)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user