@@ -5,9 +5,10 @@ import 'package:flutter_chat_core/flutter_chat_core.dart';
55import 'package:flutter_chat_ui/flutter_chat_ui.dart'
66 show ChatProviders, buildMessageContent;
77import 'package:provider/provider.dart' ;
8+ import 'package:pull_down_button/pull_down_button.dart'
9+ show PullDownMenuEntry, PullDownMenu;
810
911import '../models/default_data.dart' ;
10- import '../models/menu_item.dart' ;
1112import '../utils/typedef.dart' ;
1213
1314//// Theme values for [ReactionsDialogWidget] .
@@ -55,7 +56,7 @@ class ReactionsDialogWidget extends StatefulWidget {
5556 final VoidCallback ? onMoreReactionsTap;
5657
5758 /// The list of menu items to be displayed in the context menu
58- final List <MenuItem >? menuItems;
59+ final List <PullDownMenuEntry >? menuItems;
5960
6061 /// The list of default reactions to be displayed
6162 final List <String >? reactions;
@@ -125,94 +126,10 @@ class _ReactionsDialogWidgetState extends State<ReactionsDialogWidget> {
125126 buildReactionsPicker (context, theme),
126127 const SizedBox (height: 10 ),
127128 widget.messageWidget,
128- const SizedBox (height: 10 ),
129- buildMenuItems (context, theme),
130- ],
131- ),
132- ),
133- );
134- }
135-
136- Widget buildMenuItems (BuildContext context, _LocalTheme theme) {
137- final destructiveColor = widget.menuItemDestructiveColor ?? Colors .red;
138- return Material (
139- color: Colors .transparent,
140- child: Container (
141- /// TODO: maybe use pixels, for desktop?
142- width:
143- MediaQuery .of (context).size.width *
144- (widget.menuItemsWidthRatio ?? 0.45 ),
145- decoration: BoxDecoration (
146- color: widget.menuItemBackgroundColor ?? theme.surfaceContainer,
147- borderRadius: theme.shape,
148- ),
149- child: Column (
150- mainAxisAlignment: MainAxisAlignment .spaceEvenly,
151- mainAxisSize: MainAxisSize .min,
152- children: [
153- for (var item in widget.menuItems ?? const [])
154- Column (
155- children: [
156- Padding (
157- padding: const EdgeInsets .all (8 ),
158- child: InkWell (
159- onTap: () {
160- setState (() {
161- clickedContextMenuIndex = widget.menuItems? .indexOf (
162- item,
163- );
164- });
165-
166- Future .delayed (
167- widget.menuItemTapAnimationDuration ??
168- const Duration (milliseconds: 200 ),
169- ).whenComplete (() {
170- if (context.mounted) {
171- Navigator .of (context).pop ();
172- }
173- item.onTap? .call ();
174- });
175- },
176- child: Row (
177- mainAxisAlignment: MainAxisAlignment .spaceBetween,
178- children: [
179- Text (
180- item.title,
181- style: TextStyle (
182- color:
183- item.isDestructive
184- ? destructiveColor
185- : theme.onSurface,
186- ),
187- ),
188- Pulse (
189- infinite: false ,
190- duration:
191- widget.menuItemTapAnimationDuration ??
192- const Duration (milliseconds: 200 ),
193- animate:
194- clickedContextMenuIndex ==
195- widget.menuItems? .indexOf (item),
196- child: Icon (
197- item.icon,
198- color:
199- item.isDestructive
200- ? destructiveColor
201- : theme.onSurface,
202- ),
203- ),
204- ],
205- ),
206- ),
207- ),
208- if (widget.menuItems? .last != item)
209- Divider (
210- color: widget.menuItemDividerColor ?? Colors .white,
211- thickness: 0.5 ,
212- height: 0.5 ,
213- ),
214- ],
215- ),
129+ if (widget.menuItems != null && widget.menuItems! .isNotEmpty) ...[
130+ const SizedBox (height: 10 ),
131+ PullDownMenu (items: widget.menuItems! ),
132+ ],
216133 ],
217134 ),
218135 ),
@@ -333,7 +250,7 @@ void showReactionsDialog(
333250 required bool isSentByMe,
334251 required Function (String ) onReactionTap,
335252 VoidCallback ? onMoreReactionsTap,
336- List <MenuItem >? menuItems,
253+ List <PullDownMenuEntry >? menuItems,
337254 List <String >? reactions,
338255 List <String >? userReactions,
339256 CrossAxisAlignment ? widgetAlignment,
0 commit comments