improve manual hide logic for unsupported websites
This commit is contained in:
@@ -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,24 +471,43 @@ 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(
|
||||||
final targetClippingPx =
|
() {
|
||||||
autoHideTabBar && !keyboardVisible && !tabIsLoading
|
if (toolbarManuallyDismissed) {
|
||||||
? desiredToolbarClippingPx.value
|
desiredToolbarClippingPx.value = 0;
|
||||||
: 0;
|
}
|
||||||
|
|
||||||
if (targetClippingPx != lastClippingPx.value) {
|
final targetClippingPx =
|
||||||
lastClippingPx.value = targetClippingPx;
|
autoHideTabBar &&
|
||||||
unawaited(viewportService.setVerticalClipping(targetClippingPx));
|
!toolbarManuallyDismissed &&
|
||||||
}
|
!keyboardVisible &&
|
||||||
|
!tabIsLoading
|
||||||
|
? desiredToolbarClippingPx.value
|
||||||
|
: 0;
|
||||||
|
|
||||||
return null;
|
if (targetClippingPx != lastClippingPx.value) {
|
||||||
}, [autoHideTabBar, keyboardVisible, tabIsLoading]);
|
lastClippingPx.value = targetClippingPx;
|
||||||
|
unawaited(viewportService.setVerticalClipping(targetClippingPx));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
},
|
||||||
|
[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(
|
||||||
|
|||||||
Reference in New Issue
Block a user