Skip to content

Commit 5aa8b87

Browse files
committed
poll: Enlarge and vetically center vote count box
Previously, there were only bottom and end paddings; we redistribute the vertical paddings so the vote count box is padded on both sides. The end padding remains 5px because we want to keep the options aligned to the start with the surrounding messages. This change also affects the poll question, where 2.5px of space gets moved to the first option row. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 7165307 commit 5aa8b87

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

lib/widgets/poll.dart

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class _PollWidgetState extends State<PollWidget> {
4646

4747
@override
4848
Widget build(BuildContext context) {
49+
const verticalPadding = 2.5;
50+
4951
final zulipLocalizations = ZulipLocalizations.of(context);
5052
final theme = ContentTheme.of(context);
5153
final store = PerAccountStoreWidget.of(context);
@@ -73,10 +75,10 @@ class _PollWidgetState extends State<PollWidget> {
7375
textBaseline: localizedTextBaseline(context),
7476
children: [
7577
ConstrainedBox(
76-
constraints: const BoxConstraints(
77-
minWidth: 25 + 5, minHeight: 25 + 5),
78+
constraints: const BoxConstraints(minWidth: 44, minHeight: 44),
7879
child: Padding(
79-
padding: const EdgeInsetsDirectional.only(bottom: 5, end: 5),
80+
padding: const EdgeInsetsDirectional.only(
81+
end: 5, top: verticalPadding, bottom: verticalPadding),
8082
child: Container(
8183
// Inner padding preserves whitespace even when the text's
8284
// width approaches the button's min-width (e.g. because
@@ -89,7 +91,7 @@ class _PollWidgetState extends State<PollWidget> {
8991
child: Center(
9092
child: Text(option.voters.length.toString(),
9193
style: textStyleBold.copyWith(
92-
color: theme.colorPollVoteCountText, fontSize: 13)))))),
94+
color: theme.colorPollVoteCountText, fontSize: 20)))))),
9395
Expanded(
9496
child: Wrap(
9597
spacing: 5,
@@ -105,10 +107,17 @@ class _PollWidgetState extends State<PollWidget> {
105107
return Column(
106108
crossAxisAlignment: CrossAxisAlignment.start,
107109
children: [
108-
Padding(padding: const EdgeInsets.only(bottom: 6), child: question),
110+
Padding(
111+
// `verticalPadding` out of 6 logical pixels come from the first
112+
// option row.
113+
padding: const EdgeInsets.only(bottom: 6 - verticalPadding),
114+
child: question),
109115
if (widget.poll.options.isEmpty)
110-
Text(zulipLocalizations.pollWidgetOptionsMissing,
111-
style: textStyleVoterNames.copyWith(fontStyle: FontStyle.italic)),
116+
Padding(
117+
// This is consistent with the option items' top padding.
118+
padding: const EdgeInsets.only(top: verticalPadding),
119+
child: Text(zulipLocalizations.pollWidgetOptionsMissing,
120+
style: textStyleVoterNames.copyWith(fontStyle: FontStyle.italic))),
112121
for (final option in widget.poll.options)
113122
buildOptionItem(option),
114123
]);

0 commit comments

Comments
 (0)