3be07064f9
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.
53 lines
1.4 KiB
Dart
53 lines
1.4 KiB
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(Icons.terminal, size: 20);
|
|
final content = running > 1
|
|
? Badge.count(count: running, child: icon)
|
|
: icon;
|
|
final button = 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,
|
|
);
|
|
}
|
|
}
|