From 45d3f931923f7650ac42bc83339414f90ab5df25 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 16 Apr 2020 12:06:57 +0200 Subject: [PATCH] Add references support --- lib/ui/widgets/text_widget.dart | 7 ++++--- lib/utils/input_utils.dart | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ui/widgets/text_widget.dart b/lib/ui/widgets/text_widget.dart index 43f474a..f1602fa 100644 --- a/lib/ui/widgets/text_widget.dart +++ b/lib/ui/widgets/text_widget.dart @@ -43,7 +43,8 @@ class TextWidget extends StatelessWidget { } /// Sub parse function - List _parseLinks(BuildContext context, String text, TextStyle style) { + List _parseLinks( + BuildContext context, String text, TextStyle style) { var buff = StringBuffer(); final list = new List(); @@ -79,8 +80,8 @@ class TextWidget extends StatelessWidget { buff.write(" "); } - // Check if it is a user reference - else if(validateUserReference(word)) { + // Check if it is a directory reference + else if (validateDirectoryReference(word)) { changeWordType(); list.add( diff --git a/lib/utils/input_utils.dart b/lib/utils/input_utils.dart index 9ec1fab..bf88238 100644 --- a/lib/utils/input_utils.dart +++ b/lib/utils/input_utils.dart @@ -28,6 +28,6 @@ bool validateUrl(String url) { } } -/// Validate user reference -bool validateUserReference(String ref) => +/// Validate directory reference +bool validateDirectoryReference(String ref) => RegExp(r'@[a-zA-Z0-9]+').hasMatch(ref);