Various fixes

This commit is contained in:
Ilya Laktyushin
2024-08-02 22:05:33 +02:00
parent 8e8b8b7a3e
commit 2ea60be3da
5 changed files with 62 additions and 39 deletions

View File

@@ -18,6 +18,7 @@ import MinimizedContainer
import InstantPageUI
import NavigationStackComponent
import LottieComponent
import WebKit
private let settingsTag = GenericComponentViewTag()
@@ -489,13 +490,13 @@ public class BrowserScreen: ViewController, MinimizableController {
case expand
}
fileprivate final class Node: ViewControllerTracingNode {
final class Node: ViewControllerTracingNode {
private weak var controller: BrowserScreen?
private let context: AccountContext
private let contentContainerView = UIView()
fileprivate let contentNavigationContainer = ComponentView<Empty>()
fileprivate var content: [BrowserContent] = []
private(set) var content: [BrowserContent] = []
fileprivate var contentState: BrowserContentState?
private var contentStateDisposable = MetaDisposable()
@@ -785,13 +786,14 @@ public class BrowserScreen: ViewController, MinimizableController {
let browserContent: BrowserContent
switch content {
case let .webPage(url):
let webContent = BrowserWebContent(context: self.context, presentationData: self.presentationData, url: url)
let webContent = BrowserWebContent(context: self.context, presentationData: self.presentationData, url: url, preferredConfiguration: self.controller?.preferredConfiguration)
webContent.cancelInteractiveTransitionGestures = { [weak self] in
if let self, let view = self.controller?.view {
cancelInteractiveTransitionGestures(view: view)
}
}
browserContent = webContent
self.controller?.preferredConfiguration = nil
case let .instantPage(webPage, anchor, sourceLocation):
let instantPageContent = BrowserInstantPageContent(context: self.context, presentationData: self.presentationData, webPage: webPage, anchor: anchor, url: webPage.content.url ?? "", sourceLocation: sourceLocation)
instantPageContent.openPeer = { [weak self] peer in
@@ -846,7 +848,9 @@ public class BrowserScreen: ViewController, MinimizableController {
return
}
if controller.isMinimized {
if let navigationController = controller.navigationController as? NavigationController, let minimizedContainer = navigationController.minimizedContainer {
minimizedContainer.removeController(controller)
}
} else {
controller.dismiss()
}
@@ -1373,7 +1377,7 @@ public class BrowserScreen: ViewController, MinimizableController {
private let context: AccountContext
private let subject: Subject
private var preferredConfiguration: WKWebViewConfiguration?
private var openPreviousOnClose = false
private var validLayout: ContainerViewLayout?
@@ -1390,7 +1394,7 @@ public class BrowserScreen: ViewController, MinimizableController {
// "application/vnd.openxmlformats-officedocument.presentationml.presentation"
]
public init(context: AccountContext, subject: Subject, openPreviousOnClose: Bool = false) {
public init(context: AccountContext, subject: Subject, preferredConfiguration: WKWebViewConfiguration? = nil, openPreviousOnClose: Bool = false) {
var subject = subject
if case let .webPage(url) = subject, let parsedUrl = URL(string: url) {
if parsedUrl.host?.hasSuffix(".ton") == true {
@@ -1403,6 +1407,7 @@ public class BrowserScreen: ViewController, MinimizableController {
}
self.context = context
self.subject = subject
self.preferredConfiguration = preferredConfiguration
self.openPreviousOnClose = openPreviousOnClose
super.init(navigationBarPresentationData: nil)
@@ -1420,7 +1425,7 @@ public class BrowserScreen: ViewController, MinimizableController {
preconditionFailure()
}
private var node: Node {
var node: Node {
return self.displayNode as! Node
}