Show the phone terminal shortcut on the Chat tab only
This commit is contained in:
@@ -39,10 +39,17 @@ class AppTerminals {
|
|||||||
late final TerminalHub hub;
|
late final TerminalHub hub;
|
||||||
|
|
||||||
/// [shell] with the terminal panel, window or page around it.
|
/// [shell] with the terminal panel, window or page around it.
|
||||||
Widget surround(Widget shell, {required bool cupertino}) => TerminalSurface(
|
/// [onChat]: the phone shortcut that reopens the terminal shows on the
|
||||||
|
/// Chat tab only.
|
||||||
|
Widget surround(
|
||||||
|
Widget shell, {
|
||||||
|
required bool cupertino,
|
||||||
|
bool onChat = true,
|
||||||
|
}) => TerminalSurface(
|
||||||
hub: hub,
|
hub: hub,
|
||||||
layout: layout,
|
layout: layout,
|
||||||
cupertino: cupertino,
|
cupertino: cupertino,
|
||||||
|
shortcutHere: onChat,
|
||||||
child: shell,
|
child: shell,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -725,8 +725,11 @@ class _PipelinesAppState extends State<PipelinesApp>
|
|||||||
Widget _buildShell(BuildContext context, AppRoute route) =>
|
Widget _buildShell(BuildContext context, AppRoute route) =>
|
||||||
ValueListenableBuilder<int>(
|
ValueListenableBuilder<int>(
|
||||||
valueListenable: _attentionCount,
|
valueListenable: _attentionCount,
|
||||||
builder: (context, count, _) =>
|
builder: (context, count, _) => _terminals.surround(
|
||||||
_terminals.surround(_shellFor(route, count), cupertino: _cupertino),
|
_shellFor(route, count),
|
||||||
|
cupertino: _cupertino,
|
||||||
|
onChat: route.kind == AppRouteKind.chat,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
Widget _shellFor(AppRoute route, int attentionCount) {
|
Widget _shellFor(AppRoute route, int attentionCount) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class TerminalSurface extends StatefulWidget {
|
|||||||
required this.layout,
|
required this.layout,
|
||||||
required this.cupertino,
|
required this.cupertino,
|
||||||
required this.child,
|
required this.child,
|
||||||
|
this.shortcutHere = true,
|
||||||
});
|
});
|
||||||
|
|
||||||
final TerminalHub hub;
|
final TerminalHub hub;
|
||||||
@@ -39,6 +40,10 @@ class TerminalSurface extends StatefulWidget {
|
|||||||
final bool cupertino;
|
final bool cupertino;
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
|
/// Whether the current page offers the phone shortcut to reopen the
|
||||||
|
/// terminal (the app shows it on Chat only).
|
||||||
|
final bool shortcutHere;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<TerminalSurface> createState() => _TerminalSurfaceState();
|
State<TerminalSurface> createState() => _TerminalSurfaceState();
|
||||||
}
|
}
|
||||||
@@ -187,7 +192,7 @@ class _TerminalSurfaceState extends State<TerminalSurface>
|
|||||||
/// app below never remounts when the shortcut comes or goes.
|
/// app below never remounts when the shortcut comes or goes.
|
||||||
Widget _withShortcut(Widget child) {
|
Widget _withShortcut(Widget child) {
|
||||||
final running = widget.hub.tabs.where((tab) => tab.info.running).length;
|
final running = widget.hub.tabs.where((tab) => tab.info.running).length;
|
||||||
final show = _narrow && running > 0 && !_page.open;
|
final show = widget.shortcutHere && _narrow && running > 0 && !_page.open;
|
||||||
return Stack(
|
return Stack(
|
||||||
fit: StackFit.passthrough,
|
fit: StackFit.passthrough,
|
||||||
children: [
|
children: [
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ void main() {
|
|||||||
Future<void> pumpApp(
|
Future<void> pumpApp(
|
||||||
WidgetTester tester, {
|
WidgetTester tester, {
|
||||||
Size size = const Size(1200, 800),
|
Size size = const Size(1200, 800),
|
||||||
|
bool onChat = true,
|
||||||
}) async {
|
}) async {
|
||||||
tester.view.physicalSize = size;
|
tester.view.physicalSize = size;
|
||||||
tester.view.devicePixelRatio = 1;
|
tester.view.devicePixelRatio = 1;
|
||||||
@@ -46,6 +47,7 @@ void main() {
|
|||||||
hub: hub,
|
hub: hub,
|
||||||
layout: layout,
|
layout: layout,
|
||||||
cupertino: false,
|
cupertino: false,
|
||||||
|
shortcutHere: onChat,
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('App'),
|
title: const Text('App'),
|
||||||
@@ -289,6 +291,22 @@ void main() {
|
|||||||
expect(bubble, findsNothing);
|
expect(bubble, findsNothing);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
desktopTestWidgets('the phone shortcut shows on the Chat tab only', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await pumpApp(tester, size: const Size(390, 800), onChat: false);
|
||||||
|
final bubble = find.byKey(const Key('terminal-shortcut-bubble'));
|
||||||
|
await tester.tap(find.byTooltip(TerminalToggleButton.label));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
await tester.pageBack();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(hub.tabs, isNotEmpty);
|
||||||
|
expect(bubble, findsNothing, reason: 'not on Pipelines, Runs or Search');
|
||||||
|
await pumpApp(tester, size: const Size(390, 800));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(bubble, findsOneWidget, reason: 'shown on Chat');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Hardware keys reach the terminal on desktop; phones type through the
|
/// Hardware keys reach the terminal on desktop; phones type through the
|
||||||
|
|||||||
Reference in New Issue
Block a user