Feature: make Reader use center window

This commit is contained in:
James Magahern
2022-08-22 17:10:47 -07:00
parent ac345ef613
commit 184396b1d8
8 changed files with 116 additions and 19 deletions

View File

@@ -299,13 +299,26 @@ class BrowserViewController: UIViewController
DispatchQueue.main.async {
documentControls.dismiss(animated: true, completion: nil)
let readableViewController = ReaderViewController(readableHTMLString: string, baseURL: self.tab.bridge.webView.url)
readableViewController.title = self.tab.bridge.webView.title
readableViewController.darkModeEnabled = self.tab.bridge.darkModeEnabled
readableViewController.delegate = self
if self.traitCollection.userInterfaceIdiom == .phone {
let readableViewController = ReaderViewController(readableHTMLString: string, baseURL: self.tab.bridge.webView.url)
readableViewController.title = self.tab.bridge.webView.title
readableViewController.darkModeEnabled = self.tab.bridge.darkModeEnabled
readableViewController.delegate = self
let navigationController = UINavigationController(rootViewController: readableViewController)
self.present(navigationController, animated: true, completion: nil)
} else {
let userActivity = NSUserActivity(activityType: SessionActivityType.ReaderWindow.rawValue)
userActivity.title = self.tab.title
userActivity.userInfo = [
ReaderUserActivityKeys.baseURL.rawValue : self.tab.bridge.webView.url ?? NSNull(),
ReaderUserActivityKeys.htmlString.rawValue : string,
]
let requestOptions = UIWindowScene.ActivationRequestOptions()
requestOptions.preferredPresentationStyle = .prominent
UIApplication.shared.requestSceneSessionActivation(nil, userActivity: userActivity, options: requestOptions)
}
let navigationController = UINavigationController(rootViewController: readableViewController)
self.present(navigationController, animated: true, completion: nil)
}
}
}, for: .touchUpInside)