1
0
mirror of https://gitlab.com/comunic/comunicmobile synced 2025-06-19 16:25:17 +00:00

Add references support

This commit is contained in:
2020-04-16 12:06:01 +02:00
parent 7de882338d
commit 2bb75da017
6 changed files with 127 additions and 8 deletions

View File

@ -1,5 +1,6 @@
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';
@ -32,17 +33,17 @@ class TextWidget extends StatelessWidget {
if (this.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, 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) {
var buff = StringBuffer();
final list = new List<InlineSpan>();
@ -78,6 +79,25 @@ class TextWidget extends StatelessWidget {
buff.write(" ");
}
// Check if it is a user reference
else if(validateUserReference(word)) {
changeWordType();
list.add(
WidgetSpan(
child: InkWell(
child: Text(
word,
style: style.copyWith(color: Colors.blueAccent),
),
onTap: () => openVirtualDirectory(context, word),
),
),
);
buff.write(" ");
}
// Simple word
else {
buff.write(word);