mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: reply item
This commit is contained in:
@@ -257,8 +257,12 @@ class ReplyItemGrpc 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;
|
||||||
|
TextStyle style = TextStyle(
|
||||||
|
height: 1.75,
|
||||||
|
fontSize: Theme.of(context).textTheme.bodyMedium!.fontSize,
|
||||||
|
);
|
||||||
var textPainter = TextPainter(
|
var textPainter = TextPainter(
|
||||||
text: TextSpan(text: text),
|
text: TextSpan(text: text, style: style),
|
||||||
maxLines: replyLevel == '1' ? 6 : null,
|
maxLines: replyLevel == '1' ? 6 : null,
|
||||||
textDirection: Directionality.of(context),
|
textDirection: Directionality.of(context),
|
||||||
)..layout(maxWidth: constraints.maxWidth);
|
)..layout(maxWidth: constraints.maxWidth);
|
||||||
@@ -266,10 +270,7 @@ class ReplyItemGrpc extends StatelessWidget {
|
|||||||
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 (isTop) ...[
|
if (isTop) ...[
|
||||||
@@ -605,14 +606,15 @@ InlineSpan buildContent(
|
|||||||
|
|
||||||
if (didExceedMaxLines == true) {
|
if (didExceedMaxLines == true) {
|
||||||
final textSize = textPainter.size;
|
final textSize = textPainter.size;
|
||||||
|
final double maxHeight = textPainter.preferredLineHeight * 6;
|
||||||
var position = textPainter.getPositionForOffset(
|
var position = textPainter.getPositionForOffset(
|
||||||
Offset(
|
Offset(
|
||||||
textSize.width,
|
textSize.width,
|
||||||
textSize.height,
|
maxHeight, // textSize.height,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
final endOffset = textPainter.getOffsetBefore(position.offset);
|
// final endOffset = textPainter.getOffsetBefore(position.offset);
|
||||||
message = message.substring(0, endOffset);
|
message = message.substring(0, position.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return TextSpan(text: message);
|
// return TextSpan(text: message);
|
||||||
|
|||||||
Reference in New Issue
Block a user