opt reply item

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-06-21 22:07:58 +08:00
parent 07b7c42f13
commit a1555826c3

View File

@@ -319,10 +319,10 @@ class ReplyItemGrpc extends StatelessWidget {
if (replyLevel != 0) if (replyLevel != 0)
buttonAction(context, theme, replyItem.replyControl), buttonAction(context, theme, replyItem.replyControl),
// 一楼的评论 // 一楼的评论
if (replyLevel == 1 && replyItem.replies.isNotEmpty) ...[ if (replyLevel == 1 && replyItem.count > Int64.ZERO) ...[
Padding( Padding(
padding: const EdgeInsets.only(top: 5, bottom: 12), padding: const EdgeInsets.only(top: 5, bottom: 12),
child: replyItemRow(context, theme), child: replyItemRow(context, theme, replyItem.replies),
), ),
], ],
], ],
@@ -418,8 +418,10 @@ class ReplyItemGrpc extends StatelessWidget {
); );
} }
Widget replyItemRow(BuildContext context, ThemeData theme) { Widget replyItemRow(
final bool extraRow = replyItem.replies.length < replyItem.count.toInt(); BuildContext context, ThemeData theme, List<ReplyInfo> replies) {
final extraRow = replies.length < replyItem.count.toInt();
late final length = replies.length + (extraRow ? 1 : 0);
return Padding( return Padding(
padding: const EdgeInsets.only(left: 42, right: 4), padding: const EdgeInsets.only(left: 42, right: 4),
child: Material( child: Material(
@@ -430,12 +432,24 @@ class ReplyItemGrpc extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (replyItem.replies.isNotEmpty) if (replies.isNotEmpty)
for (int i = 0; i < replyItem.replies.length; i++) ...[ ...List.generate(replies.length, (index) {
InkWell( final childReply = replies[index];
// 一楼点击评论展开评论详情 EdgeInsets padding;
onTap: () => replyReply?.call( if (length == 1) {
replyItem, replyItem.replies[i].id.toInt()), padding = const EdgeInsets.all(8);
} else {
if (index == 0) {
padding = const EdgeInsets.fromLTRB(8, 8, 8, 4);
} else if (index == length - 1) {
padding = const EdgeInsets.fromLTRB(8, 4, 8, 8);
} else {
padding = const EdgeInsets.fromLTRB(8, 4, 8, 4);
}
}
return InkWell(
onTap: () =>
replyReply?.call(replyItem, childReply.id.toInt()),
onLongPress: () { onLongPress: () {
feedBack(); feedBack();
showModalBottomSheet( showModalBottomSheet(
@@ -448,8 +462,8 @@ class ReplyItemGrpc extends StatelessWidget {
builder: (context) { builder: (context) {
return morePanel( return morePanel(
context: context, context: context,
item: replyItem.replies[i], item: childReply,
onDelete: () => onDelete?.call(i), onDelete: () => onDelete?.call(index),
isSubReply: true, isSubReply: true,
); );
}, },
@@ -457,16 +471,10 @@ class ReplyItemGrpc extends StatelessWidget {
}, },
child: Container( child: Container(
width: double.infinity, width: double.infinity,
padding: EdgeInsets.symmetric( padding: padding,
horizontal: 8,
vertical:
i == 0 && (extraRow || replyItem.replies.length > 1)
? 8
: 4,
),
child: Semantics( child: Semantics(
label: label:
'${replyItem.replies[i].member.name} ${replyItem.replies[i].content.message}', '${childReply.member.name} ${childReply.content.message}',
excludeSemantics: true, excludeSemantics: true,
child: Text.rich( child: Text.rich(
style: TextStyle( style: TextStyle(
@@ -479,7 +487,7 @@ class ReplyItemGrpc extends StatelessWidget {
TextSpan( TextSpan(
children: [ children: [
TextSpan( TextSpan(
text: replyItem.replies[i].member.name, text: childReply.member.name,
style: TextStyle( style: TextStyle(
color: theme.colorScheme.primary, color: theme.colorScheme.primary,
), ),
@@ -487,11 +495,11 @@ class ReplyItemGrpc extends StatelessWidget {
..onTap = () { ..onTap = () {
feedBack(); feedBack();
Get.toNamed( Get.toNamed(
'/member?mid=${replyItem.replies[i].member.mid}', '/member?mid=${childReply.member.mid}',
); );
}, },
), ),
if (replyItem.replies[i].mid == upMid) ...[ if (childReply.mid == upMid) ...[
const TextSpan(text: ' '), const TextSpan(text: ' '),
const WidgetSpan( const WidgetSpan(
alignment: PlaceholderAlignment.middle, alignment: PlaceholderAlignment.middle,
@@ -506,17 +514,16 @@ class ReplyItemGrpc extends StatelessWidget {
const TextSpan(text: ' '), const TextSpan(text: ' '),
], ],
TextSpan( TextSpan(
text: replyItem.replies[i].root == text: childReply.root == childReply.parent
replyItem.replies[i].parent
? ': ' ? ': '
: replyItem.replies[i].mid == upMid : childReply.mid == upMid
? '' ? ''
: ' ', : ' ',
), ),
buildContent( buildContent(
context, context,
theme, theme,
replyItem.replies[i], childReply,
replyItem, replyItem,
null, null,
null, null,
@@ -526,15 +533,17 @@ class ReplyItemGrpc extends StatelessWidget {
), ),
), ),
), ),
) );
], }),
if (extraRow) if (extraRow)
InkWell( InkWell(
// 一楼点击【共xx条回复】展开评论详情 // 一楼点击【共xx条回复】展开评论详情
onTap: () => replyReply?.call(replyItem, null), onTap: () => replyReply?.call(replyItem, null),
child: Container( child: Container(
width: double.infinity, width: double.infinity,
padding: const EdgeInsets.fromLTRB(8, 5, 8, 8), padding: length == 1
? const EdgeInsets.all(8)
: const EdgeInsets.fromLTRB(8, 4, 8, 8),
child: Text.rich( child: Text.rich(
TextSpan( TextSpan(
style: TextStyle( style: TextStyle(