diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 673b4c7..2119e09 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -302,5 +302,7 @@ "example2": "Unblocks access to example.org and all its subdomains.", "example3": "Adds a comment.", "example4": "Block access to domains matching the specified regular expression.", - "moreInformation": "More information" + "moreInformation": "More information", + "addingRule": "Adding rule...", + "deletingRule": "Deleting rule..." } \ No newline at end of file diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 28c9693..78f23fe 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -302,5 +302,7 @@ "example2": "Desbloquea el acceso al dominio ejemplo.org y a todos sus subdominios.", "example3": "Añade un comentario.", "example4": "Bloquea el acceso a los dominios que coincidan con la expresión regular especificada.", - "moreInformation": "Más información" + "moreInformation": "Más información", + "addingRule": "Añadiendo regla...", + "deletingRule": "Eliminando regla..." } \ No newline at end of file diff --git a/lib/screens/filters/add_custom_rule.dart b/lib/screens/filters/add_custom_rule.dart index 7320635..d7b660c 100644 --- a/lib/screens/filters/add_custom_rule.dart +++ b/lib/screens/filters/add_custom_rule.dart @@ -24,18 +24,24 @@ class _AddCustomRuleState extends State { final TextEditingController domainController = TextEditingController(); String? domainError; - bool validValues = false; - String preset = "block"; bool addImportant = false; - void checkValidValues() { - if (domainController.text != '') { - setState(() => validValues = true); + bool checkValidValues() { + if ( + domainController.text != '' && + domainError == null && + ( + preset == 'block' || + preset == 'unblock' || + preset == 'custom' + ) + ) { + return true; } else { - setState(() => validValues = false); + return false; } } @@ -47,19 +53,22 @@ class _AddCustomRuleState extends State { else { setState(() => domainError = AppLocalizations.of(context)!.domainNotValid); } + checkValidValues(); } - String buildRule() { + String buildRule({String?value}) { String rule = ""; + + String fieldValue = value ?? domainController.text; if (preset == 'block') { - rule = "||${domainController.text.trim()}^"; + rule = "||${fieldValue.trim()}^"; } else if (preset == 'unblock') { - rule = "@@||${domainController.text.trim()}^"; + rule = "@@||${fieldValue.trim()}^"; } else { - rule = domainController.text.trim(); + rule = fieldValue.trim(); } if (addImportant == true) { @@ -151,7 +160,7 @@ class _AddCustomRuleState extends State { padding: const EdgeInsets.symmetric(horizontal: 28), child: TextFormField( controller: domainController, - onChanged: validateDomain, + onChanged: (value) => setState(() => {}), decoration: InputDecoration( prefixIcon: const Icon(Icons.link_rounded), border: const OutlineInputBorder( @@ -378,16 +387,16 @@ class _AddCustomRuleState extends State { ), const SizedBox(width: 20), TextButton( - onPressed: validValues == true + onPressed: checkValidValues() == true ? () { Navigator.pop(context); - widget.onConfirm(domainController.text); + widget.onConfirm(buildRule()); } : null, child: Text( AppLocalizations.of(context)!.confirm, style: TextStyle( - color: validValues == true + color: checkValidValues() == true ? Theme.of(context).primaryColor : Colors.grey ), diff --git a/lib/screens/filters/custom_rules_list.dart b/lib/screens/filters/custom_rules_list.dart index 77a11d5..255e156 100644 --- a/lib/screens/filters/custom_rules_list.dart +++ b/lib/screens/filters/custom_rules_list.dart @@ -64,7 +64,7 @@ class _CustomRulesListState extends State { void removeCustomRule(String rule) async { ProcessModal processModal = ProcessModal(context: context); - processModal.open(AppLocalizations.of(context)!.updatingRules); + processModal.open(AppLocalizations.of(context)!.deletingRule); final List newRules = serversProvider.filtering.data!.userRules.where((r) => r != rule).toList(); @@ -146,12 +146,16 @@ class _CustomRulesListState extends State { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text( - AppLocalizations.of(context)!.noBlackLists, - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 24, - color: Colors.grey + SizedBox( + width: MediaQuery.of(context).size.width-100, + child: Text( + AppLocalizations.of(context)!.noBlackLists, + textAlign: TextAlign.center, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 24, + color: Colors.grey + ), ), ), const SizedBox(height: 30), diff --git a/lib/screens/filters/fab.dart b/lib/screens/filters/fab.dart index 2c26a70..d61bcc5 100644 --- a/lib/screens/filters/fab.dart +++ b/lib/screens/filters/fab.dart @@ -30,7 +30,7 @@ class FiltersFab extends StatelessWidget { void confirmAddRule(String rule) async { ProcessModal processModal = ProcessModal(context: context); - processModal.open(AppLocalizations.of(context)!.updatingRules); + processModal.open(AppLocalizations.of(context)!.addingRule); final List newRules = serversProvider.filtering.data!.userRules; newRules.add(rule);