Files
pipelines/app/lib/features/terminal/terminal_menu.dart
T
alan 214bbbc54f Remove Cupertino branches from terminal chat shell
Keep the existing Material terminal and chat-shell behavior while removing live Cupertino widgets, icon metadata, and alternate-host branches. Retain only the documented optional compatibility parameters until remaining callers migrate.
2026-11-11 20:05:55 +00:00

65 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
/// One choice of a [TerminalMenuButton].
class TerminalChoice<T> {
const TerminalChoice(this.value, this.label, {this.checked, this.key});
final T value;
final String label;
/// Non-null draws the choice as a checkable item.
final bool? checked;
final Key? key;
}
/// An icon button opening the host's menu.
class TerminalMenuButton<T> extends StatelessWidget {
const TerminalMenuButton({
super.key,
required this.label,
required this.icon,
required this.choices,
required this.onSelected,
this.info,
});
final String label;
final IconData icon;
final List<TerminalChoice<T>> choices;
final ValueChanged<T> onSelected;
/// A note under the choices (the terminal's shortcuts), not selectable.
final String? info;
@override
Widget build(BuildContext context) {
return PopupMenuButton<T>(
tooltip: label,
icon: Icon(icon),
onSelected: onSelected,
itemBuilder: (_) => [
for (final choice in choices)
choice.checked == null
? PopupMenuItem<T>(
key: choice.key,
value: choice.value,
child: Text(choice.label),
)
: CheckedPopupMenuItem<T>(
key: choice.key,
value: choice.value,
checked: choice.checked!,
child: Text(choice.label),
),
if (info case final info?) ...[
const PopupMenuDivider(),
PopupMenuItem<T>(
key: const ValueKey('terminal-menu-info'),
enabled: false,
child: Text(info),
),
],
],
);
}
}