mod: remove more

This commit is contained in:
guozhigq
2024-11-02 23:39:29 +08:00
parent fe4b33febf
commit 0bc2a79468

View File

@ -235,32 +235,33 @@ class ReplyItem extends StatelessWidget {
// title
Container(
margin: const EdgeInsets.only(top: 10, left: 45, right: 6, bottom: 4),
child: !replySave
? LayoutBuilder(builder:
(BuildContext context, BoxConstraints boxConstraints) {
String text = replyItem?.content?.message ?? '';
bool didExceedMaxLines = false;
final double maxWidth = boxConstraints.maxWidth;
TextPainter? textPainter;
final int maxLines =
replyItem!.content!.isText! && replyLevel == '1'
? 6
: 999;
try {
textPainter = TextPainter(
text: TextSpan(text: text),
maxLines: maxLines,
textDirection: Directionality.of(context),
);
textPainter.layout(maxWidth: maxWidth);
didExceedMaxLines = textPainter.didExceedMaxLines;
} catch (e) {
debugPrint('Error while measuring text: $e');
didExceedMaxLines = false;
}
return replyContent(context, didExceedMaxLines, textPainter);
})
: replyContent(context, false, null),
child: Text.rich(
overflow: TextOverflow.ellipsis,
maxLines:
replyLevel == '1' && replyItem!.content!.isText! ? 5 : 999,
style: const TextStyle(height: 1.75),
TextSpan(
children: [
if (replyItem!.isTop!)
const WidgetSpan(
alignment: PlaceholderAlignment.top,
child: PBadge(
text: 'TOP',
size: 'small',
stack: 'normal',
type: 'line',
fs: 9,
),
),
buildContent(
context,
replyItem!,
replyReply,
null,
),
],
),
),
),
// 操作区域
bottonAction(context, replyItem!.replyControl, replySave),
@ -281,36 +282,6 @@ class ReplyItem extends StatelessWidget {
);
}
Widget replyContent(
BuildContext context, bool? didExceedMaxLines, TextPainter? textPainter) {
return Text.rich(
style: const TextStyle(height: 1.75),
TextSpan(
children: [
if (replyItem!.isTop!)
const WidgetSpan(
alignment: PlaceholderAlignment.top,
child: PBadge(
text: 'TOP',
size: 'small',
stack: 'normal',
type: 'line',
fs: 9,
),
),
buildContent(
context,
replyItem!,
replyReply,
null,
didExceedMaxLines ?? false,
textPainter,
),
],
),
);
}
// 感谢、回复、复制
Widget bottonAction(BuildContext context, replyControl, replySave) {
ColorScheme colorScheme = Theme.of(context).colorScheme;
@ -493,8 +464,12 @@ class ReplyItemRow extends StatelessWidget {
fs: 9,
),
),
buildContent(context, replies![i], replyReply,
replyItem, false, null),
buildContent(
context,
replies![i],
replyReply,
replyItem,
),
],
),
),
@ -540,8 +515,6 @@ InlineSpan buildContent(
replyItem,
replyReply,
fReplyItem,
bool didExceedMaxLines,
TextPainter? textPainter,
) {
final String routePath = Get.currentRoute;
bool isVideoPage = routePath.startsWith('/video');
@ -553,25 +526,6 @@ InlineSpan buildContent(
final content = replyItem.content;
final List<InlineSpan> spanChilds = <InlineSpan>[];
if (didExceedMaxLines && content.message != '') {
final textSize = textPainter!.size;
var position = textPainter.getPositionForOffset(
Offset(
textSize.width,
textSize.height,
),
);
final endOffset = textPainter.getOffsetBefore(position.offset);
if (endOffset != null && endOffset > 0) {
content.message = content.message.substring(0, endOffset);
} else {
content.message = content.message.substring(0, position.offset);
}
} else {
content.message = content.message2;
}
// 投票
if (content.vote.isNotEmpty) {
content.message.splitMapJoin(RegExp(r"\{vote:.*?\}"),
@ -921,17 +875,6 @@ InlineSpan buildContent(
}
}
if (didExceedMaxLines) {
spanChilds.add(
TextSpan(
text: '\n查看更多',
style: TextStyle(
color: colorScheme.primary,
),
),
);
}
// 图片渲染
if (content.pictures.isNotEmpty) {
final List<String> picList = <String>[];