Skip to content

Commit 4be28c1

Browse files
committed
button: Add ZulipMenuItemButton.subLabel
1 parent 8792876 commit 4be28c1

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

lib/widgets/button.dart

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,13 +290,15 @@ class ZulipMenuItemButton extends StatelessWidget {
290290
super.key,
291291
this.style = ZulipMenuItemButtonStyle.menu,
292292
required this.label,
293+
this.subLabel,
293294
required this.onPressed,
294295
this.icon,
295296
this.toggle,
296297
});
297298

298299
final ZulipMenuItemButtonStyle style;
299300
final String label;
301+
final TextSpan? subLabel;
300302
final VoidCallback onPressed;
301303
final IconData? icon;
302304

@@ -393,13 +395,29 @@ class ZulipMenuItemButton extends StatelessWidget {
393395
foregroundColor: _labelColor(designVariables),
394396
splashFactory: NoSplash.splashFactory,
395397
).copyWith(backgroundColor: _backgroundColor(designVariables)),
398+
overflowAxis: Axis.vertical,
396399
onPressed: onPressed,
397400
child: Padding(
398401
padding: const EdgeInsets.symmetric(vertical: 4),
399-
// TODO sublabel, for [ZulipMenuItemButtonStyle.list]
400-
child: Text(label,
401-
style: const TextStyle(fontSize: 20, height: 24 / 20)
402-
.merge(weightVariableTextStyle(context, wght: _labelWght())))));
402+
child: Row(
403+
spacing: 8,
404+
crossAxisAlignment: CrossAxisAlignment.baseline,
405+
textBaseline: localizedTextBaseline(context),
406+
children: [
407+
Flexible(child: Text(label,
408+
overflow: TextOverflow.ellipsis,
409+
style: const TextStyle(fontSize: 20, height: 24 / 20)
410+
.merge(weightVariableTextStyle(context, wght: _labelWght())))),
411+
if (subLabel != null)
412+
Flexible(child: Text.rich(subLabel!,
413+
overflow: TextOverflow.ellipsis,
414+
style: TextStyle(
415+
fontSize: 16,
416+
height: 16 / 16,
417+
color: _labelColor(designVariables).withFadedAlpha(0.70),
418+
).merge(weightVariableTextStyle(context, wght: _labelWght())))),
419+
],
420+
)));
403421
}
404422
}
405423

0 commit comments

Comments
 (0)