support for m.emote msgtype
This commit is contained in:
parent
b9e42ec51b
commit
f9b1960cf8
2 changed files with 28 additions and 5 deletions
|
|
@ -25,6 +25,13 @@ abstract class MessageContent extends Content with _$MessageContent {
|
|||
String? formattedBody,
|
||||
}) = NoticeMessageContent;
|
||||
|
||||
@FreezedUnionValue("m.emote")
|
||||
factory MessageContent.emote({
|
||||
required String body,
|
||||
String? format,
|
||||
String? formattedBody,
|
||||
}) = EmoteMessageContent;
|
||||
|
||||
@FreezedUnionValue("m.image")
|
||||
factory MessageContent.image({
|
||||
required String body,
|
||||
|
|
|
|||
|
|
@ -62,6 +62,11 @@ class RenderEvent extends ConsumerWidget {
|
|||
children: getEventOptions!(event).toList(),
|
||||
);
|
||||
|
||||
final textStyle = TextStyle(
|
||||
fontSize: event.localContent?.bigEmoji == true ? 32 : null,
|
||||
fontStyle: event.content is EmoteMessageContent ? FontStyle.italic : null,
|
||||
);
|
||||
|
||||
if (event.redactedBy != null) return SizedBox.shrink();
|
||||
|
||||
final child = switch (event.content) {
|
||||
|
|
@ -132,6 +137,11 @@ class RenderEvent extends ConsumerWidget {
|
|||
:final formattedBody,
|
||||
:final format,
|
||||
) ||
|
||||
EmoteMessageContent(
|
||||
:final body,
|
||||
:final formattedBody,
|
||||
:final format,
|
||||
) ||
|
||||
ImageMessageContent(
|
||||
:final body,
|
||||
:final formattedBody,
|
||||
|
|
@ -141,10 +151,7 @@ class RenderEvent extends ConsumerWidget {
|
|||
children: [
|
||||
format == "org.matrix.custom.html" && !textOnly
|
||||
? Html(
|
||||
textStyle:
|
||||
event.localContent?.bigEmoji == true
|
||||
? TextStyle(fontSize: 32)
|
||||
: null,
|
||||
textStyle: textStyle,
|
||||
formattedBody!.replaceAllMapped(
|
||||
RegExp(
|
||||
"(<a\\b[^>]*>.*?<\\/a>)|(\\bhttps?:\\/\\/[^\\s<]+)",
|
||||
|
|
@ -164,6 +171,7 @@ class RenderEvent extends ConsumerWidget {
|
|||
),
|
||||
)
|
||||
: Linkify(
|
||||
style: textStyle,
|
||||
text: body,
|
||||
maxLines: maxLines,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
|
|
@ -263,7 +271,15 @@ class RenderEvent extends ConsumerWidget {
|
|||
LinkPreview(link.url),
|
||||
],
|
||||
),
|
||||
_ => Text("Unknown message type", style: errorStyle),
|
||||
MessageContent(:final body) => Row(
|
||||
spacing: 8,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text("Unknown message type:", style: errorStyle),
|
||||
Text(body),
|
||||
],
|
||||
),
|
||||
_ => throw Exception("This is impossible"),
|
||||
},
|
||||
],
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue