refactor: New html rendering

This commit is contained in:
Krille 2025-01-30 14:09:33 +01:00 committed by krille-chan
commit 12c948211b
No known key found for this signature in database
9 changed files with 467 additions and 436 deletions

View file

@ -26,6 +26,7 @@ import 'message_download_content.dart';
class MessageContent extends StatelessWidget {
final Event event;
final Color textColor;
final Color linkColor;
final void Function(Event)? onInfoTab;
final BorderRadius borderRadius;
final Timeline timeline;
@ -36,6 +37,7 @@ class MessageContent extends StatelessWidget {
super.key,
required this.timeline,
required this.textColor,
required this.linkColor,
required this.borderRadius,
});
@ -155,14 +157,23 @@ class MessageContent extends StatelessWidget {
return AudioPlayerWidget(
event,
color: textColor,
linkColor: linkColor,
fontSize: fontSize,
);
}
return MessageDownloadContent(event, textColor);
return MessageDownloadContent(
event,
textColor: textColor,
linkColor: linkColor,
);
case MessageTypes.Video:
return EventVideoPlayer(event, textColor: textColor);
case MessageTypes.File:
return MessageDownloadContent(event, textColor);
return MessageDownloadContent(
event,
textColor: textColor,
linkColor: linkColor,
);
case MessageTypes.Text:
case MessageTypes.Notice:
@ -178,6 +189,15 @@ class MessageContent extends StatelessWidget {
html: html,
textColor: textColor,
room: event.room,
fontSize: AppConfig.fontSizeFactor * AppConfig.messageFontSize,
linkStyle: TextStyle(
color: linkColor,
fontSize:
AppConfig.fontSizeFactor * AppConfig.messageFontSize,
decoration: TextDecoration.underline,
decorationColor: linkColor,
),
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
);
}
// else we fall through to the normal message rendering
@ -268,10 +288,10 @@ class MessageContent extends StatelessWidget {
),
options: const LinkifyOptions(humanize: false),
linkStyle: TextStyle(
color: textColor.withAlpha(150),
color: linkColor,
fontSize: fontSize,
decoration: TextDecoration.underline,
decorationColor: textColor.withAlpha(150),
decorationColor: linkColor,
),
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
);