Skip to content

Commit ceca4ce

Browse files
committed
poll [nfc]: Move vote count paddings inside children of Row
It makes it easier to adjust the size of the vote count box touch target later. This preserves the visuals. In particular, we add bottom paddings to both the vote count box and the option/voters text to ensure that there is always 5px between option rows, as it was before. The end padding is equivalent to the spacing previously specified on the Row; the bottom padding is equivalent to the padding specified on the outer (now removed) Padding. The ConstrainedBox is expanded because it now also contains the paddings. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 255aed0 commit ceca4ce

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

lib/widgets/poll.dart

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ class _PollWidgetState extends State<PollWidget> {
6868
store.users[userId]?.fullName ?? zulipLocalizations.unknownUserName)
6969
.join(', ');
7070

71-
return Padding(
72-
padding: const EdgeInsets.only(bottom: 5),
73-
child: Row(
74-
spacing: 5,
75-
crossAxisAlignment: CrossAxisAlignment.baseline,
76-
textBaseline: localizedTextBaseline(context),
77-
children: [
78-
ConstrainedBox(
79-
constraints: const BoxConstraints(minWidth: 25, minHeight: 25),
71+
return Row(
72+
crossAxisAlignment: CrossAxisAlignment.baseline,
73+
textBaseline: localizedTextBaseline(context),
74+
children: [
75+
ConstrainedBox(
76+
constraints: const BoxConstraints(
77+
minWidth: 25 + 5, minHeight: 25 + 5),
78+
child: Padding(
79+
padding: const EdgeInsetsDirectional.only(bottom: 5, end: 5),
8080
child: Container(
8181
// Inner padding preserves whitespace even when the text's
8282
// width approaches the button's min-width (e.g. because
@@ -89,26 +89,35 @@ class _PollWidgetState extends State<PollWidget> {
8989
child: Center(
9090
child: Text(option.voters.length.toString(),
9191
style: textStyleBold.copyWith(
92-
color: theme.colorPollVoteCountText, fontSize: 13))))),
93-
Expanded(
92+
color: theme.colorPollVoteCountText, fontSize: 13)))))),
93+
Expanded(
94+
child: Padding(
95+
// This and the bottom padding on the vote count box both extend
96+
// the row by the same extent. This ensures that there still will
97+
// be consistent spacing between rows when the text takes more
98+
// vertical space than the vote count box.
99+
padding: const EdgeInsets.only(bottom: 5),
94100
child: Wrap(
95101
spacing: 5,
96102
children: [
97103
Text(option.text, style: textStyleBold.copyWith(fontSize: 16)),
98104
if (option.voters.isNotEmpty)
99105
// TODO(i18n): Localize parenthesis characters.
100106
Text('($voterNames)', style: textStyleVoterNames),
101-
])),
102-
]));
107+
]))),
108+
]);
103109
}
104110

105111
return Column(
106112
crossAxisAlignment: CrossAxisAlignment.start,
107113
children: [
108114
Padding(padding: const EdgeInsets.only(bottom: 6), 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 rows' bottom padding.
118+
padding: const EdgeInsets.only(bottom: 5),
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)