Expose pane actions in chat list menu

Share the open chat pane menu choices with session rows so list actions use the same handlers and target the selected chat. Add command routing, pane movement support, and focused coverage for wide and narrow layouts.
This commit is contained in:
2026-11-12 01:17:46 +00:00
parent 4f1b45571f
commit 3ce7f7a5dd
21 changed files with 1000 additions and 20 deletions
+15 -3
View File
@@ -7,6 +7,7 @@ class AppMenuAction<T> {
required this.label,
this.key,
this.destructive = false,
this.enabled = true,
});
final T value;
@@ -15,6 +16,9 @@ class AppMenuAction<T> {
/// Placed on the menu item so tests can find the same item.
final Key? key;
/// A disabled item stays listed but cannot be chosen.
final bool enabled;
// Kept for callers that distinguish destructive actions in their data model;
// Material PopupMenuItem does not apply a separate action-sheet treatment.
final bool destructive;
@@ -28,7 +32,8 @@ class AppMenuAction<T> {
class AppOverflowMenu<T> extends StatelessWidget {
const AppOverflowMenu({
super.key,
required this.actions,
this.actions = const [],
this.actionsBuilder,
required this.onSelected,
this.label = 'More actions',
this.sheetTitle,
@@ -38,6 +43,10 @@ class AppOverflowMenu<T> extends StatelessWidget {
final List<AppMenuAction<T>> actions;
/// When given, supplies the choices each time the menu opens, instead of
/// [actions]; for choices that depend on state read at that moment.
final List<AppMenuAction<T>> Function()? actionsBuilder;
/// Called with the picked value once the menu has closed.
final void Function(BuildContext context, T value) onSelected;
@@ -55,7 +64,9 @@ class AppOverflowMenu<T> extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (actions.isEmpty) return const SizedBox.shrink();
if (actionsBuilder == null && actions.isEmpty) {
return const SizedBox.shrink();
}
return Localizations.override(
context: context,
delegates: const [DefaultMaterialLocalizations.delegate],
@@ -67,10 +78,11 @@ class AppOverflowMenu<T> extends StatelessWidget {
enabled: enabled,
onSelected: (value) => onSelected(context, value),
itemBuilder: (_) => [
for (final action in actions)
for (final action in actionsBuilder?.call() ?? actions)
PopupMenuItem<T>(
key: action.key,
value: action.value,
enabled: action.enabled,
child: Text(action.label),
),
],