mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-16 23:12:50 +00:00
Added type of rule on custom rules
This commit is contained in:
parent
8ff0edfab2
commit
a0c66f13f2
1 changed files with 35 additions and 0 deletions
|
@ -115,6 +115,40 @@ class _CustomRulesListState extends State<CustomRulesList> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
switch (widget.loadStatus) {
|
||||||
case 0:
|
case 0:
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
|
@ -153,6 +187,7 @@ class _CustomRulesListState extends State<CustomRulesList> {
|
||||||
fontWeight: FontWeight.normal,
|
fontWeight: FontWeight.normal,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
subtitle: generateSubtitle(widget.data[index]),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
onPressed: () => openRemoveCustomRuleModal(widget.data[index]),
|
onPressed: () => openRemoveCustomRuleModal(widget.data[index]),
|
||||||
icon: const Icon(Icons.delete)
|
icon: const Icon(Icons.delete)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue