mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-01-15 20:58:41 +00:00
fix #194
This commit is contained in:
parent
24e8f1ca36
commit
87d7f24416
2 changed files with 31 additions and 23 deletions
|
|
@ -36,10 +36,10 @@ class ChatTextResponseColumns extends StatelessWidget {
|
||||||
child: Text(
|
child: Text(
|
||||||
content.text,
|
content.text,
|
||||||
style: TextStyle(fontSize: 14),
|
style: TextStyle(fontSize: 14),
|
||||||
textAlign: right ? TextAlign.left : TextAlign.right,
|
textAlign: right ? TextAlign.right : TextAlign.left,
|
||||||
)),
|
)),
|
||||||
];
|
];
|
||||||
if (!right) {
|
if (right) {
|
||||||
entries = entries.reversed.toList();
|
entries = entries.reversed.toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,7 +72,7 @@ class ChatTextResponseColumns extends StatelessWidget {
|
||||||
|
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
right ? CrossAxisAlignment.start : CrossAxisAlignment.end,
|
right ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||||
children: children,
|
children: children,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -273,28 +273,34 @@ class _ChatMessagesViewState extends State<ChatMessagesView> {
|
||||||
index -= 1;
|
index -= 1;
|
||||||
double size = 44;
|
double size = 44;
|
||||||
if (messages[index].kind == MessageKind.textMessage) {
|
if (messages[index].kind == MessageKind.textMessage) {
|
||||||
MessageContent? content = MessageContent.fromJson(
|
TextMessageContent? content = TextMessageContent.fromJson(
|
||||||
messages[index].kind,
|
|
||||||
jsonDecode(messages[index].contentJson!));
|
jsonDecode(messages[index].contentJson!));
|
||||||
if (content is TextMessageContent) {
|
|
||||||
if (EmojiAnimation.supported(content.text)) {
|
if (EmojiAnimation.supported(content.text)) {
|
||||||
size = 95;
|
size = 95;
|
||||||
} else {
|
} else {
|
||||||
size = 11 +
|
size = 11 +
|
||||||
calculateNumberOfLines(content.text,
|
calculateNumberOfLines(content.text,
|
||||||
MediaQuery.of(context).size.width * 0.8) *
|
MediaQuery.of(context).size.width * 0.8, 17) *
|
||||||
27;
|
27;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (messages[index].mediaStored) {
|
if (messages[index].mediaStored) {
|
||||||
size = 271;
|
size = 271;
|
||||||
}
|
}
|
||||||
// add reaction size
|
final reactions =
|
||||||
size += (textReactionsToMessageId[messages[index].messageId]
|
textReactionsToMessageId[messages[index].messageId];
|
||||||
?.length ??
|
if (reactions != null && reactions.isNotEmpty) {
|
||||||
0) *
|
for (final reaction in reactions) {
|
||||||
|
if (reaction.kind == MessageKind.textMessage) {
|
||||||
|
TextMessageContent? content =
|
||||||
|
TextMessageContent.fromJson(
|
||||||
|
jsonDecode(reaction.contentJson!));
|
||||||
|
size += calculateNumberOfLines(content.text,
|
||||||
|
MediaQuery.of(context).size.width * 0.5, 14) *
|
||||||
27;
|
27;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isLastMessageFromSameUser(messages, index)) {
|
if (!isLastMessageFromSameUser(messages, index)) {
|
||||||
size += 20;
|
size += 20;
|
||||||
|
|
@ -418,12 +424,14 @@ bool isLastMessageFromSameUser(List<Message> messages, int index) {
|
||||||
currentMessage.messageOtherId != null);
|
currentMessage.messageOtherId != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
double calculateNumberOfLines(String text, double width) {
|
double calculateNumberOfLines(String text, double width, double fontSize) {
|
||||||
final textPainter = TextPainter(
|
final textPainter = TextPainter(
|
||||||
text: TextSpan(text: text, style: TextStyle(fontSize: 17)),
|
text: TextSpan(
|
||||||
// maxLines: null,
|
text: text,
|
||||||
|
style: TextStyle(fontSize: fontSize),
|
||||||
|
),
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
);
|
);
|
||||||
textPainter.layout(maxWidth: (width - 20));
|
textPainter.layout(maxWidth: (width - 30));
|
||||||
return textPainter.computeLineMetrics().length.toDouble();
|
return textPainter.computeLineMetrics().length.toDouble();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue