From a0c66f13f2acdb0cb341f893fd866d2cb6045387 Mon Sep 17 00:00:00 2001 From: Juan Gilsanz Polo Date: Sat, 31 Dec 2022 17:51:28 +0100 Subject: [PATCH] Added type of rule on custom rules --- lib/screens/filters/custom_rules_list.dart | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lib/screens/filters/custom_rules_list.dart b/lib/screens/filters/custom_rules_list.dart index b40ebb7..09d0925 100644 --- a/lib/screens/filters/custom_rules_list.dart +++ b/lib/screens/filters/custom_rules_list.dart @@ -115,6 +115,40 @@ class _CustomRulesListState extends State { } } + Widget? generateSubtitle(String rule) { + final allowRegex = RegExp(r'^@@.*$'); + final blockRegex = RegExp(r'^\|\|.*$'); + final commentRegex = RegExp(r'^(#|!).*$'); + + if (allowRegex.hasMatch(rule)) { + return Text( + AppLocalizations.of(context)!.allowed, + style: const TextStyle( + color: Colors.green + ), + ); + } + else if (blockRegex.hasMatch(rule)) { + return Text( + AppLocalizations.of(context)!.blocked, + style: const TextStyle( + color: Colors.red + ), + ); + } + else if (commentRegex.hasMatch(rule)) { + return Text( + AppLocalizations.of(context)!.comment, + style: const TextStyle( + color: Colors.grey + ), + ); + } + else { + return null; + } + } + switch (widget.loadStatus) { case 0: return SizedBox( @@ -153,6 +187,7 @@ class _CustomRulesListState extends State { fontWeight: FontWeight.normal, ), ), + subtitle: generateSubtitle(widget.data[index]), trailing: IconButton( onPressed: () => openRemoveCustomRuleModal(widget.data[index]), icon: const Icon(Icons.delete)