Skip to content

Commit 1d0159a

Browse files
committed
button [nfc]: Have ZulipWebUiKitButton support an icon
For muted-users, coming up. This is consistent with the ad hoc design for muted-users, but also consistent with the component in "Zulip Web UI Kit". (Modulo the TODO for changing icon-to-label gap from 8px to 6px; that's tricky with the Material widget we're working with.)
1 parent 7f731e4 commit 1d0159a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/widgets/button.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ class ZulipWebUiKitButton extends StatelessWidget {
2020
this.intent = ZulipWebUiKitButtonIntent.info,
2121
this.size = ZulipWebUiKitButtonSize.normal,
2222
required this.label,
23+
this.icon,
2324
required this.onPressed,
2425
});
2526

2627
final ZulipWebUiKitButtonAttention attention;
2728
final ZulipWebUiKitButtonIntent intent;
2829
final ZulipWebUiKitButtonSize size;
2930
final String label;
31+
final IconData? icon;
3032
final VoidCallback onPressed;
3133

3234
WidgetStateColor _backgroundColor(DesignVariables designVariables) {
@@ -118,16 +120,22 @@ class ZulipWebUiKitButton extends StatelessWidget {
118120

119121
final buttonHeight = _forSize(24, 28);
120122

123+
final labelColor = _labelColor(designVariables);
124+
121125
return AnimatedScaleOnTap(
122126
scaleEnd: 0.96,
123127
duration: Duration(milliseconds: 100),
124-
child: TextButton(
128+
child: TextButton.icon(
129+
// TODO the gap between the icon and label should be 6px, not 8px
130+
icon: icon != null ? Icon(icon) : null,
125131
style: TextButton.styleFrom(
132+
iconSize: 16,
133+
iconColor: labelColor,
126134
padding: EdgeInsets.symmetric(
127135
horizontal: _forSize(6, 10),
128136
vertical: 4 - densityVerticalAdjustment,
129137
),
130-
foregroundColor: _labelColor(designVariables),
138+
foregroundColor: labelColor,
131139
shape: RoundedRectangleBorder(
132140
side: _borderSide(designVariables),
133141
borderRadius: BorderRadius.circular(_forSize(6, 4))),
@@ -144,7 +152,7 @@ class ZulipWebUiKitButton extends StatelessWidget {
144152
),
145153
).copyWith(backgroundColor: _backgroundColor(designVariables)),
146154
onPressed: onPressed,
147-
child: ConstrainedBox(
155+
label: ConstrainedBox(
148156
constraints: BoxConstraints(maxWidth: 240),
149157
child: Text(label,
150158
textScaler: textScaler,

0 commit comments

Comments
 (0)