diff --git a/lib/components/html_message.dart b/lib/components/html_message.dart
index a0b3092..57b0a1f 100644
--- a/lib/components/html_message.dart
+++ b/lib/components/html_message.dart
@@ -9,8 +9,9 @@ class HtmlMessage extends StatelessWidget {
final String html;
final Color textColor;
final int maxLines;
+ final Room room;
- const HtmlMessage({this.html, this.textColor, this.maxLines});
+ const HtmlMessage({this.html, this.textColor, this.maxLines, this.room});
@override
Widget build(BuildContext context) {
@@ -36,6 +37,57 @@ class HtmlMessage extends StatelessWidget {
method: ThumbnailMethod.scale,
);
},
+ getPillInfo: (String identifier) async {
+ if (room == null) {
+ return null;
+ }
+ if (identifier[0] == '@') {
+ // we have a user pill
+ final user = room.getState('m.room.member', identifier);
+ if (user != null) {
+ return user.content;
+ }
+ // there might still be a profile...
+ final profile = await room.client.getProfileFromUserId(identifier);
+ if (profile != null) {
+ return {
+ 'displayname': profile.displayname,
+ 'avatar_url': profile.avatarUrl.toString(),
+ };
+ }
+ return null;
+ }
+ if (identifier[0] == '#') {
+ // we have an alias pill
+ for (final r in room.client.rooms) {
+ final state = r.getState('m.room.canonical_alias');
+ if (
+ state != null && (
+ (state.content['alias'] is String && state.content['alias'] == identifier) ||
+ (state.content['alt_aliases'] is List && state.content['alt_aliases'].contains(identifier))
+ )) {
+ // we have a room!
+ return {
+ 'displayname': identifier,
+ 'avatar_url': r.getState('m.room.avatar')?.content['url'],
+ };
+ }
+ }
+ return null;
+ }
+ if (identifier[0] == '!') {
+ // we have a room ID pill
+ final r = room.client.getRoomById(identifier);
+ if (r == null) {
+ return null;
+ }
+ return {
+ 'displayname': r.canonicalAlias,
+ 'avatar_url': r.getState('m.room.avatar')?.content['url'],
+ };
+ }
+ return null;
+ },
);
}
}
diff --git a/lib/components/message_content.dart b/lib/components/message_content.dart
index 6d23ba3..0fb3028 100644
--- a/lib/components/message_content.dart
+++ b/lib/components/message_content.dart
@@ -40,6 +40,7 @@ class MessageContent extends StatelessWidget {
case MessageTypes.Text:
case MessageTypes.Notice:
case MessageTypes.Emote:
+ case MessageTypes.Reply:
if (Matrix.of(context).renderHtml &&
!event.redacted &&
event.content['format'] == 'org.matrix.custom.html' &&
@@ -51,12 +52,12 @@ class MessageContent extends StatelessWidget {
return HtmlMessage(
html: html,
textColor: textColor,
+ room: event.room,
);
}
// else we fall through to the normal message rendering
continue textmessage;
case MessageTypes.BadEncrypted:
- case MessageTypes.Reply:
case MessageTypes.Location:
case MessageTypes.None:
textmessage:
diff --git a/lib/components/reply_content.dart b/lib/components/reply_content.dart
index 4822ccc..432888a 100644
--- a/lib/components/reply_content.dart
+++ b/lib/components/reply_content.dart
@@ -33,6 +33,7 @@ class ReplyContent extends StatelessWidget {
? Colors.white
: Theme.of(context).textTheme.bodyText2.color,
maxLines: 1,
+ room: replyEvent.room,
);
} else {
replyBody = Text(
@@ -51,6 +52,7 @@ class ReplyContent extends StatelessWidget {
);
}
return Row(
+ mainAxisSize: MainAxisSize.min,
children: [
Container(
width: 3,
@@ -58,7 +60,7 @@ class ReplyContent extends StatelessWidget {
color: lightText ? Colors.white : Theme.of(context).primaryColor,
),
SizedBox(width: 6),
- Expanded(
+ Flexible(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
diff --git a/pubspec.lock b/pubspec.lock
index 60278b5..46de7f8 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -203,7 +203,7 @@ packages:
name: flutter_matrix_html
url: "https://pub.dartlang.org"
source: hosted
- version: "0.0.5"
+ version: "0.0.6"
flutter_plugin_android_lifecycle:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index 976a854..13aebf6 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -54,7 +54,7 @@ dependencies:
open_file: ^3.0.1
mime_type: ^0.3.0
bot_toast: ^3.0.0
- flutter_matrix_html: ^0.0.5
+ flutter_matrix_html: ^0.0.6
moor: ^3.0.2
random_string: ^2.0.1