diff --git a/app/lib/application/pipelines_app.dart b/app/lib/application/pipelines_app.dart index 1c33021c..70a1aff8 100644 --- a/app/lib/application/pipelines_app.dart +++ b/app/lib/application/pipelines_app.dart @@ -446,10 +446,6 @@ class _PipelinesAppState extends State final chatRoute = tab(AppDestination.chat); return AdaptiveShell( attentionCount: attentionCount, - detailOpen: - route.runId != null || - route.chatSessionId != null || - (route.kind == AppRouteKind.pipelines && route.pipelineId != null), cupertino: _cupertino, destination: _destinationOf(route.kind), onDestinationSelected: _selectDestination, diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index 9c80322a..0851e56f 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -15,7 +15,6 @@ class AdaptiveShell extends StatefulWidget { this.onDestinationSelected, this.onSearch, this.attentionCount = 0, - this.detailOpen = false, }); final Map destinationBodies; @@ -34,10 +33,6 @@ class AdaptiveShell extends StatefulWidget { /// so it stays visible from any destination. Zero shows no badge. 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 State createState() => _AdaptiveShellState(); } @@ -188,19 +183,18 @@ class _AdaptiveShellState extends State { : Column( children: [ Expanded(child: _destinationStack(contents, index)), - if (!widget.detailOpen) - CupertinoTabBar( - currentIndex: index, - onTap: (value) => - _select(AppDestination.values[value]), - items: _items((destination) { - final item = destinationDetails(destination); - return BottomNavigationBarItem( - icon: _icon(destination, item.cupertinoIcon), - label: item.label, - ); - }), - ), + CupertinoTabBar( + currentIndex: index, + onTap: (value) => + _select(AppDestination.values[value]), + items: _items((destination) { + final item = destinationDetails(destination); + return BottomNavigationBarItem( + icon: _icon(destination, item.cupertinoIcon), + label: item.label, + ); + }), + ), ], ), ), @@ -256,7 +250,7 @@ class _AdaptiveShellState extends State { Expanded(child: _destinationStack(contents, index)), ], ), - bottomNavigationBar: wide || widget.detailOpen + bottomNavigationBar: wide ? null : NavigationBar( selectedIndex: index, diff --git a/app/test/shell/shell_bar_test.dart b/app/test/shell/shell_bar_test.dart index 329decdf..31479abe 100644 --- a/app/test/shell/shell_bar_test.dart +++ b/app/test/shell/shell_bar_test.dart @@ -100,22 +100,34 @@ void main() { ); }); - testWidgets('an open detail fills a phone screen without the tab bar', ( - tester, - ) async { - tester.view.physicalSize = const Size(390, 844); - tester.view.devicePixelRatio = 1; - addTearDown(tester.view.reset); - Widget shell({required bool detail}) => MaterialApp( - home: AdaptiveShell( - destination: AppDestination.runs, - detailOpen: detail, - destinationBodies: {AppDestination.runs: (_) => const Text('runs')}, - ), - ); - await tester.pumpWidget(shell(detail: false)); - expect(find.byType(NavigationBar), findsOneWidget); - await tester.pumpWidget(shell(detail: true)); - expect(find.byType(NavigationBar), findsNothing); - }); + testWidgets( + 'a pushed detail covers tabs without unmounting the Back destination', + (tester) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + Widget shell() => MaterialApp( + home: AdaptiveShell( + destination: AppDestination.runs, + destinationBodies: {AppDestination.runs: (_) => const Text('runs')}, + ), + ); + await tester.pumpWidget(shell()); + expect(find.byType(NavigationBar), findsOneWidget); + final navigator = tester.state(find.byType(Navigator)); + navigator.push( + MaterialPageRoute( + 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); + }, + ); }