Merge commit 'b8390c10cb9a2bb000d993ead657a026192de924'

This commit is contained in:
Ali 2022-03-27 19:52:12 +04:00
commit 57b728ec94

View File

@ -49,7 +49,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
public var updateTabBarAlpha: (CGFloat, ContainedViewLayoutTransition) -> Void = { _, _ in }
public var cancelPanGesture: () -> Void = { }
private class Node: ViewControllerTracingNode, UIScrollViewDelegate {
private class Node: ViewControllerTracingNode, WKNavigationDelegate, UIScrollViewDelegate {
private weak var controller: WebAppController?
private var webView: WKWebView?
@ -109,8 +109,10 @@ public final class WebAppController: ViewController, AttachmentContainable {
}
let webView = WKWebView(frame: CGRect(), configuration: configuration)
webView.alpha = 0.0
webView.isOpaque = false
webView.backgroundColor = .clear
webView.navigationDelegate = self
if #available(iOSApplicationExtension 9.0, iOS 9.0, *) {
webView.allowsLinkPreview = false
@ -169,6 +171,21 @@ public final class WebAppController: ViewController, AttachmentContainable {
}
}
private var loadCount = 0
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
self.loadCount += 1
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
self.loadCount -= 1
Queue.mainQueue().after(0.1, {
if self.loadCount == 0, let webView = self.webView {
ContainedViewLayoutTransition.animated(duration: 0.2, curve: .linear).updateAlpha(layer: webView.layer, alpha: 1.0)
}
})
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let contentOffset = scrollView.contentOffset.y
self.controller?.navigationBar?.updateBackgroundAlpha(min(30.0, contentOffset) / 30.0, transition: .immediate)