mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: reply/like num
Closes #85 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:PiliPalaX/utils/extension.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
@@ -134,7 +135,7 @@ class _ZanButtonState extends State<ZanButton> {
|
||||
return ScaleTransition(scale: animation, child: child);
|
||||
},
|
||||
child: Text(
|
||||
widget.replyItem!.like.toString(),
|
||||
Utils.numFormat(widget.replyItem!.like),
|
||||
key: ValueKey<int>(widget.replyItem!.like!),
|
||||
style: TextStyle(
|
||||
color: widget.replyItem!.action == 1 ? primary : color,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:PiliPalaX/grpc/app/main/community/reply/v1/reply.pb.dart';
|
||||
import 'package:PiliPalaX/utils/extension.dart';
|
||||
import 'package:PiliPalaX/utils/utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
@@ -161,8 +162,7 @@ class _ZanButtonGrpcState extends State<ZanButtonGrpc> {
|
||||
return ScaleTransition(scale: animation, child: child);
|
||||
},
|
||||
child: Text(
|
||||
widget.replyItem.like.toString(),
|
||||
// key: ValueKey<int>(widget.replyItem!.like!),
|
||||
Utils.numFormat(widget.replyItem.like.toInt()),
|
||||
style: TextStyle(
|
||||
color: widget.replyItem.replyControl.action.toInt() == 1
|
||||
? primary
|
||||
|
||||
@@ -1236,7 +1236,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
|
||||
if (text == '评论') {
|
||||
return Tab(
|
||||
text:
|
||||
'评论${_videoReplyController.count.value == -1 ? '' : ' ${_videoReplyController.count.value}'}',
|
||||
'评论${_videoReplyController.count.value == -1 ? '' : ' ${Utils.numFormat(_videoReplyController.count.value)}'}',
|
||||
);
|
||||
} else {
|
||||
return Tab(text: text);
|
||||
|
||||
@@ -482,16 +482,21 @@ class Utils {
|
||||
return number;
|
||||
}
|
||||
}
|
||||
if (number >= 100000000) {
|
||||
return '${(number / 100000000).toStringAsFixed(1)}亿';
|
||||
} else if (number > 10000) {
|
||||
double result = number / 10000;
|
||||
|
||||
String format(first, second) {
|
||||
double result = number / first;
|
||||
String format = result.toStringAsFixed(1);
|
||||
if (format.endsWith('.0')) {
|
||||
return '${result.toInt()}万';
|
||||
return '${result.toInt()}$second';
|
||||
} else {
|
||||
return '$format万';
|
||||
return '$format$second';
|
||||
}
|
||||
}
|
||||
|
||||
if (number >= 100000000) {
|
||||
return format(100000000, '亿');
|
||||
} else if (number >= 10000) {
|
||||
return format(10000, '万');
|
||||
} else {
|
||||
return number.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user