Skip to content

Commit ddf25b7

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. The inner padding defined on the Container is affected by the size of the text. Document that fact as we make the green box and the text in it larger. Signed-off-by: Zixuan James Li <[email protected]>
1 parent dc0e039 commit ddf25b7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/widgets/poll.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class _PollWidgetState extends State<PollWidget> {
6060
style: textStyleBold.copyWith(fontSize: 18, fontStyle: FontStyle.italic));
6161

6262
Widget buildOptionItem(PollOption option) {
63+
const verticalPadding = 2.5;
6364
// TODO(i18n): List formatting, like you can do in JavaScript:
6465
// new Intl.ListFormat('ja').format(['Chris', 'Greg', 'Alya', 'Zixuan'])
6566
// // 'Chris、Greg、Alya、Zixuan'
@@ -73,10 +74,15 @@ class _PollWidgetState extends State<PollWidget> {
7374
textBaseline: localizedTextBaseline(context),
7475
children: [
7576
ConstrainedBox(
76-
constraints: const BoxConstraints(minWidth: 25 + 5).tighten(height: 25 + 5),
77+
constraints: const BoxConstraints(
78+
minWidth: 39 + 5).tighten(height: 39 + verticalPadding * 2),
7779
child: Padding(
78-
padding: const EdgeInsetsDirectional.only(bottom: 5, end: 5),
80+
padding: const EdgeInsetsDirectional.only(
81+
end: 5, top: verticalPadding, bottom: verticalPadding),
7982
child: Container(
83+
// Inner padding preserves whitespace even when the text's
84+
// width approaches the button's min-width (e.g. because
85+
// there are more than three digits).
8086
padding: const EdgeInsets.symmetric(horizontal: 4),
8187
decoration: BoxDecoration(
8288
color: theme.colorPollVoteCountBackground,
@@ -86,7 +92,7 @@ class _PollWidgetState extends State<PollWidget> {
8692
child: Text(option.voters.length.toString(),
8793
textAlign: TextAlign.center,
8894
style: textStyleBold.copyWith(
89-
color: theme.colorPollVoteCountText, fontSize: 13)))))),
95+
color: theme.colorPollVoteCountText, fontSize: 20)))))),
9096
Expanded(
9197
child: Wrap(
9298
spacing: 5,

0 commit comments

Comments
 (0)