Skip to content

Commit 540e019

Browse files
committed
action_sheet [nfc]: Support multiple button sections in context menu
Some context menus in the Figma have multiple groups/sections of buttons, e.g.: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=6327-96694&m=dev
1 parent 648ab7f commit 540e019

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/widgets/action_sheet.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import 'topic_list.dart';
4141
void _showContextMenu(
4242
BuildContext pageContext, {
4343
Widget? header,
44-
required List<Widget> buttons,
44+
required List<List<Widget>> buttonSections,
4545
}) {
4646
// Could omit this if we need _showActionSheet outside a per-account context.
4747
final accountId = PerAccountStoreWidget.accountIdOf(pageContext);
@@ -95,7 +95,11 @@ void _showContextMenu(
9595
color: designVariables.bgContextMenu,
9696
child: SingleChildScrollView(
9797
padding: const EdgeInsets.symmetric(vertical: 8),
98-
child: MenuButtonsShape(buttons: buttons)))),
98+
child: Column(
99+
mainAxisSize: MainAxisSize.min,
100+
spacing: 8,
101+
children: buttonSections.map((buttons) =>
102+
MenuButtonsShape(buttons: buttons)).toList())))),
99103
const BottomSheetDismissButton(style: BottomSheetDismissButtonStyle.cancel),
100104
]))),
101105
]))));
@@ -259,7 +263,7 @@ void showChannelActionSheet(BuildContext context, {
259263
buttons.add(
260264
CopyChannelLinkButton(channelId: channelId, pageContext: pageContext));
261265

262-
_showContextMenu(pageContext, buttons: buttons);
266+
_showContextMenu(pageContext, buttonSections: [buttons]);
263267
}
264268

265269
class MarkChannelAsReadButton extends ContextMenuItemButton {
@@ -444,7 +448,7 @@ void showTopicActionSheet(BuildContext context, {
444448
narrow: TopicNarrow(channelId, topic, with_: someMessageIdInTopic),
445449
pageContext: context));
446450

447-
_showContextMenu(pageContext, buttons: buttons);
451+
_showContextMenu(pageContext, buttonSections: [buttons]);
448452
}
449453

450454
class UserTopicUpdateButton extends ContextMenuItemButton {
@@ -736,7 +740,7 @@ void showMessageActionSheet({required BuildContext context, required Message mes
736740
];
737741

738742
_showContextMenu(pageContext,
739-
buttons: buttons,
743+
buttonSections: [buttons],
740744
header: _MessageActionSheetHeader(message: message));
741745
}
742746

0 commit comments

Comments
 (0)