refactor: Update flutter_html

This commit is contained in:
Krille 2023-06-01 11:03:40 +02:00
parent 640fe0d476
commit e166f17cae
No known key found for this signature in database

View File

@ -109,7 +109,7 @@ class HtmlMessage extends StatelessWidget {
color: textColor, color: textColor,
), ),
), ),
padding: const EdgeInsets.only(left: 6, bottom: 0), padding: HtmlPaddings.only(left: 6, bottom: 0),
), ),
'hr': Style( 'hr': Style(
border: Border.all(color: textColor, width: 0.5), border: Border.all(color: textColor, width: 0.5),
@ -122,7 +122,7 @@ class HtmlMessage extends StatelessWidget {
), ),
'td': Style( 'td': Style(
border: Border.all(color: textColor, width: 0.5), border: Border.all(color: textColor, width: 0.5),
padding: const EdgeInsets.all(2), padding: HtmlPaddings.all(2),
), ),
'th': Style( 'th': Style(
border: Border.all(color: textColor, width: 0.5), border: Border.all(color: textColor, width: 0.5),
@ -235,7 +235,6 @@ class FontColorExtension extends HtmlExtension {
@override @override
InlineSpan build( InlineSpan build(
ExtensionContext context, ExtensionContext context,
Map<StyledElement, InlineSpan> Function() parseChildren,
) { ) {
final colorText = context.element?.attributes[colorAttribute] ?? final colorText = context.element?.attributes[colorAttribute] ??
context.element?.attributes[mxColorAttribute]; context.element?.attributes[mxColorAttribute];
@ -259,10 +258,7 @@ class ImageExtension extends HtmlExtension {
Set<String> get supportedTags => {'img'}; Set<String> get supportedTags => {'img'};
@override @override
InlineSpan build( InlineSpan build(ExtensionContext context) {
ExtensionContext context,
Map<StyledElement, InlineSpan> Function() parseChildren,
) {
final mxcUrl = Uri.tryParse(context.attributes['src'] ?? ''); final mxcUrl = Uri.tryParse(context.attributes['src'] ?? '');
if (mxcUrl == null || mxcUrl.scheme != 'mxc') { if (mxcUrl == null || mxcUrl.scheme != 'mxc') {
return TextSpan(text: context.attributes['alt']); return TextSpan(text: context.attributes['alt']);
@ -304,11 +300,9 @@ class SpoilerExtension extends HtmlExtension {
} }
@override @override
InlineSpan build( InlineSpan build(ExtensionContext context) {
ExtensionContext context,
Map<StyledElement, InlineSpan> Function() parseChildren,
) {
var obscure = true; var obscure = true;
final children = context.inlineSpanChildren;
return WidgetSpan( return WidgetSpan(
child: StatefulBuilder( child: StatefulBuilder(
builder: (context, setState) { builder: (context, setState) {
@ -319,7 +313,7 @@ class SpoilerExtension extends HtmlExtension {
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
style: obscure ? TextStyle(backgroundColor: textColor) : null, style: obscure ? TextStyle(backgroundColor: textColor) : null,
children: parseChildren().values.toList(), children: children,
), ),
), ),
); );
@ -344,10 +338,7 @@ class MatrixMathExtension extends HtmlExtension {
} }
@override @override
InlineSpan build( InlineSpan build(ExtensionContext context) {
ExtensionContext context,
Map<StyledElement, InlineSpan> Function() parseChildren,
) {
final data = context.element?.attributes['data-mx-maths'] ?? ''; final data = context.element?.attributes['data-mx-maths'] ?? '';
return WidgetSpan( return WidgetSpan(
child: Math.tex( child: Math.tex(
@ -373,11 +364,7 @@ class CodeExtension extends HtmlExtension {
Set<String> get supportedTags => {'code'}; Set<String> get supportedTags => {'code'};
@override @override
InlineSpan build( InlineSpan build(ExtensionContext context) => WidgetSpan(
ExtensionContext context,
Map<StyledElement, InlineSpan> Function() parseChildren,
) =>
WidgetSpan(
child: Material( child: Material(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
borderRadius: BorderRadius.circular(4), borderRadius: BorderRadius.circular(4),
@ -428,10 +415,7 @@ class RoomPillExtension extends HtmlExtension {
_cachedUsers[room.id + matrixId] ??= await room.requestUser(matrixId); _cachedUsers[room.id + matrixId] ??= await room.requestUser(matrixId);
@override @override
InlineSpan build( InlineSpan build(ExtensionContext context) {
ExtensionContext context,
Map<StyledElement, InlineSpan> Function() parseChildren,
) {
final href = context.element?.attributes['href']; final href = context.element?.attributes['href'];
final matrixId = href?.parseIdentifierIntoParts()?.primaryIdentifier; final matrixId = href?.parseIdentifierIntoParts()?.primaryIdentifier;
if (href == null || matrixId == null) { if (href == null || matrixId == null) {