diff --git a/lib/common/widgets/extra_hit_test_widget.dart b/lib/common/widgets/extra_hit_test_widget.dart new file mode 100644 index 000000000..4227395a7 --- /dev/null +++ b/lib/common/widgets/extra_hit_test_widget.dart @@ -0,0 +1,31 @@ +import 'package:flutter/rendering.dart'; +import 'package:flutter/widgets.dart'; + +class ExtraHitTestWidget extends SingleChildRenderObjectWidget { + const ExtraHitTestWidget({ + super.key, + required this.width, + required Widget super.child, + }); + + final double width; + + @override + RenderObject createRenderObject(BuildContext context) { + return RenderExtraHitTestWidget(width: width); + } +} + +class RenderExtraHitTestWidget extends RenderProxyBox { + RenderExtraHitTestWidget({ + required double width, + }) : _width = width; + + final double _width; + + @override + bool hitTestChildren(BoxHitTestResult result, {required Offset position}) { + return super.hitTestChildren(result, position: position) || + position.dx <= _width; + } +} diff --git a/lib/models_new/live/live_superchat/item.dart b/lib/models_new/live/live_superchat/item.dart index 8ebb78a9c..689a047e0 100644 --- a/lib/models_new/live/live_superchat/item.dart +++ b/lib/models_new/live/live_superchat/item.dart @@ -53,7 +53,7 @@ class SuperChatItem { 'ts': 0, 'uinfo': { 'medal': { - "name": "MedalName", + "name": "Medal", "level": Utils.random.nextInt(40), "id": 123, "ruid": 456, diff --git a/lib/pages/dynamics/widgets/author_panel.dart b/lib/pages/dynamics/widgets/author_panel.dart index e30732f42..1aaee0143 100644 --- a/lib/pages/dynamics/widgets/author_panel.dart +++ b/lib/pages/dynamics/widgets/author_panel.dart @@ -3,6 +3,7 @@ import 'dart:math'; import 'package:PiliPlus/common/assets.dart'; import 'package:PiliPlus/common/style.dart'; import 'package:PiliPlus/common/widgets/dialog/report.dart'; +import 'package:PiliPlus/common/widgets/extra_hit_test_widget.dart'; import 'package:PiliPlus/common/widgets/pendant_avatar.dart'; import 'package:PiliPlus/http/constants.dart'; import 'package:PiliPlus/http/loading_state.dart'; @@ -98,37 +99,40 @@ class AuthorPanel extends StatelessWidget { Get.toNamed('/member?mid=${moduleAuthor.mid}'); } : null, - child: Row( - spacing: 10, - children: [ - PendantAvatar( - size: 40, - moduleAuthor.face, - pendantImage: moduleAuthor.pendant?.image, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - moduleAuthor.name!, - maxLines: 1, - overflow: .ellipsis, - style: TextStyle( - color: - moduleAuthor.vip != null && - moduleAuthor.vip!.status > 0 && - moduleAuthor.vip!.type == 2 - ? theme.colorScheme.vipColor - : theme.colorScheme.onSurface, - fontSize: theme.textTheme.titleSmall!.fontSize, - ), - ), - ?pubTs, - ], + child: ExtraHitTestWidget( + width: 50, + child: Row( + spacing: 10, + children: [ + PendantAvatar( + size: 40, + moduleAuthor.face, + pendantImage: moduleAuthor.pendant?.image, ), - ), - ], + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + moduleAuthor.name!, + maxLines: 1, + overflow: .ellipsis, + style: TextStyle( + color: + moduleAuthor.vip != null && + moduleAuthor.vip!.status > 0 && + moduleAuthor.vip!.type == 2 + ? theme.colorScheme.vipColor + : theme.colorScheme.onSurface, + fontSize: theme.textTheme.titleSmall!.fontSize, + ), + ), + ?pubTs, + ], + ), + ), + ], + ), ), ); Widget? moreBtn = isSave diff --git a/lib/pages/live_room/superchat/superchat_card.dart b/lib/pages/live_room/superchat/superchat_card.dart index c70ea0a29..697ab9a56 100644 --- a/lib/pages/live_room/superchat/superchat_card.dart +++ b/lib/pages/live_room/superchat/superchat_card.dart @@ -153,11 +153,11 @@ class _SuperChatCardState extends State { name = Row( spacing: 5, children: [ - Flexible(child: name), MedalWidget.fromMedalInfo( medal: medal, padding: MedalWidget.mediumPadding, ), + Flexible(child: name), ], ); } catch (e, s) { diff --git a/lib/pages/video/reply/widgets/reply_item_grpc.dart b/lib/pages/video/reply/widgets/reply_item_grpc.dart index dcaf39419..da4ec25a4 100644 --- a/lib/pages/video/reply/widgets/reply_item_grpc.dart +++ b/lib/pages/video/reply/widgets/reply_item_grpc.dart @@ -5,6 +5,7 @@ import 'package:PiliPlus/common/constants.dart'; import 'package:PiliPlus/common/style.dart'; import 'package:PiliPlus/common/widgets/badge.dart'; import 'package:PiliPlus/common/widgets/dialog/report.dart'; +import 'package:PiliPlus/common/widgets/extra_hit_test_widget.dart'; import 'package:PiliPlus/common/widgets/flutter/text/text.dart' as custom_text; import 'package:PiliPlus/common/widgets/gesture/tap_gesture_recognizer.dart'; import 'package:PiliPlus/common/widgets/image/network_img_layer.dart'; @@ -139,100 +140,108 @@ class ReplyItemGrpc extends StatelessWidget { feedBack(); Get.toNamed('/member?mid=${replyItem.mid}'); }, - child: Row( - crossAxisAlignment: .center, - spacing: 12, - children: [ - PendantAvatar( - member.face, - size: 34, - badgeSize: 14, - vipStatus: member.vipStatus.toInt(), - officialType: member.officialVerifyType.toInt(), - pendantImage: member.hasGarbPendantImage() - ? member.garbPendantImage - : null, - ), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Row( - spacing: 6, - children: [ - Flexible( - child: Text( - member.name, - maxLines: 1, - overflow: .ellipsis, - style: TextStyle( - color: (member.vipStatus > 0 && member.vipType == 2) - ? theme.colorScheme.vipColor - : theme.colorScheme.outline, - fontSize: 13, + child: ExtraHitTestWidget( + width: 46, + child: Row( + crossAxisAlignment: .center, + spacing: 12, + children: [ + PendantAvatar( + member.face, + size: 34, + badgeSize: 14, + vipStatus: member.vipStatus.toInt(), + officialType: member.officialVerifyType.toInt(), + pendantImage: member.hasGarbPendantImage() + ? member.garbPendantImage + : null, + ), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Row( + spacing: 6, + children: [ + Flexible( + child: Text( + member.name, + maxLines: 1, + overflow: .ellipsis, + style: TextStyle( + color: (member.vipStatus > 0 && member.vipType == 2) + ? theme.colorScheme.vipColor + : theme.colorScheme.outline, + fontSize: 13, + ), ), ), - ), - Image.asset( - Utils.levelName( - member.level, - isSeniorMember: member.isSeniorMember == 1, - ), - height: 11, - cacheHeight: 11.cacheSize(context), - ), - if (replyItem.mid == upMid) - const PBadge( - text: 'UP', - size: PBadgeSize.small, - isStack: false, - fontSize: 9, - ) - else if (GlobalData().showMedal && - member.hasFansMedalLevel()) - MedalWidget( - medalName: member.fansMedalName, - level: member.fansMedalLevel.toInt(), - backgroundColor: DmUtils.decimalToColor( - member.fansMedalColor.toInt(), + Image.asset( + Utils.levelName( + member.level, + isSeniorMember: member.isSeniorMember == 1, ), - nameColor: DmUtils.decimalToColor( - member.fansMedalColorName.toInt(), + height: 11, + cacheHeight: 11.cacheSize(context), + ), + if (replyItem.mid == upMid) + const PBadge( + text: 'UP', + size: PBadgeSize.small, + isStack: false, + fontSize: 9, + ) + else if (GlobalData().showMedal && + member.hasFansMedalLevel()) + MedalWidget( + medalName: member.fansMedalName, + level: member.fansMedalLevel.toInt(), + backgroundColor: DmUtils.decimalToColor( + member.fansMedalColor.toInt(), + ), + nameColor: DmUtils.decimalToColor( + member.fansMedalColorName.toInt(), + ), + padding: const .symmetric( + horizontal: 6, + vertical: 1.5, + ), ), - padding: const .symmetric(horizontal: 6, vertical: 1.5), - ), - ], - ), - Row( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - replyLevel == 0 - ? DateFormatUtils.format( - replyItem.ctime.toInt(), - format: DateFormatUtils.longFormatDs, - ) - : DateFormatUtils.dateFormat(replyItem.ctime.toInt()), - style: TextStyle( - fontSize: theme.textTheme.labelSmall!.fontSize, - color: theme.colorScheme.outline, - ), - ), - if (replyItem.replyControl.hasLocation()) + ], + ), + Row( + mainAxisSize: MainAxisSize.min, + children: [ Text( - ' • ${replyItem.replyControl.location}', + replyLevel == 0 + ? DateFormatUtils.format( + replyItem.ctime.toInt(), + format: DateFormatUtils.longFormatDs, + ) + : DateFormatUtils.dateFormat( + replyItem.ctime.toInt(), + ), style: TextStyle( fontSize: theme.textTheme.labelSmall!.fontSize, color: theme.colorScheme.outline, ), ), - ], - ), - ], + if (replyItem.replyControl.hasLocation()) + Text( + ' • ${replyItem.replyControl.location}', + style: TextStyle( + fontSize: theme.textTheme.labelSmall!.fontSize, + color: theme.colorScheme.outline, + ), + ), + ], + ), + ], + ), ), - ), - ], + ], + ), ), ); if (PendantAvatar.showDecorate) {