Commit 1524eba6 authored by Wilko Manger's avatar Wilko Manger

Render emote messages correctly

Implements #65.
parent ada9774c
......@@ -82,6 +82,16 @@ abstract class MessageBubble extends Bubble {
return style;
}
TextStyle senderTextStyle(BuildContext context, {Color color}) {
if (color == null) {
color = colorOf(event.sender);
}
return textStyle(context, color: color).copyWith(
fontWeight: FontWeight.bold
);
}
@protected
Widget buildTime(BuildContext context, {Color color}) {
if (isEndOfGroup) {
......@@ -102,15 +112,9 @@ abstract class MessageBubble extends Bubble {
@protected
Widget buildSender(BuildContext context, {Color color}) {
if (color == null) {
color = colorOf(event.sender);
}
if ((isStartOfGroup || (isRepliedTo && !isMine)) && !event.room.isDirect) {
return Text(displayNameOf(event.sender),
style: textStyle(context, color: color).copyWith(
fontWeight: FontWeight.bold
),
style: senderTextStyle(context, color: color)
);
} else {
return Container(height: 0, width: 0);
......
......@@ -101,7 +101,7 @@ class TextBubble extends MessageBubble {
@protected
Widget buildContent(BuildContext context) {
return Html(
final html = Html(
data: event.content.formattedBody ?? '',
useRichText: true,
defaultTextStyle: textStyle(context),
......@@ -113,6 +113,23 @@ class TextBubble extends MessageBubble {
}
},
);
if (event is! EmoteMessageEvent) {
return html;
} else {
return Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(displayNameOf(event.sender) + ' ',
style: senderTextStyle(context,
color: isMine ? Colors.white : null
),
),
html
],
);
}
}
@protected
......@@ -149,25 +166,30 @@ class TextBubble extends MessageBubble {
@protected
Widget buildTheirs(BuildContext context) {
final needsBorder = isRepliedTo && !reply.sender.isIdenticalTo(me);
// Don't show sender above emotes
final sender = event is! EmoteMessageEvent
? buildSender(context) : Container(width: 0);
return InkWell(
onTap: () {},
customBorder: border(),
child: CustomPaint(
painter: needsBorder
? ReplyBorderPainter(
color: colorOf(event.sender),
)
: null,
? ReplyBorderPainter(
color: colorOf(event.sender),
)
: null,
child: Padding(
padding: Bubble.padding.copyWith(
left: needsBorder ? _replyLeftPadding : null
left: needsBorder ? _replyLeftPadding : null
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
buildSender(context),
sender,
_buildRepliedTo(context),
SizedBox(height: 4),
SizedBox(height: sender is! Container ? 4 : 0),
buildContent(context),
SizedBox(height: 4),
buildTime(context)
......
......@@ -215,7 +215,7 @@ packages:
name: matrix_sdk
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.0"
version: "0.8.2"
matrix_sdk_sqflite:
dependency: "direct main"
description:
......
......@@ -12,7 +12,7 @@ dependencies:
injector: ^1.0.6
matrix_sdk: ^0.8.0
matrix_sdk: ^0.8.2
matrix_sdk_sqflite: ^0.5.0
rxdart: ^0.21.0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment