open profiles when clicking a link that starts with @
This commit is contained in:
parent
756deea82c
commit
95cecbed9c
|
@ -1,7 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||||
import 'package:html2md/html2md.dart' as html2md;
|
import 'package:html2md/html2md.dart' as html2md;
|
||||||
|
import 'package:localization/localization.dart';
|
||||||
|
import 'package:loris/dialogues/profile_view.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
import '../business_logic/account/account.dart' as account;
|
||||||
|
|
||||||
class PostTextRenderer extends StatelessWidget {
|
class PostTextRenderer extends StatelessWidget {
|
||||||
const PostTextRenderer({
|
const PostTextRenderer({
|
||||||
|
@ -42,8 +45,18 @@ class PostTextRenderer extends StatelessWidget {
|
||||||
|
|
||||||
String s = html2md.convert(input);
|
String s = html2md.convert(input);
|
||||||
return MarkdownBody(
|
return MarkdownBody(
|
||||||
onTapLink: ((text, href, title) {
|
onTapLink: ((text, href, title) async {
|
||||||
if (href != null) {
|
if (href != null) {
|
||||||
|
if (text.startsWith("@")) {
|
||||||
|
final result = await account.searchModel(identityName, href);
|
||||||
|
if (result.keys.first == 200) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => ProfileView(model: result.values.first!),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
launchUrl(Uri.parse(href));
|
launchUrl(Uri.parse(href));
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue