mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Cache parsed emojies
This commit is contained in:
@ -521,7 +521,7 @@ class _PostTileState extends State<PostTile> {
|
||||
context: context,
|
||||
title: tr("Update comment content"),
|
||||
message: tr("New content:"),
|
||||
defaultValue: comment.content,
|
||||
defaultValue: comment.content.isNull ? "" : comment.content.content,
|
||||
hint: tr("New content..."),
|
||||
);
|
||||
|
||||
@ -529,7 +529,7 @@ class _PostTileState extends State<PostTile> {
|
||||
return showSimpleSnack(context, tr("Could not update comment content!"));
|
||||
|
||||
setState(() {
|
||||
comment.content = newContent;
|
||||
comment.content.content = newContent;
|
||||
});
|
||||
}
|
||||
|
||||
@ -591,7 +591,7 @@ class _PostTileState extends State<PostTile> {
|
||||
context: context,
|
||||
title: tr("Update post content"),
|
||||
message: tr("Please enter message content: "),
|
||||
defaultValue: widget.post.content == null ? "" : widget.post.content,
|
||||
defaultValue: widget.post.content.isNull == null ? "" : widget.post.content.content,
|
||||
hint: tr("Post content"),
|
||||
);
|
||||
|
||||
@ -602,7 +602,7 @@ class _PostTileState extends State<PostTile> {
|
||||
return;
|
||||
}
|
||||
|
||||
setState(() => widget.post.content = newContent);
|
||||
setState(() => widget.post.content.content = newContent);
|
||||
}
|
||||
|
||||
/// Perform the deletion of the post
|
||||
|
@ -1,8 +1,8 @@
|
||||
import 'package:comunic/models/displayed_content.dart';
|
||||
import 'package:comunic/utils/bbcode_parser.dart';
|
||||
import 'package:comunic/utils/input_utils.dart';
|
||||
import 'package:comunic/utils/navigation_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_emoji/flutter_emoji.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
/// Text widget
|
||||
@ -11,8 +11,8 @@ import 'package:url_launcher/url_launcher.dart';
|
||||
///
|
||||
/// @author Pierre Hubert
|
||||
|
||||
class TextWidget extends StatefulWidget {
|
||||
final String content;
|
||||
class TextWidget extends StatelessWidget {
|
||||
final DisplayedString content;
|
||||
final bool parseBBcode;
|
||||
final TextStyle style;
|
||||
|
||||
@ -25,38 +25,28 @@ class TextWidget extends StatefulWidget {
|
||||
assert(parseBBcode != null),
|
||||
super(key: key);
|
||||
|
||||
@override
|
||||
_TextWidgetState createState() => _TextWidgetState();
|
||||
}
|
||||
|
||||
class _TextWidgetState extends State<TextWidget> {
|
||||
Widget _cache;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_cache == null) _cache = doBuild();
|
||||
if (this.content.isNull || this.content.isEmpty) return Text("");
|
||||
|
||||
return _cache;
|
||||
}
|
||||
|
||||
Widget doBuild() {
|
||||
var content = EmojiParser().emojify(this.widget.content);
|
||||
var content = this.content.parsedString;
|
||||
|
||||
// Parse BBcode
|
||||
if (this.widget.parseBBcode)
|
||||
if (parseBBcode)
|
||||
return BBCodeParsedWidget(
|
||||
text: content,
|
||||
parseCallback: (style, text) => _parseLinks(text, style),
|
||||
parseCallback: (style, text) => _parseLinks(context, text, style),
|
||||
);
|
||||
|
||||
// Just parse link
|
||||
return RichText(
|
||||
text: TextSpan(children: _parseLinks(content, widget.style)),
|
||||
text: TextSpan(children: _parseLinks(context, content, style)),
|
||||
);
|
||||
}
|
||||
|
||||
/// Sub parse function
|
||||
List<InlineSpan> _parseLinks(String text, TextStyle style) {
|
||||
List<InlineSpan> _parseLinks(
|
||||
BuildContext context, String text, TextStyle style) {
|
||||
if (style == null) style = TextStyle();
|
||||
|
||||
var buff = StringBuffer();
|
||||
|
Reference in New Issue
Block a user