From 900ae203da3b550cbf5113fe31f1af7f2a473443 Mon Sep 17 00:00:00 2001 From: Vedant Agarwal Date: Sat, 14 Feb 2026 17:55:46 +0530 Subject: [PATCH] fix: smooth tab switching with fade animations (#1479) --- App/CompactViewController.swift | 12 ++++++++---- Views/BrowserTab.swift | 2 +- Views/BuildingBlocks/WebView.swift | 6 ++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/App/CompactViewController.swift b/App/CompactViewController.swift index d3c975e23..02ebcf2a3 100644 --- a/App/CompactViewController.swift +++ b/App/CompactViewController.swift @@ -136,11 +136,15 @@ private struct CompactViewWrapper: View { @EnvironmentObject private var navigation: NavigationViewModel var body: some View { - if case .loading = navigation.currentItem { - LoadingDataView() - } else if case let .tab(tabID) = navigation.currentItem { - CompactView(tabID: tabID) + Group { + if case .loading = navigation.currentItem { + LoadingDataView() + } else if case let .tab(tabID) = navigation.currentItem { + CompactView(tabID: tabID) + .transition(.opacity) + } } + .animation(.easeInOut(duration: 0.2), value: navigation.currentItem) } } diff --git a/Views/BrowserTab.swift b/Views/BrowserTab.swift index 97f1e1850..e76eae302 100644 --- a/Views/BrowserTab.swift +++ b/Views/BrowserTab.swift @@ -191,7 +191,7 @@ struct BrowserTab: View { .overlay { if case .webPage(let isLoading) = model.state, isLoading { LoadingProgressView() - .background(Color.background) + .allowsHitTesting(false) } } #if os(macOS) diff --git a/Views/BuildingBlocks/WebView.swift b/Views/BuildingBlocks/WebView.swift index 59cdab90c..2cc6cd888 100644 --- a/Views/BuildingBlocks/WebView.swift +++ b/Views/BuildingBlocks/WebView.swift @@ -117,12 +117,14 @@ final class WebViewController: UIViewController { topSafeAreaConstraint = view.safeAreaLayoutGuide.topAnchor.constraint(equalTo: webView.topAnchor) topSafeAreaConstraint?.isActive = true layoutCancellable = layoutSubject - .debounce(for: .seconds(0.15), scheduler: RunLoop.main) + .debounce(for: .seconds(0.05), scheduler: RunLoop.main) .sink { [weak self] _ in guard let view = self?.view, let webView = self?.webView, view.subviews.contains(webView) else { return } - webView.alpha = 1 + UIView.animate(withDuration: 0.2) { + webView.alpha = 1 + } guard self?.topSafeAreaConstraint?.isActive == true else { return } self?.topSafeAreaConstraint?.isActive = false self?.view.topAnchor.constraint(equalTo: webView.topAnchor).isActive = true