fix: Introduce a TextMessage widget that doesn't render HTML
Messages that don't have the format set to `org.matrix.custom.html` shouldn't be interpreted as HTML. This achieves that by adding a simpler TextMessage widget that renders messages as plain text. TextMessage was created by copying relevant parts of HtmlMessage, so there's definitely potential for deduplicating.pull/2015/head
parent
90f7cca0a5
commit
155f8f6328
@ -0,0 +1,40 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_linkify/flutter_linkify.dart';
|
||||
|
||||
class TextMessage extends StatelessWidget {
|
||||
final String text;
|
||||
final Color textColor;
|
||||
final double fontSize;
|
||||
final TextStyle linkStyle;
|
||||
final void Function(LinkableElement) onOpen;
|
||||
final bool limitHeight;
|
||||
|
||||
const TextMessage({
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.fontSize,
|
||||
required this.linkStyle,
|
||||
required this.onOpen,
|
||||
this.textColor = Colors.black,
|
||||
this.limitHeight = true,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Text.rich(
|
||||
LinkifySpan(
|
||||
text: text,
|
||||
options: const LinkifyOptions(humanize: false),
|
||||
linkStyle: linkStyle,
|
||||
onOpen: onOpen,
|
||||
),
|
||||
style: TextStyle(
|
||||
fontSize: fontSize,
|
||||
color: textColor,
|
||||
),
|
||||
maxLines: limitHeight ? 64 : null,
|
||||
overflow: TextOverflow.fade,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue