87519985bf
The shortcut no longer waits for a running shell: on the Chat page it opens the terminal, starting one at its login prompt when none is open, and shows a count when more than one shell runs.
68 lines
1.9 KiB
Dart
68 lines
1.9 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
|
|
/// opens the full-screen terminal. 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, $running running'
|
|
: 'Open terminal';
|
|
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,
|
|
);
|
|
}
|
|
}
|