opt like btn

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-06-18 20:12:31 +08:00
parent 14aac2870d
commit ba1471a79a
3 changed files with 111 additions and 106 deletions

View File

@@ -304,64 +304,65 @@ class _PgcReviewChildPageState extends State<PgcReviewChildPage>
builder: (context) { builder: (context) {
final Color color = theme.colorScheme.outline; final Color color = theme.colorScheme.outline;
final Color primary = theme.colorScheme.primary; final Color primary = theme.colorScheme.primary;
final ButtonStyle style = TextButton.styleFrom(
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: VisualDensity.compact,
);
final isLike = item.stat?.liked == 1; final isLike = item.stat?.liked == 1;
late final isDislike = item.stat?.disliked == 1; late final isDislike = item.stat?.disliked == 1;
return Row( return Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: .end,
children: [ children: [
if (!isLongReview) if (!isLongReview)
SizedBox( TextButton(
height: 32, style: const ButtonStyle(
child: TextButton( visualDensity: .compact,
style: style, tapTargetSize: .shrinkWrap,
onPressed: () => _controller.onDislike( padding: WidgetStatePropertyAll(.zero),
item, minimumSize: WidgetStatePropertyAll(.square(40)),
isDislike, ),
item.reviewId, onPressed: () => _controller.onDislike(
), item,
child: Icon( isDislike,
isDislike item.reviewId,
? BiliIcons.ic_disliked ),
: BiliIcons.ic_dislike, child: Icon(
size: 16, isDislike
color: isDislike ? primary : color, ? BiliIcons.ic_disliked
), : BiliIcons.ic_dislike,
size: 16,
color: isDislike ? primary : color,
), ),
), ),
SizedBox( TextButton(
height: 32, style: const ButtonStyle(
child: TextButton( visualDensity: .compact,
style: style, tapTargetSize: .shrinkWrap,
onPressed: isLongReview minimumSize: WidgetStatePropertyAll(.square(40)),
? null padding: WidgetStatePropertyAll(
: () => _controller.onLike( .symmetric(horizontal: 8),
item,
isLike,
item.reviewId,
),
child: Row(
spacing: 4,
children: [
Icon(
isLike ? BiliIcons.ic_liked : BiliIcons.ic_like,
size: 16,
color: isLike ? primary : color,
),
Text(
NumUtils.numFormat(item.stat?.likes ?? 0),
style: TextStyle(
color: isLike ? primary : color,
fontSize: 12,
),
),
],
), ),
), ),
onPressed: isLongReview
? null
: () => _controller.onLike(
item,
isLike,
item.reviewId,
),
child: Row(
spacing: 4,
children: [
Icon(
isLike ? BiliIcons.ic_liked : BiliIcons.ic_like,
size: 16,
color: isLike ? primary : color,
),
Text(
NumUtils.numFormat(item.stat?.likes ?? 0),
style: TextStyle(
color: isLike ? primary : color,
fontSize: 12,
),
),
],
),
), ),
], ],
); );

View File

@@ -38,7 +38,12 @@ class ActionItem extends StatelessWidget {
Widget child = Icon( Widget child = Icon(
icon.icon, icon.icon,
size: icon.size ?? 20.5, size: icon.size ?? 20.5,
color: selectStatus ? primary : icon.color ?? colorScheme.outline, color: selectStatus
? primary
: icon.color ??
(colorScheme.isDark
? colorScheme.outline
: colorScheme.outline.withValues(alpha: .85)),
); );
if (animation != null) { if (animation != null) {

View File

@@ -106,70 +106,69 @@ class ZanButtonGrpc extends StatelessWidget {
final isDislike = action == $fixnum.Int64.TWO; final isDislike = action == $fixnum.Int64.TWO;
final outline = theme.colorScheme.outline; final outline = theme.colorScheme.outline;
final primary = theme.colorScheme.primary; final primary = theme.colorScheme.primary;
final ButtonStyle style = TextButton.styleFrom(
padding: EdgeInsets.zero,
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
visualDensity: VisualDensity.compact,
);
return Row( return Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: .min,
children: [ children: [
SizedBox( TextButton(
height: 32, style: const ButtonStyle(
child: TextButton( visualDensity: .compact,
style: style, tapTargetSize: .shrinkWrap,
onPressed: () => EasyThrottle.throttle( padding: WidgetStatePropertyAll(.zero),
'interactAction', minimumSize: WidgetStatePropertyAll(.square(40)),
const Duration(milliseconds: 200), ),
() => onHateReply( onPressed: () => EasyThrottle.throttle(
context, 'interactAction',
isProcessing, const Duration(milliseconds: 200),
() => isProcessing = false, () => onHateReply(
isLike: isLike, context,
isDislike: isDislike, isProcessing,
), () => isProcessing = false,
), isLike: isLike,
child: Icon( isDislike: isDislike,
isDislike ? BiliIcons.ic_disliked : BiliIcons.ic_dislike,
size: 16,
color: isDislike ? primary : outline,
semanticLabel: isDislike ? '已踩' : '点踩',
), ),
), ),
child: Icon(
isDislike ? BiliIcons.ic_disliked : BiliIcons.ic_dislike,
size: 16,
color: isDislike ? primary : outline,
semanticLabel: isDislike ? '已踩' : '点踩',
),
), ),
SizedBox( TextButton(
height: 32, style: const ButtonStyle(
child: TextButton( visualDensity: .compact,
style: style, tapTargetSize: .shrinkWrap,
onPressed: () => EasyThrottle.throttle( minimumSize: WidgetStatePropertyAll(.square(40)),
'interactAction', padding: WidgetStatePropertyAll(.symmetric(horizontal: 8)),
const Duration(milliseconds: 200), ),
() => onLikeReply( onPressed: () => EasyThrottle.throttle(
context, 'interactAction',
isProcessing, const Duration(milliseconds: 200),
() => isProcessing = false, () => onLikeReply(
isLike: isLike, context,
isDislike: isDislike, isProcessing,
() => isProcessing = false,
isLike: isLike,
isDislike: isDislike,
),
),
child: Row(
spacing: 4,
children: [
Icon(
isLike ? BiliIcons.ic_liked : BiliIcons.ic_like,
size: 16,
color: isLike ? primary : outline,
semanticLabel: isLike ? '已赞' : '点赞',
), ),
), Text(
child: Row( NumUtils.numFormat(replyItem.like.toInt()),
spacing: 4, style: TextStyle(
children: [
Icon(
isLike ? BiliIcons.ic_liked : BiliIcons.ic_like,
size: 16,
color: isLike ? primary : outline, color: isLike ? primary : outline,
semanticLabel: isLike ? '已赞' : '点赞', fontSize: theme.textTheme.labelSmall!.fontSize,
), ),
Text( ),
NumUtils.numFormat(replyItem.like.toInt()), ],
style: TextStyle(
color: isLike ? primary : outline,
fontSize: theme.textTheme.labelSmall!.fontSize,
),
),
],
),
), ),
), ),
], ],