Skip to content

Commit 05d75c4

Browse files
committed
wip; poll: Support vote/unvote for polls
Signed-off-by: Zixuan James Li <[email protected]>
1 parent 2cadc82 commit 05d75c4

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

lib/widgets/poll.dart

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,30 @@ class _PollWidgetState extends State<PollWidget> {
9292
crossAxisAlignment: CrossAxisAlignment.baseline,
9393
textBaseline: localizedTextBaseline(context),
9494
children: [
95-
ConstrainedBox(
96-
constraints: const BoxConstraints(minWidth: 44),
97-
child: Container(
98-
height: 44,
95+
OutlinedButton(
96+
style: OutlinedButton.styleFrom(
97+
minimumSize: const Size.square(44),
98+
// The default visual density is platform dependent.
99+
// For those whose density defaults to [VisualDensity.compact],
100+
// this button would be 8px smaller if we do not override it.
101+
//
102+
// See also:
103+
// * [ThemeData.visualDensity], which provides the default.
104+
visualDensity: VisualDensity.standard,
99105
// This padding is only in effect
100106
// when the vote count has more than one digit.
101107
padding: const EdgeInsets.symmetric(horizontal: 15),
102-
decoration: BoxDecoration(
103-
color: theme.colorPollVoteCountBackground,
104-
border: Border.all(color: theme.colorPollVoteCountBorder),
108+
shape: RoundedRectangleBorder(
105109
borderRadius: BorderRadius.circular(3)),
106-
child: Center(
107-
child: Text(option.voters.length.toString(),
108-
textAlign: TextAlign.center,
109-
style: textStyleBold.copyWith(
110-
color: theme.colorPollVoteCountText, fontSize: 16))))),
110+
backgroundColor: theme.colorPollVoteCountBackground,
111+
side: BorderSide(color: theme.colorPollVoteCountBorder),
112+
splashFactory: NoSplash.splashFactory,
113+
),
114+
onPressed: () => toggleVote(option),
115+
child: Text(option.voters.length.toString(),
116+
textAlign: TextAlign.center,
117+
style: textStyleBold.copyWith(fontSize: 16,
118+
color: theme.colorPollVoteCountText))),
111119
Expanded(
112120
child: Wrap(
113121
spacing: 5,

0 commit comments

Comments
 (0)