fix(shell): keep the tab destination ready behind pushed pages

This commit is contained in:
2026-10-24 11:14:10 +01:00
parent 399d520c71
commit 877c2f1acd
3 changed files with 43 additions and 41 deletions
-4
View File
@@ -446,10 +446,6 @@ class _PipelinesAppState extends State<PipelinesApp>
final chatRoute = tab(AppDestination.chat); final chatRoute = tab(AppDestination.chat);
return AdaptiveShell( return AdaptiveShell(
attentionCount: attentionCount, attentionCount: attentionCount,
detailOpen:
route.runId != null ||
route.chatSessionId != null ||
(route.kind == AppRouteKind.pipelines && route.pipelineId != null),
cupertino: _cupertino, cupertino: _cupertino,
destination: _destinationOf(route.kind), destination: _destinationOf(route.kind),
onDestinationSelected: _selectDestination, onDestinationSelected: _selectDestination,
+13 -19
View File
@@ -15,7 +15,6 @@ class AdaptiveShell extends StatefulWidget {
this.onDestinationSelected, this.onDestinationSelected,
this.onSearch, this.onSearch,
this.attentionCount = 0, this.attentionCount = 0,
this.detailOpen = false,
}); });
final Map<AppDestination, WidgetBuilder> destinationBodies; final Map<AppDestination, WidgetBuilder> destinationBodies;
@@ -34,10 +33,6 @@ class AdaptiveShell extends StatefulWidget {
/// so it stays visible from any destination. Zero shows no badge. /// so it stays visible from any destination. Zero shows no badge.
final int attentionCount; final int attentionCount;
/// A pipeline, run or chat is open: on a phone it takes the whole screen,
/// like its own page, and the destination bar steps aside until Back.
final bool detailOpen;
@override @override
State<AdaptiveShell> createState() => _AdaptiveShellState(); State<AdaptiveShell> createState() => _AdaptiveShellState();
} }
@@ -188,19 +183,18 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
: Column( : Column(
children: [ children: [
Expanded(child: _destinationStack(contents, index)), Expanded(child: _destinationStack(contents, index)),
if (!widget.detailOpen) CupertinoTabBar(
CupertinoTabBar( currentIndex: index,
currentIndex: index, onTap: (value) =>
onTap: (value) => _select(AppDestination.values[value]),
_select(AppDestination.values[value]), items: _items((destination) {
items: _items((destination) { final item = destinationDetails(destination);
final item = destinationDetails(destination); return BottomNavigationBarItem(
return BottomNavigationBarItem( icon: _icon(destination, item.cupertinoIcon),
icon: _icon(destination, item.cupertinoIcon), label: item.label,
label: item.label, );
); }),
}), ),
),
], ],
), ),
), ),
@@ -256,7 +250,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
Expanded(child: _destinationStack(contents, index)), Expanded(child: _destinationStack(contents, index)),
], ],
), ),
bottomNavigationBar: wide || widget.detailOpen bottomNavigationBar: wide
? null ? null
: NavigationBar( : NavigationBar(
selectedIndex: index, selectedIndex: index,
+30 -18
View File
@@ -100,22 +100,34 @@ void main() {
); );
}); });
testWidgets('an open detail fills a phone screen without the tab bar', ( testWidgets(
tester, 'a pushed detail covers tabs without unmounting the Back destination',
) async { (tester) async {
tester.view.physicalSize = const Size(390, 844); tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1; tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset); addTearDown(tester.view.reset);
Widget shell({required bool detail}) => MaterialApp( Widget shell() => MaterialApp(
home: AdaptiveShell( home: AdaptiveShell(
destination: AppDestination.runs, destination: AppDestination.runs,
detailOpen: detail, destinationBodies: {AppDestination.runs: (_) => const Text('runs')},
destinationBodies: {AppDestination.runs: (_) => const Text('runs')}, ),
), );
); await tester.pumpWidget(shell());
await tester.pumpWidget(shell(detail: false)); expect(find.byType(NavigationBar), findsOneWidget);
expect(find.byType(NavigationBar), findsOneWidget); final navigator = tester.state<NavigatorState>(find.byType(Navigator));
await tester.pumpWidget(shell(detail: true)); navigator.push(
expect(find.byType(NavigationBar), findsNothing); MaterialPageRoute<void>(
}); builder: (_) => const Scaffold(body: Text('detail')),
),
);
await tester.pumpAndSettle();
expect(find.byType(NavigationBar), findsNothing);
expect(find.byType(NavigationBar, skipOffstage: false), findsOneWidget);
await navigator.maybePop();
await tester.pump(const Duration(milliseconds: 16));
expect(find.byType(NavigationBar), findsOneWidget);
await tester.pumpAndSettle();
expect(find.byType(NavigationBar), findsOneWidget);
},
);
} }