@@ -289,12 +289,19 @@ class MenuButton extends StatelessWidget {
289
289
required this .label,
290
290
required this .onPressed,
291
291
this .icon,
292
+ this .toggle,
292
293
});
293
294
294
295
final String label;
295
296
final VoidCallback onPressed;
296
297
final IconData ? icon;
297
298
299
+ /// A [Toggle] to go before [icon] , or in its place if it's null.
300
+ ///
301
+ /// See Figma:
302
+ /// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=6070-60682&m=dev
303
+ final Widget ? toggle;
304
+
298
305
static double itemSpacing = 16 ;
299
306
300
307
static bool _debugCheckShapeAncestor (BuildContext context) {
@@ -319,26 +326,37 @@ class MenuButton extends StatelessWidget {
319
326
assert (Theme .of (context).visualDensity == VisualDensity .standard);
320
327
321
328
return MenuItemButton (
322
- trailingIcon: icon != null
329
+ trailingIcon: ( icon != null || toggle != null )
323
330
? Padding (
324
331
// This Material widget gives us 12px padding before the icon --
325
332
// or more or less, depending on Theme.of(context).visualDensity,
326
333
// hence the `assert` above.
327
334
padding: EdgeInsetsDirectional .only (start: itemSpacing - 12 ),
328
335
329
- child: Icon (icon, color: designVariables.contextMenuItemText))
336
+ child: Row (
337
+ mainAxisSize: MainAxisSize .min,
338
+ crossAxisAlignment: CrossAxisAlignment .center,
339
+ spacing: itemSpacing,
340
+ children: [
341
+ if (toggle != null ) toggle! ,
342
+ if (icon != null ) Icon (icon! , color: designVariables.contextMenuItemText),
343
+ ]))
330
344
: null ,
331
345
style: MenuItemButton .styleFrom (
332
- padding: const EdgeInsets .symmetric (vertical: 12 , horizontal: 16 ),
346
+ minimumSize: Size .fromHeight (48 ),
347
+ padding: const EdgeInsets .symmetric (horizontal: 16 ),
333
348
foregroundColor: designVariables.contextMenuItemText,
334
349
splashFactory: NoSplash .splashFactory,
335
350
).copyWith (backgroundColor: WidgetStateColor .resolveWith ((states) =>
336
351
designVariables.contextMenuItemBg.withFadedAlpha (
337
352
states.contains (WidgetState .pressed) ? 0.20 : 0.12 ))),
338
353
onPressed: onPressed,
339
- child: Text (label,
340
- style: const TextStyle (fontSize: 20 , height: 24 / 20 )
341
- .merge (weightVariableTextStyle (context, wght: 600 ))));
354
+ child: Padding (
355
+ padding: const EdgeInsets .symmetric (vertical: 4 ),
356
+ child: Text (label,
357
+ style: const TextStyle (fontSize: 20 , height: 24 / 20 )
358
+ .merge (weightVariableTextStyle (context, wght: 600 ))),
359
+ ));
342
360
}
343
361
}
344
362
0 commit comments