Files
pipelines/app/lib/features/terminal/terminal_page.dart
T
alan 3be07064f9 Remove Cupertino terminal branches
Keep the Material-only terminal implementation while preserving public Cupertino parameters for callers. This removes unreachable Cupertino widgets and imports without changing the Material path.
2026-11-11 03:58:24 +00:00

100 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import 'terminal_body.dart';
import 'terminal_hub.dart';
import 'terminal_layout.dart';
import 'terminal_tab_strip.dart';
/// The terminals full screen (a narrow window has no room for a panel or a
/// window), with the touch key toolbar. The shells keep running when it is
/// closed; the route's own transition animates it and returns focus to
/// whatever had it.
PageRoute<void> terminalPageRoute({
required TerminalHub hub,
required TerminalLayout layout,
required bool cupertino,
}) {
Widget page(BuildContext _) =>
TerminalPage(hub: hub, layout: layout, cupertino: cupertino);
return MaterialPageRoute<void>(builder: page);
}
/// The full-screen terminal page of a narrow window, opened and closed by
/// the terminal's toggle.
class TerminalPageToggle {
PageRoute<void>? _route;
bool get open => _route != null;
/// Pushes the page on [context]'s navigator unless it is open; resolves
/// when it closes.
Future<void> show(
BuildContext context, {
required TerminalHub hub,
required TerminalLayout layout,
required bool cupertino,
}) async {
if (_route != null) return;
final route = _route = terminalPageRoute(
hub: hub,
layout: layout,
cupertino: cupertino,
);
try {
await Navigator.of(context).push(route);
} finally {
if (identical(_route, route)) _route = null;
}
}
/// Closes the page, also from under a route above it.
void close() {
final route = _route;
_route = null;
if (route == null) return;
route.isCurrent
? route.navigator?.pop()
: route.navigator?.removeRoute(route);
}
}
class TerminalPage extends StatelessWidget {
const TerminalPage({
super.key,
required this.hub,
required this.layout,
required this.cupertino,
});
final TerminalHub hub;
final TerminalLayout layout;
final bool cupertino;
@override
Widget build(BuildContext context) {
final body = ListenableBuilder(
listenable: hub,
builder: (context, _) => SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TerminalTabStrip(
hub: hub,
layout: layout,
cupertino: cupertino,
showModes: false,
),
Expanded(
child: TerminalBody(hub: hub, cupertino: cupertino, keys: true),
),
],
),
),
);
return Scaffold(
appBar: AppBar(title: const Text('Terminal')),
body: body,
);
}
}