Web app improvements

This commit is contained in:
Ilya Laktyushin
2022-04-02 15:51:30 +04:00
parent bb0339b6f4
commit 1bcdd691ec
10 changed files with 154 additions and 43 deletions

View File

@@ -209,10 +209,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
let placeholderNode = ShimmerEffectNode()
self.addSubnode(placeholderNode)
self.placeholderNode = placeholderNode
if controller.buttonText == nil {
self.addSubnode(self.loadingProgressNode)
}
self.addSubnode(self.loadingProgressNode)
if let iconFile = controller.iconFile {
let _ = freeMediaFileInteractiveFetched(account: self.context.account, fileReference: .standalone(media: iconFile)).start()
@@ -337,6 +334,7 @@ public final class WebAppController: ViewController, AttachmentContainable {
self.controller?.navigationBar?.updateBackgroundAlpha(min(30.0, contentOffset) / 30.0, transition: .immediate)
}
private var validLayout: (ContainerViewLayout, CGFloat)?
func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) {
let previous = self.validLayout?.0
@@ -344,7 +342,6 @@ public final class WebAppController: ViewController, AttachmentContainable {
if let webView = self.webView, let controller = self.controller {
let frame = CGRect(origin: CGPoint(x: layout.safeInsets.left, y: navigationBarHeight), size: CGSize(width: layout.size.width - layout.safeInsets.left - layout.safeInsets.right, height: max(1.0, layout.size.height - navigationBarHeight - layout.intrinsicInsets.bottom - layout.additionalInsets.bottom)))
webView.updateFrame(frame: frame, panning: controller.isContainerPanning(), transition: transition)
}
@@ -371,6 +368,17 @@ public final class WebAppController: ViewController, AttachmentContainable {
}
}
func isContainerPanningUpdated(_ panning: Bool) {
guard let (layout, navigationBarHeight) = self.validLayout else {
return
}
if let webView = self.webView {
let frame = CGRect(origin: CGPoint(x: layout.safeInsets.left, y: navigationBarHeight), size: CGSize(width: layout.size.width - layout.safeInsets.left - layout.safeInsets.right, height: max(1.0, layout.size.height - navigationBarHeight - layout.intrinsicInsets.bottom - layout.additionalInsets.bottom)))
webView.updateFrame(frame: frame, panning: panning, transition: .immediate)
}
}
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == "estimatedProgress", let webView = self.webView {
self.loadingProgressNode.updateProgress(webView.estimatedProgress, animated: true)