From 6184c60d80d8c7fab78369bd5569b44c48ce79a1 Mon Sep 17 00:00:00 2001 From: Sorunome Date: Fri, 15 May 2020 05:47:32 +0000 Subject: [PATCH] Hopefully fix font size & link colour --- lib/components/html_message.dart | 12 +++++++++--- lib/components/message_content.dart | 6 +++++- lib/components/reply_content.dart | 13 +++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/components/html_message.dart b/lib/components/html_message.dart index 57b0a1f..1c7f0f9 100644 --- a/lib/components/html_message.dart +++ b/lib/components/html_message.dart @@ -7,19 +7,25 @@ import 'matrix.dart'; class HtmlMessage extends StatelessWidget { final String html; - final Color textColor; final int maxLines; 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 Widget build(BuildContext context) { // there is no need to pre-validate the html, as we validate it while rendering + final themeData = Theme.of(context); return Html( data: html, - defaultTextStyle: TextStyle(color: textColor), + defaultTextStyle: defaultTextStyle, + linkStyle: linkStyle ?? themeData.textTheme.bodyText2.copyWith( + color: themeData.accentColor, + decoration: TextDecoration.underline, + ), shrinkToFit: true, maxLines: maxLines, onLinkTap: (String url) { diff --git a/lib/components/message_content.dart b/lib/components/message_content.dart index 0fb3028..d2f4897 100644 --- a/lib/components/message_content.dart +++ b/lib/components/message_content.dart @@ -51,7 +51,10 @@ class MessageContent extends StatelessWidget { } return HtmlMessage( html: html, - textColor: textColor, + defaultTextStyle: TextStyle( + color: textColor, + fontSize: DefaultTextStyle.of(context).style.fontSize, + ), room: event.room, ); } @@ -79,6 +82,7 @@ class MessageContent extends StatelessWidget { text: event.getLocalizedBody(L10n.of(context), hideReply: true), textStyle: TextStyle( color: textColor, + fontSize: DefaultTextStyle.of(context).style.fontSize, decoration: event.redacted ? TextDecoration.lineThrough : null, ), ); diff --git a/lib/components/reply_content.dart b/lib/components/reply_content.dart index 432888a..9c28a4b 100644 --- a/lib/components/reply_content.dart +++ b/lib/components/reply_content.dart @@ -29,9 +29,12 @@ class ReplyContent extends StatelessWidget { } replyBody = HtmlMessage( html: html, - textColor: lightText + defaultTextStyle: TextStyle( + color: lightText ? Colors.white : Theme.of(context).textTheme.bodyText2.color, + fontSize: DefaultTextStyle.of(context).style.fontSize, + ), maxLines: 1, room: replyEvent.room, ); @@ -46,9 +49,11 @@ class ReplyContent extends StatelessWidget { overflow: TextOverflow.ellipsis, maxLines: 1, style: TextStyle( - color: lightText - ? Colors.white - : Theme.of(context).textTheme.bodyText2.color), + color: lightText + ? Colors.white + : Theme.of(context).textTheme.bodyText2.color, + fontSize: DefaultTextStyle.of(context).style.fontSize, + ), ); } return Row(