Merge branch 'soru/fix-html-render' into 'master'

Hopefully fix font size & link colour

See merge request ChristianPauly/fluffychat-flutter!56
This commit is contained in:
Christian Pauly 2020-05-15 05:47:33 +00:00
commit fb47b030c0
3 changed files with 23 additions and 8 deletions

View File

@ -7,19 +7,25 @@ import 'matrix.dart';
class HtmlMessage extends StatelessWidget { class HtmlMessage extends StatelessWidget {
final String html; final String html;
final Color textColor;
final int maxLines; final int maxLines;
final Room room; final Room room;
final TextStyle defaultTextStyle;
final TextStyle linkStyle;
const HtmlMessage({this.html, this.textColor, this.maxLines, this.room}); const HtmlMessage({this.html, this.maxLines, this.room, this.defaultTextStyle, this.linkStyle});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
// there is no need to pre-validate the html, as we validate it while rendering // there is no need to pre-validate the html, as we validate it while rendering
final themeData = Theme.of(context);
return Html( return Html(
data: html, data: html,
defaultTextStyle: TextStyle(color: textColor), defaultTextStyle: defaultTextStyle,
linkStyle: linkStyle ?? themeData.textTheme.bodyText2.copyWith(
color: themeData.accentColor,
decoration: TextDecoration.underline,
),
shrinkToFit: true, shrinkToFit: true,
maxLines: maxLines, maxLines: maxLines,
onLinkTap: (String url) { onLinkTap: (String url) {

View File

@ -51,7 +51,10 @@ class MessageContent extends StatelessWidget {
} }
return HtmlMessage( return HtmlMessage(
html: html, html: html,
textColor: textColor, defaultTextStyle: TextStyle(
color: textColor,
fontSize: DefaultTextStyle.of(context).style.fontSize,
),
room: event.room, room: event.room,
); );
} }
@ -79,6 +82,7 @@ class MessageContent extends StatelessWidget {
text: event.getLocalizedBody(L10n.of(context), hideReply: true), text: event.getLocalizedBody(L10n.of(context), hideReply: true),
textStyle: TextStyle( textStyle: TextStyle(
color: textColor, color: textColor,
fontSize: DefaultTextStyle.of(context).style.fontSize,
decoration: event.redacted ? TextDecoration.lineThrough : null, decoration: event.redacted ? TextDecoration.lineThrough : null,
), ),
); );

View File

@ -29,9 +29,12 @@ class ReplyContent extends StatelessWidget {
} }
replyBody = HtmlMessage( replyBody = HtmlMessage(
html: html, html: html,
textColor: lightText defaultTextStyle: TextStyle(
color: lightText
? Colors.white ? Colors.white
: Theme.of(context).textTheme.bodyText2.color, : Theme.of(context).textTheme.bodyText2.color,
fontSize: DefaultTextStyle.of(context).style.fontSize,
),
maxLines: 1, maxLines: 1,
room: replyEvent.room, room: replyEvent.room,
); );
@ -46,9 +49,11 @@ class ReplyContent extends StatelessWidget {
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
maxLines: 1, maxLines: 1,
style: TextStyle( style: TextStyle(
color: lightText color: lightText
? Colors.white ? Colors.white
: Theme.of(context).textTheme.bodyText2.color), : Theme.of(context).textTheme.bodyText2.color,
fontSize: DefaultTextStyle.of(context).style.fontSize,
),
); );
} }
return Row( return Row(