mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-06-02 12:52:18 +00:00
Improved check host modal
This commit is contained in:
parent
5d908549e1
commit
568f2ea4d7
3 changed files with 162 additions and 157 deletions
|
@ -324,5 +324,6 @@
|
||||||
"updateFrequencyNotChanged": "Updare frecuency couldn't be changed",
|
"updateFrequencyNotChanged": "Updare frecuency couldn't be changed",
|
||||||
"updating": "Updating values...",
|
"updating": "Updating values...",
|
||||||
"blockedServicesUpdated": "Blocked services updated successfully",
|
"blockedServicesUpdated": "Blocked services updated successfully",
|
||||||
"blockedServicesNotUpdated": "Blocked services couldn't be updated"
|
"blockedServicesNotUpdated": "Blocked services couldn't be updated",
|
||||||
|
"insertDomain": "Insert a domain to check it's stauts."
|
||||||
}
|
}
|
|
@ -324,5 +324,6 @@
|
||||||
"updateFrequencyNotChanged": "La frecuencia de actualización no pudo ser cambiada",
|
"updateFrequencyNotChanged": "La frecuencia de actualización no pudo ser cambiada",
|
||||||
"updating": "Actualizando valores...",
|
"updating": "Actualizando valores...",
|
||||||
"blockedServicesUpdated": "Servicios bloqueados actualizados correctamente",
|
"blockedServicesUpdated": "Servicios bloqueados actualizados correctamente",
|
||||||
"blockedServicesNotUpdated": "No se pudieron actualizar los servicios bloqueados"
|
"blockedServicesNotUpdated": "No se pudieron actualizar los servicios bloqueados",
|
||||||
|
"insertDomain": "Inserta un dominio para comprobar su estado,"
|
||||||
}
|
}
|
|
@ -19,8 +19,6 @@ class _CheckHostModalState extends State<CheckHostModal> {
|
||||||
final TextEditingController domainController = TextEditingController();
|
final TextEditingController domainController = TextEditingController();
|
||||||
String? domainError;
|
String? domainError;
|
||||||
|
|
||||||
bool isChecking = false;
|
|
||||||
|
|
||||||
Widget? resultWidget;
|
Widget? resultWidget;
|
||||||
|
|
||||||
void validateDomain(String value) {
|
void validateDomain(String value) {
|
||||||
|
@ -33,189 +31,194 @@ class _CheckHostModalState extends State<CheckHostModal> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget checking() {
|
||||||
|
return SizedBox(
|
||||||
|
height: 30,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const CircularProgressIndicator(),
|
||||||
|
const SizedBox(width: 20),
|
||||||
|
Text(AppLocalizations.of(context)!.checkingHost)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final serversProvider = Provider.of<ServersProvider>(context);
|
final serversProvider = Provider.of<ServersProvider>(context);
|
||||||
|
|
||||||
void checkHost() async {
|
void checkHost() async {
|
||||||
setState(() => isChecking = true);
|
if (mounted) {
|
||||||
|
setState(() => resultWidget = checking());
|
||||||
|
|
||||||
final result = await checkHostFiltered(server: serversProvider.selectedServer!, host: domainController.text);
|
final result = await checkHostFiltered(server: serversProvider.selectedServer!, host: domainController.text);
|
||||||
|
|
||||||
if (result['result'] == 'success') {
|
if (result['result'] == 'success') {
|
||||||
final status = getFilteredStatus(context, result['data']['reason']);
|
final status = getFilteredStatus(context, result['data']['reason']);
|
||||||
setState(() => resultWidget = Row(
|
if (mounted) {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
setState(() => resultWidget = Row(
|
||||||
children: [
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
Icon(
|
children: [
|
||||||
status['icon'],
|
Icon(
|
||||||
size: 18,
|
status['icon'],
|
||||||
color: status['filtered'] == true
|
size: 18,
|
||||||
? Colors.red
|
color: status['filtered'] == true
|
||||||
: Colors.green,
|
? Colors.red
|
||||||
),
|
: Colors.green,
|
||||||
const SizedBox(width: 10),
|
),
|
||||||
Text(
|
const SizedBox(width: 10),
|
||||||
status['label'],
|
Text(
|
||||||
style: TextStyle(
|
status['label'],
|
||||||
color: status['filtered'] == true
|
style: TextStyle(
|
||||||
? Colors.red
|
color: status['filtered'] == true
|
||||||
: Colors.green,
|
? Colors.red
|
||||||
fontWeight: FontWeight.w500
|
: Colors.green,
|
||||||
),
|
fontWeight: FontWeight.w500
|
||||||
)
|
),
|
||||||
],
|
)
|
||||||
));
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (mounted) {
|
||||||
|
setState(() => resultWidget = Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
const Icon(
|
||||||
|
Icons.cancel,
|
||||||
|
size: 18,
|
||||||
|
color: Colors.red,
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Text(
|
||||||
|
AppLocalizations.of(context)!.check,
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.red,
|
||||||
|
fontWeight: FontWeight.w500
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
setState(() => resultWidget = Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const Icon(
|
|
||||||
Icons.cancel,
|
|
||||||
size: 18,
|
|
||||||
color: Colors.red,
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context)!.check,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.red,
|
|
||||||
fontWeight: FontWeight.w500
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
setState(() => isChecking = false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: MediaQuery.of(context).viewInsets,
|
padding: MediaQuery.of(context).viewInsets,
|
||||||
child: Stack(
|
child: Container(
|
||||||
children: [
|
height: 350,
|
||||||
AnimatedContainer(
|
width: double.maxFinite,
|
||||||
height: resultWidget != null
|
decoration: BoxDecoration(
|
||||||
? 350
|
borderRadius: const BorderRadius.only(
|
||||||
: 310,
|
topLeft: Radius.circular(28),
|
||||||
width: double.maxFinite,
|
topRight: Radius.circular(28),
|
||||||
duration: const Duration(milliseconds: 200),
|
),
|
||||||
curve: Curves.easeInOut,
|
color: Theme.of(context).dialogBackgroundColor
|
||||||
decoration: BoxDecoration(
|
),
|
||||||
borderRadius: const BorderRadius.only(
|
child: Center(
|
||||||
topLeft: Radius.circular(28),
|
child: Column(
|
||||||
topRight: Radius.circular(28),
|
children: [
|
||||||
|
const Padding(
|
||||||
|
padding: EdgeInsets.only(top: 24),
|
||||||
|
child: Icon(
|
||||||
|
Icons.shield_rounded,
|
||||||
|
size: 26,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
color: Theme.of(context).dialogBackgroundColor
|
const SizedBox(height: 20),
|
||||||
),
|
Text(
|
||||||
child: Center(
|
AppLocalizations.of(context)!.checkHostFiltered,
|
||||||
child: Column(
|
style: const TextStyle(
|
||||||
children: [
|
fontSize: 24
|
||||||
const Padding(
|
),
|
||||||
padding: EdgeInsets.only(top: 24),
|
),
|
||||||
child: Icon(
|
const SizedBox(height: 30),
|
||||||
Icons.shield_rounded,
|
Padding(
|
||||||
size: 26,
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
|
child: TextFormField(
|
||||||
|
controller: domainController,
|
||||||
|
onChanged: validateDomain,
|
||||||
|
decoration: InputDecoration(
|
||||||
|
prefixIcon: const Icon(Icons.link_rounded),
|
||||||
|
border: const OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.all(
|
||||||
|
Radius.circular(10)
|
||||||
|
)
|
||||||
),
|
),
|
||||||
|
errorText: domainError,
|
||||||
|
labelText: AppLocalizations.of(context)!.domain,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
),
|
||||||
Text(
|
),
|
||||||
AppLocalizations.of(context)!.checkHostFiltered,
|
if (resultWidget != null) Expanded(
|
||||||
style: const TextStyle(
|
child: Padding(
|
||||||
fontSize: 24
|
padding: const EdgeInsets.only(
|
||||||
),
|
top: 20,
|
||||||
|
left: 20,
|
||||||
|
right: 20
|
||||||
),
|
),
|
||||||
const SizedBox(height: 30),
|
child: resultWidget,
|
||||||
Padding(
|
),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
),
|
||||||
child: TextFormField(
|
if (resultWidget == null) Expanded(
|
||||||
controller: domainController,
|
child: Padding(
|
||||||
onChanged: validateDomain,
|
padding: const EdgeInsets.only(
|
||||||
decoration: InputDecoration(
|
top: 20,
|
||||||
prefixIcon: const Icon(Icons.link_rounded),
|
left: 20,
|
||||||
border: const OutlineInputBorder(
|
right: 20
|
||||||
borderRadius: BorderRadius.all(
|
),
|
||||||
Radius.circular(10)
|
child: Center(
|
||||||
)
|
child: Text(
|
||||||
),
|
AppLocalizations.of(context)!.insertDomain,
|
||||||
errorText: domainError,
|
style: TextStyle(
|
||||||
labelText: AppLocalizations.of(context)!.domain,
|
fontSize: 16,
|
||||||
|
color: Theme.of(context).primaryColor
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (resultWidget != null) Padding(
|
)
|
||||||
|
),
|
||||||
|
Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
top: 20,
|
bottom: 20,
|
||||||
left: 20,
|
|
||||||
right: 20
|
right: 20
|
||||||
),
|
),
|
||||||
child: resultWidget,
|
child: Row(
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
TextButton(
|
||||||
padding: const EdgeInsets.all(20),
|
onPressed: () => Navigator.pop(context),
|
||||||
child: Row(
|
child: Text(AppLocalizations.of(context)!.close),
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
),
|
||||||
children: [
|
const SizedBox(width: 20),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: domainController.text != '' && domainError == null
|
||||||
child: Text(AppLocalizations.of(context)!.close),
|
? () => checkHost()
|
||||||
),
|
: null,
|
||||||
const SizedBox(width: 20),
|
child: Text(
|
||||||
TextButton(
|
AppLocalizations.of(context)!.check,
|
||||||
onPressed: checkHost,
|
style: TextStyle(
|
||||||
child: Text(AppLocalizations.of(context)!.check),
|
color: domainController.text != '' && domainError == null
|
||||||
),
|
? Theme.of(context).primaryColor
|
||||||
],
|
: Colors.grey
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
)
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
AnimatedOpacity(
|
),
|
||||||
opacity: isChecking == true ? 1 : 0,
|
|
||||||
duration: const Duration(milliseconds: 250),
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
child: IgnorePointer(
|
|
||||||
ignoring: isChecking == true ? false : true,
|
|
||||||
child: Container(
|
|
||||||
height: 310,
|
|
||||||
width: double.maxFinite,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
borderRadius: const BorderRadius.only(
|
|
||||||
topLeft: Radius.circular(28),
|
|
||||||
topRight: Radius.circular(28),
|
|
||||||
),
|
|
||||||
color: Colors.black.withOpacity(0.8)
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
const CircularProgressIndicator(
|
|
||||||
color: Colors.white,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 30),
|
|
||||||
Text(
|
|
||||||
AppLocalizations.of(context)!.checkingHost,
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontSize: 22
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue