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

@ -1,16 +1,24 @@
import 'package:flutter/material.dart';
import 'package:flutter_linkify/flutter_linkify.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/pages/chat/events/html_message.dart';
import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/utils/file_description.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart';
import 'package:fluffychat/utils/url_launcher.dart';
class MessageDownloadContent extends StatelessWidget {
final Event event;
final Color textColor;
final Color linkColor;
const MessageDownloadContent(this.event, this.textColor, {super.key});
const MessageDownloadContent(
this.event, {
required this.textColor,
required this.linkColor,
super.key,
});
@override
Widget build(BuildContext context) {
@ -66,7 +74,7 @@ class MessageDownloadContent extends StatelessWidget {
Text(
filetype,
style: TextStyle(
color: textColor.withAlpha(150),
color: linkColor,
),
),
const Spacer(),
@ -74,7 +82,7 @@ class MessageDownloadContent extends StatelessWidget {
Text(
sizeString,
style: TextStyle(
color: textColor.withAlpha(150),
color: linkColor,
),
),
],
@ -84,10 +92,20 @@ class MessageDownloadContent extends StatelessWidget {
),
),
if (fileDescription != null)
HtmlMessage(
html: fileDescription,
textColor: textColor,
room: event.room,
Linkify(
text: fileDescription,
style: TextStyle(
color: textColor,
fontSize: AppConfig.fontSizeFactor * AppConfig.messageFontSize,
),
options: const LinkifyOptions(humanize: false),
linkStyle: TextStyle(
color: linkColor,
fontSize: AppConfig.fontSizeFactor * AppConfig.messageFontSize,
decoration: TextDecoration.underline,
decorationColor: linkColor,
),
onOpen: (url) => UrlLauncher(context, url.url).launchUrl(),
),
],
);