fix(shell): keep the tab destination ready behind pushed pages
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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,7 +183,6 @@ 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) =>
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -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(detail: false));
|
await tester.pumpWidget(shell());
|
||||||
expect(find.byType(NavigationBar), findsOneWidget);
|
expect(find.byType(NavigationBar), findsOneWidget);
|
||||||
await tester.pumpWidget(shell(detail: true));
|
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
|
||||||
|
navigator.push(
|
||||||
|
MaterialPageRoute<void>(
|
||||||
|
builder: (_) => const Scaffold(body: Text('detail')),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
await tester.pumpAndSettle();
|
||||||
expect(find.byType(NavigationBar), findsNothing);
|
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);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user