Files
pipelines/app/lib/features/terminal/terminal_toggle_button.dart
T

50 lines
1.3 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'terminal_layout.dart';
import 'terminal_scope.dart';
/// The shell bar's Terminal button: shows or hides the terminal (Ctrl+`).
class TerminalToggleButton extends StatelessWidget {
const TerminalToggleButton({
super.key,
required this.layout,
required this.cupertino,
});
final TerminalLayout layout;
final bool cupertino;
static const String label = 'Terminal (Ctrl+`)';
@override
Widget build(BuildContext context) {
final actions = TerminalScope.maybeOf(context);
if (actions == null) return const SizedBox.shrink();
return ListenableBuilder(
listenable: layout,
builder: (context, _) {
final shown = layout.visible;
if (cupertino) {
return CupertinoButton(
key: const ValueKey('shell.terminal'),
padding: EdgeInsets.zero,
onPressed: actions.toggle,
child: Icon(
CupertinoIcons.chevron_left_slash_chevron_right,
semanticLabel: label,
),
);
}
return IconButton(
key: const ValueKey('shell.terminal'),
tooltip: label,
isSelected: shown,
onPressed: actions.toggle,
icon: const Icon(Icons.terminal),
);
},
);
}
}