mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-31 08:08:19 +08:00
opt: reply item
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -255,23 +255,24 @@ class ReplyItem extends StatelessWidget {
|
|||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
String text = replyItem?.content?.message ?? '';
|
String text = replyItem?.content?.message ?? '';
|
||||||
var textPainter = TextPainter(
|
TextStyle style = TextStyle(
|
||||||
text: TextSpan(text: text),
|
height: 1.75,
|
||||||
maxLines: replyItem!.content!.isText! &&
|
fontSize: Theme.of(context).textTheme.bodyMedium!.fontSize,
|
||||||
replyLevel == '1' &&
|
);
|
||||||
GlobalData().replyLengthLimit != 0
|
TextPainter? textPainter;
|
||||||
? GlobalData().replyLengthLimit
|
bool? didExceedMaxLines;
|
||||||
: null,
|
if (replyLevel == '1' && GlobalData().replyLengthLimit != 0) {
|
||||||
|
textPainter = TextPainter(
|
||||||
|
text: TextSpan(text: text, style: style),
|
||||||
|
maxLines: GlobalData().replyLengthLimit,
|
||||||
textDirection: Directionality.of(context),
|
textDirection: Directionality.of(context),
|
||||||
)..layout(maxWidth: constraints.maxWidth);
|
)..layout(maxWidth: constraints.maxWidth);
|
||||||
bool didExceedMaxLines = textPainter.didExceedMaxLines;
|
didExceedMaxLines = textPainter.didExceedMaxLines;
|
||||||
|
}
|
||||||
return Semantics(
|
return Semantics(
|
||||||
label: text,
|
label: text,
|
||||||
child: Text.rich(
|
child: Text.rich(
|
||||||
style: TextStyle(
|
style: style,
|
||||||
height: 1.75,
|
|
||||||
fontSize:
|
|
||||||
Theme.of(context).textTheme.bodyMedium!.fontSize),
|
|
||||||
TextSpan(
|
TextSpan(
|
||||||
children: [
|
children: [
|
||||||
if (replyItem!.isTop!) ...[
|
if (replyItem!.isTop!) ...[
|
||||||
@@ -296,13 +297,6 @@ class ReplyItem extends StatelessWidget {
|
|||||||
textPainter,
|
textPainter,
|
||||||
didExceedMaxLines,
|
didExceedMaxLines,
|
||||||
),
|
),
|
||||||
if (didExceedMaxLines)
|
|
||||||
TextSpan(
|
|
||||||
text: '\n查看更多',
|
|
||||||
style: TextStyle(
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -952,6 +946,18 @@ class ReplyItem extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (didExceedMaxLines == true) {
|
||||||
|
spanChildren.add(
|
||||||
|
TextSpan(
|
||||||
|
text: '\n查看更多',
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// 图片渲染
|
// 图片渲染
|
||||||
if (content.pictures.isNotEmpty) {
|
if (content.pictures.isNotEmpty) {
|
||||||
spanChildren.add(const TextSpan(text: '\n'));
|
spanChildren.add(const TextSpan(text: '\n'));
|
||||||
|
|||||||
@@ -267,15 +267,16 @@ class ReplyItemGrpc extends StatelessWidget {
|
|||||||
height: 1.75,
|
height: 1.75,
|
||||||
fontSize: Theme.of(context).textTheme.bodyMedium!.fontSize,
|
fontSize: Theme.of(context).textTheme.bodyMedium!.fontSize,
|
||||||
);
|
);
|
||||||
var textPainter = TextPainter(
|
TextPainter? textPainter;
|
||||||
|
bool? didExceedMaxLines;
|
||||||
|
if (replyLevel == '1' && GlobalData().replyLengthLimit != 0) {
|
||||||
|
textPainter = TextPainter(
|
||||||
text: TextSpan(text: text, style: style),
|
text: TextSpan(text: text, style: style),
|
||||||
maxLines:
|
maxLines: GlobalData().replyLengthLimit,
|
||||||
replyLevel == '1' && GlobalData().replyLengthLimit != 0
|
|
||||||
? GlobalData().replyLengthLimit
|
|
||||||
: null,
|
|
||||||
textDirection: Directionality.of(context),
|
textDirection: Directionality.of(context),
|
||||||
)..layout(maxWidth: constraints.maxWidth);
|
)..layout(maxWidth: constraints.maxWidth);
|
||||||
bool didExceedMaxLines = textPainter.didExceedMaxLines;
|
didExceedMaxLines = textPainter.didExceedMaxLines;
|
||||||
|
}
|
||||||
return Semantics(
|
return Semantics(
|
||||||
label: text,
|
label: text,
|
||||||
child: Text.rich(
|
child: Text.rich(
|
||||||
|
|||||||
Reference in New Issue
Block a user