Remove flutter chat #26
2 changed files with 14 additions and 9 deletions
Make message format an enum
commit
fc6ca5b454
|
|
@ -15,28 +15,28 @@ abstract class MessageContent extends Content with _$MessageContent {
|
||||||
@FreezedUnionValue("m.text")
|
@FreezedUnionValue("m.text")
|
||||||
factory MessageContent.text({
|
factory MessageContent.text({
|
||||||
required String body,
|
required String body,
|
||||||
String? format,
|
MessageFormat? format,
|
||||||
String? formattedBody,
|
String? formattedBody,
|
||||||
}) = TextMessageContent;
|
}) = TextMessageContent;
|
||||||
|
|
||||||
@FreezedUnionValue("m.notice")
|
@FreezedUnionValue("m.notice")
|
||||||
factory MessageContent.notice({
|
factory MessageContent.notice({
|
||||||
required String body,
|
required String body,
|
||||||
String? format,
|
MessageFormat? format,
|
||||||
String? formattedBody,
|
String? formattedBody,
|
||||||
}) = NoticeMessageContent;
|
}) = NoticeMessageContent;
|
||||||
|
|
||||||
@FreezedUnionValue("m.emote")
|
@FreezedUnionValue("m.emote")
|
||||||
factory MessageContent.emote({
|
factory MessageContent.emote({
|
||||||
required String body,
|
required String body,
|
||||||
String? format,
|
MessageFormat? format,
|
||||||
String? formattedBody,
|
String? formattedBody,
|
||||||
}) = EmoteMessageContent;
|
}) = EmoteMessageContent;
|
||||||
|
|
||||||
@FreezedUnionValue("m.image")
|
@FreezedUnionValue("m.image")
|
||||||
factory MessageContent.image({
|
factory MessageContent.image({
|
||||||
required String body,
|
required String body,
|
||||||
String? format,
|
MessageFormat? format,
|
||||||
String? formattedBody,
|
String? formattedBody,
|
||||||
// EncryptedFile? file
|
// EncryptedFile? file
|
||||||
String? filename,
|
String? filename,
|
||||||
|
|
@ -47,7 +47,7 @@ abstract class MessageContent extends Content with _$MessageContent {
|
||||||
@FreezedUnionValue("m.file")
|
@FreezedUnionValue("m.file")
|
||||||
factory MessageContent.file({
|
factory MessageContent.file({
|
||||||
required String body,
|
required String body,
|
||||||
String? format,
|
MessageFormat? format,
|
||||||
String? formattedBody,
|
String? formattedBody,
|
||||||
// EncryptedFile? file
|
// EncryptedFile? file
|
||||||
String? filename,
|
String? filename,
|
||||||
|
|
@ -58,7 +58,7 @@ abstract class MessageContent extends Content with _$MessageContent {
|
||||||
@FreezedUnionValue("m.audio")
|
@FreezedUnionValue("m.audio")
|
||||||
factory MessageContent.audio({
|
factory MessageContent.audio({
|
||||||
required String body,
|
required String body,
|
||||||
String? format,
|
MessageFormat? format,
|
||||||
String? formattedBody,
|
String? formattedBody,
|
||||||
// EncryptedFile? file
|
// EncryptedFile? file
|
||||||
String? filename,
|
String? filename,
|
||||||
|
|
@ -69,7 +69,7 @@ abstract class MessageContent extends Content with _$MessageContent {
|
||||||
@FreezedUnionValue("m.video")
|
@FreezedUnionValue("m.video")
|
||||||
factory MessageContent.video({
|
factory MessageContent.video({
|
||||||
required String body,
|
required String body,
|
||||||
String? format,
|
MessageFormat? format,
|
||||||
String? formattedBody,
|
String? formattedBody,
|
||||||
// EncryptedFile? file
|
// EncryptedFile? file
|
||||||
String? filename,
|
String? filename,
|
||||||
|
|
@ -84,3 +84,9 @@ abstract class MessageContent extends Content with _$MessageContent {
|
||||||
factory MessageContent.fromJson(Map<String, Object?> json) =>
|
factory MessageContent.fromJson(Map<String, Object?> json) =>
|
||||||
_$MessageContentFromJson(json);
|
_$MessageContentFromJson(json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonEnum()
|
||||||
|
enum MessageFormat {
|
||||||
|
@JsonValue("org.matrix.custom.html")
|
||||||
|
html,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -231,8 +231,7 @@ class EventRenderer extends ConsumerWidget {
|
||||||
) => Column(
|
) => Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
format == "org.matrix.custom.html" &&
|
format == MessageFormat.html && !textOnly
|
||||||
!textOnly
|
|
||||||
? Html(
|
? Html(
|
||||||
textStyle: textStyle,
|
textStyle: textStyle,
|
||||||
formattedBody!.replaceAllMapped(
|
formattedBody!.replaceAllMapped(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue