improve manual hide logic for unsupported websites

This commit is contained in:
Fabian Freund
2026-02-21 08:38:29 +01:00
parent 4dc893acfd
commit f027155633
@@ -357,6 +357,8 @@ class BrowserScreen extends HookConsumerWidget {
// Toolbar is visible when: sheet is shown OR (not fullscreen AND controller says visible) // Toolbar is visible when: sheet is shown OR (not fullscreen AND controller says visible)
// The controller handles loading-start show internally via ref.listen on isLoading // The controller handles loading-start show internally via ref.listen on isLoading
final effectiveAppBarVisible = toolbarState == ToolbarVisibility.visible; final effectiveAppBarVisible = toolbarState == ToolbarVisibility.visible;
final toolbarManuallyDismissed =
toolbarState == ToolbarVisibility.dismissed;
final topToolbarVisible = final topToolbarVisible =
sheetDisplayed || (!tabInFullScreen && effectiveAppBarVisible); sheetDisplayed || (!tabInFullScreen && effectiveAppBarVisible);
final bottomToolbarVisible = final bottomToolbarVisible =
@@ -419,7 +421,9 @@ class BrowserScreen extends HookConsumerWidget {
: 0.0; : 0.0;
final findInPageHeightPx = (findInPageHeight * pixelRatio).round(); final findInPageHeightPx = (findInPageHeight * pixelRatio).round();
final stableToolbarHeight = autoHideTabBar ? bottomAppBarTotalHeight : 0.0; final stableToolbarHeight = autoHideTabBar && !toolbarManuallyDismissed
? bottomAppBarTotalHeight
: 0.0;
final stableToolbarHeightPx = (stableToolbarHeight * pixelRatio).round(); final stableToolbarHeightPx = (stableToolbarHeight * pixelRatio).round();
final keyboardHeightPx = useState<int?>(null); final keyboardHeightPx = useState<int?>(null);
@@ -467,9 +471,17 @@ class BrowserScreen extends HookConsumerWidget {
// Keep clipping state in sync with keyboard and auto-hide states. // Keep clipping state in sync with keyboard and auto-hide states.
// While keyboard is visible, do not apply toolbar clipping. // While keyboard is visible, do not apply toolbar clipping.
useEffect(() { useEffect(
() {
if (toolbarManuallyDismissed) {
desiredToolbarClippingPx.value = 0;
}
final targetClippingPx = final targetClippingPx =
autoHideTabBar && !keyboardVisible && !tabIsLoading autoHideTabBar &&
!toolbarManuallyDismissed &&
!keyboardVisible &&
!tabIsLoading
? desiredToolbarClippingPx.value ? desiredToolbarClippingPx.value
: 0; : 0;
@@ -479,12 +491,23 @@ class BrowserScreen extends HookConsumerWidget {
} }
return null; return null;
}, [autoHideTabBar, keyboardVisible, tabIsLoading]); },
[autoHideTabBar, toolbarManuallyDismissed, keyboardVisible, tabIsLoading],
);
final animationProgressCallback = useCallback(( final animationProgressCallback = useCallback((
double progress, double progress,
double heightPx, double heightPx,
) { ) {
if (toolbarManuallyDismissed) {
desiredToolbarClippingPx.value = 0;
if (lastClippingPx.value != 0) {
lastClippingPx.value = 0;
unawaited(viewportService.setVerticalClipping(0));
}
return;
}
// Clip content from bottom as toolbar hides. // Clip content from bottom as toolbar hides.
// Negative clipping = clip from bottom. // Negative clipping = clip from bottom.
final clippingPx = -((1.0 - progress) * heightPx * pixelRatio).round(); final clippingPx = -((1.0 - progress) * heightPx * pixelRatio).round();
@@ -498,7 +521,7 @@ class BrowserScreen extends HookConsumerWidget {
lastClippingPx.value = targetClippingPx; lastClippingPx.value = targetClippingPx;
unawaited(viewportService.setVerticalClipping(targetClippingPx)); unawaited(viewportService.setVerticalClipping(targetClippingPx));
} }
}, [keyboardVisible, pixelRatio, tabIsLoading]); }, [toolbarManuallyDismissed, keyboardVisible, pixelRatio, tabIsLoading]);
// Theme with dynamic snackbar margin to position above bottom toolbar // Theme with dynamic snackbar margin to position above bottom toolbar
final themeData = Theme.of(context).copyWith( final themeData = Theme.of(context).copyWith(
@@ -577,7 +600,8 @@ class BrowserScreen extends HookConsumerWidget {
position: TabBarPosition.bottom, position: TabBarPosition.bottom,
visible: bottomToolbarVisible, visible: bottomToolbarVisible,
toolbarHeight: bottomAppBarTotalHeight, toolbarHeight: bottomAppBarTotalHeight,
onAnimationProgress: autoHideTabBar onAnimationProgress:
autoHideTabBar && !toolbarManuallyDismissed
? animationProgressCallback ? animationProgressCallback
: null, : null,
child: _TabBar( child: _TabBar(