reorganize and rename widgets

This commit is contained in:
Henry Hiles 2026-11-09 17:25:02 -05:00
commit d5f29dc344
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -0,0 +1,67 @@
import "package:material_ui/material_ui.dart";
class const PollOption(
final String text, {
required final bool picked,
required final bool isSingleChoice,
/// From 0 to 1
required final double share,
final bool isWinner = false,
final bool loading = false,
super.key,
}) extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
final emphasis = isWinner ? const TextStyle(fontWeight: .bold) : null;
return Column(
crossAxisAlignment: .stretch,
spacing: 10,
children: [
Row(
spacing: 12,
children: [
SizedBox.square(
dimension: 20,
child: loading
? const CircularProgressIndicator(strokeWidth: 2.5)
: Icon(
switch ((isSingleChoice, picked)) {
(true, true) => Icons.radio_button_checked,
(true, false) => Icons.radio_button_unchecked,
(false, true) => Icons.check_box,
(false, false) => Icons.check_box_outline_blank,
},
size: 20,
color: picked
? colorScheme.primary
: colorScheme.onSurfaceVariant,
),
),
Expanded(
child: Text(
text,
style: theme.textTheme.bodyLarge?.merge(emphasis),
),
),
Text(
"${(share * 100).round()}%",
style: theme.textTheme.labelLarge
?.copyWith(color: colorScheme.onSurfaceVariant)
.merge(emphasis),
),
],
),
TweenAnimationBuilder(
tween: Tween(end: share),
duration: Durations.medium2,
curve: Curves.easeInOut,
builder: (context, value, _) => LinearProgressIndicator(value: value),
),
],
);
}
}