diff --git a/submodules/WebUI/Sources/WebAppController.swift b/submodules/WebUI/Sources/WebAppController.swift index 192a53acc0..4e6a4b14be 100644 --- a/submodules/WebUI/Sources/WebAppController.swift +++ b/submodules/WebUI/Sources/WebAppController.swift @@ -336,13 +336,11 @@ public final class WebAppController: ViewController, AttachmentContainable { self.controller?.navigationBar?.updateBackgroundAlpha(min(30.0, contentOffset) / 30.0, transition: .immediate) } - private var animationProgress: CGFloat = 0.0 - private var floatSnapshotView: UIView? - - - - + private var validLayout: (ContainerViewLayout, CGFloat)? func containerLayoutUpdated(_ layout: ContainerViewLayout, navigationBarHeight: CGFloat, transition: ContainedViewLayoutTransition) { + let previous = self.validLayout?.0 + self.validLayout = (layout, navigationBarHeight) + 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))) @@ -366,6 +364,10 @@ public final class WebAppController: ViewController, AttachmentContainable { let loadingProgressHeight: CGFloat = 2.0 transition.updateFrame(node: self.loadingProgressNode, frame: CGRect(origin: CGPoint(x: 0.0, y: height - loadingProgressHeight), size: CGSize(width: layout.size.width, height: loadingProgressHeight))) } + + if let previous = previous, (previous.inputHeight ?? 0.0).isZero, let inputHeight = layout.inputHeight, inputHeight > 44.0 { + self.controller?.requestAttachmentMenuExpansion() + } } override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { diff --git a/submodules/WebUI/Sources/WebAppWebView.swift b/submodules/WebUI/Sources/WebAppWebView.swift index f743715edf..0d6950582d 100644 --- a/submodules/WebUI/Sources/WebAppWebView.swift +++ b/submodules/WebUI/Sources/WebAppWebView.swift @@ -112,15 +112,27 @@ final class WebAppWebView: WKWebView { if panning { let fixedPositionViews = findFixedPositionViews(webView: self, classes: self.fixedPositionClasses) if fixedPositionViews.count != self.currentFixedViews.count { - reset() + var existing: [String: (UIView, UIView)] = [:] + for (className, originalView, snapshotView) in self.currentFixedViews { + existing[className] = (originalView, snapshotView) + } var updatedFixedViews: [(String, UIView, UIView)] = [] for (className, view) in fixedPositionViews { - if let snapshotView = view.snapshotView(afterScreenUpdates: false) { + if let (_, existingSnapshotView) = existing[className] { + updatedFixedViews.append((className, view, existingSnapshotView)) + existing[className] = nil + } else if let snapshotView = view.snapshotView(afterScreenUpdates: false) { updatedFixedViews.append((className, view, snapshotView)) self.addSubview(snapshotView) } } + + for (_, originalAndSnapshotView) in existing { + originalAndSnapshotView.0.isHidden = false + originalAndSnapshotView.1.removeFromSuperview() + } + self.currentFixedViews = updatedFixedViews } transition.updateFrame(view: self, frame: frame)