Files
pipelines/app/lib/features/terminal/terminal_shortcut_bubble.dart
T
alan 070f9e205e Show a terminal shortcut below the top bar on phones
While shells are running and the full-screen terminal is closed, a small
floating button under the right end of the top bar reopens it, with a count
when more than one shell runs. The surface's stack is always present so the
app never remounts when the shortcut comes or goes.
2026-11-10 00:23:53 +00:00

68 lines
2.0 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../ui/adaptive/segmented_bar_pieces.dart';
/// On a phone, a small floating button below the top bar's right end that
/// reopens the full-screen terminal while a shell is running there. It shows
/// how many shells are running when there is more than one.
class TerminalShortcutBubble extends StatelessWidget {
const TerminalShortcutBubble({
super.key,
required this.running,
required this.cupertino,
required this.onOpen,
});
final int running;
final bool cupertino;
final VoidCallback onOpen;
/// The top edge: below the safe area and the top bar (its 8 px top inset
/// and its pieces), with an 8 px gap.
static double topOf(BuildContext context, {required bool cupertino}) =>
MediaQuery.paddingOf(context).top +
8 +
segmentedPieceHeight(cupertino) +
8;
@override
Widget build(BuildContext context) {
final label = running == 1
? 'Open terminal'
: 'Open terminal, $running running';
final icon = Icon(
cupertino
? CupertinoIcons.chevron_left_slash_chevron_right
: Icons.terminal,
size: 20,
);
final content = running > 1
? Badge.count(count: running, child: icon)
: icon;
final button = cupertino
? CupertinoButton.tinted(
key: const Key('terminal-shortcut-bubble'),
sizeStyle: CupertinoButtonSize.small,
padding: const EdgeInsets.all(10),
borderRadius: BorderRadius.circular(22),
onPressed: onOpen,
child: content,
)
: FloatingActionButton.small(
key: const Key('terminal-shortcut-bubble'),
heroTag: null,
tooltip: label,
onPressed: onOpen,
child: content,
);
return Semantics(
button: true,
label: label,
excludeSemantics: true,
onTap: onOpen,
child: button,
);
}
}