mirror of
https://gitlab.com/comunic/comunicmobile
synced 2025-06-19 08:15:16 +00:00
Add references support
This commit is contained in:
@ -22,10 +22,6 @@ import 'login_route.dart';
|
||||
class HomeRoute extends StatefulWidget {
|
||||
@override
|
||||
State<StatefulWidget> createState() => _HomeRouteState();
|
||||
|
||||
/// Get current instance of Home controller
|
||||
static HomeController of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<HomeController>();
|
||||
}
|
||||
|
||||
class CurrPage {
|
||||
@ -45,6 +41,11 @@ class CurrPage {
|
||||
|
||||
/// Public interface of home controller
|
||||
abstract class HomeController extends State<HomeRoute> {
|
||||
|
||||
/// Get current instance of Home controller
|
||||
static HomeController of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<HomeController>();
|
||||
|
||||
/// Open a specific group page specified by its [groupID]
|
||||
void openGroup(int groupID);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class _GroupsListScreenState extends SafeState<GroupsListScreen> {
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.delete),
|
||||
onPressed: () => _deleteGroup(g)),
|
||||
onTap: () => HomeRoute.of(context).openGroup(g.id),
|
||||
onTap: () => HomeController.of(context).openGroup(g.id),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user