Files
buzz/mobile/lib/shared/widgets/native_route_controls.dart
Tom Brow 7361326717 fix(mobile): keep glass controls mounted and the wide thread push parallax (#9726)
Fixes three regressions that #9717 (Duo chat switching) introduced.

**Glass controls blank when anything covers their route.** #9717 gated
`IosGlassNavigationButton` and `IosGlassNavigationAction` on
`useNativeRouteControlsVisible`, so every glass control (Home's filter
chips, glass Back, Close, Done) unmounted under any dialog, alert or
modal sheet and during every push, pop and back swipe, then came back as
a new platform view near the end of the transition. This drops the gate
from those two widgets, which restores their behaviour from before
#9717. The problem #9717 targets is unaffected: under Search and
Activity sheets the hook already returns true and the opaque backing
hides the controls. Home's gate, the Channels route sync and
`IosMessageCreateButton` keep the hook.

**The visibility hook rebuilt its host on every animation frame.** It
subscribed to the route's animation values but only reads whether the
covering animation is at zero and whether the route is reversing. It now
uses `useListenableSelector` on those two booleans, so a host rebuilds
only when visibility can change.

**A wide thread push lost the outgoing chat's slide.** For an immediate
wide selection, `_ConversationDetailRoute.buildTransitions` returned its
child directly, which also discarded the secondary animation that moves
the chat left when a thread is pushed over it. It now builds the
platform transition with a completed primary animation, so selection
stays immediate and the covered chat keeps its parallax.

### Regressions

- Glass controls go back to staying mounted under covering routes, as
they did before #9717. Platform-view bleed under non-sheet routes is
therefore the pre-#9717 behaviour, not new.
- No change to compact navigation or to the Search and Activity sheet
composition.

### Validation

Added tests:
-
[native_route_controls_test.dart](fb0d16ef56/mobile/test/shared/widgets/native_route_controls_test.dart):
glass controls stay mounted, with the same channels, under a dialog and
keep receiving appearance updates, while only the create control
unmounts and returns; glass controls stay mounted with no platform-view
churn across a modal bottom sheet; the `bottomUp=false` composition case
keeps the glass views; the hook rebuilds its host a small constant
number of times across a full push and pop.
-
[adaptive_conversation_pane_test.dart](fb0d16ef56/mobile/test/shared/widgets/adaptive_conversation_pane_test.dart):
in the wide layout, the covered chat has moved left 150 ms into a thread
push on iOS.

Signed-off-by: Tom Brow <tomb@block.xyz>
Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost>
2026-11-19 18:09:17 +00:00

30 lines
1.2 KiB
Dart

import 'bottom_up_page_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
/// Keeps native controls mounted for opaque sheets and their own exit motion.
/// Other covering Flutter routes suppress them to avoid platform-view bleed.
/// Used by Home's native-controls gate, the Channels route-currency sync and
/// `IosMessageCreateButton`. Rebuilds only when the visibility inputs change,
/// not on every animation frame. Must be called unconditionally from a hook
/// widget's build method.
bool useNativeRouteControlsVisible(BuildContext context) {
final route = ModalRoute.of(context);
final uncovered = useListenableSelector(
route?.secondaryAnimation,
() => (route?.secondaryAnimation?.value ?? 0) == 0,
);
final reversing = useListenableSelector(
route?.animation,
() => route?.animation?.status == AnimationStatus.reverse,
);
final sheets = route == null ? null : BottomUpPageRoute.sheetsAbove(route);
useListenable(sheets);
if ((sheets?.value ?? 0) > 0) {
return true;
}
final exiting = route != null && !route.isActive && reversing;
return ((route?.isCurrent ?? true) || exiting) && uncovered;
}