Show awarded score

This commit is contained in:
2025-09-08 23:55:50 +08:00
parent 6c847ee1e1
commit c7f417234e
4 changed files with 51 additions and 18 deletions

View File

@@ -77,6 +77,22 @@ class PostActionButtons extends HookConsumerWidget {
final isAuthor =
user.value != null && user.value?.id == post.publisher.accountId;
String formatScore(int score) {
if (score >= 1000000) {
double value = score / 1000000;
return value % 1 == 0
? '${value.toInt()}m'
: '${value.toStringAsFixed(1)}m';
} else if (score >= 1000) {
double value = score / 1000;
return value % 1 == 0
? '${value.toInt()}k'
: '${value.toStringAsFixed(1)}k';
} else {
return score.toString();
}
}
final actions = <Widget>[];
const kButtonHeight = 40.0;
@@ -254,6 +270,17 @@ class PostActionButtons extends HookConsumerWidget {
),
];
actions.add(
FilledButton.tonalIcon(
onPressed: () {},
icon: const Icon(Symbols.star),
label:
post.awardedScore > 0
? Text('${formatScore(post.awardedScore)} pts')
: Text('award').tr(),
),
);
actions.add(
Row(
mainAxisSize: MainAxisSize.min,