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",
|
||||
"updating": "Updating values...",
|
||||
"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",
|
||||
"updating": "Actualizando valores...",
|
||||
"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();
|
||||
String? domainError;
|
||||
|
||||
bool isChecking = false;
|
||||
|
||||
Widget? resultWidget;
|
||||
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
final serversProvider = Provider.of<ServersProvider>(context);
|
||||
|
||||
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') {
|
||||
final status = getFilteredStatus(context, result['data']['reason']);
|
||||
setState(() => resultWidget = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
status['icon'],
|
||||
size: 18,
|
||||
color: status['filtered'] == true
|
||||
? Colors.red
|
||||
: Colors.green,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
status['label'],
|
||||
style: TextStyle(
|
||||
color: status['filtered'] == true
|
||||
? Colors.red
|
||||
: Colors.green,
|
||||
fontWeight: FontWeight.w500
|
||||
),
|
||||
)
|
||||
],
|
||||
));
|
||||
if (result['result'] == 'success') {
|
||||
final status = getFilteredStatus(context, result['data']['reason']);
|
||||
if (mounted) {
|
||||
setState(() => resultWidget = Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
status['icon'],
|
||||
size: 18,
|
||||
color: status['filtered'] == true
|
||||
? Colors.red
|
||||
: Colors.green,
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(
|
||||
status['label'],
|
||||
style: TextStyle(
|
||||
color: status['filtered'] == true
|
||||
? Colors.red
|
||||
: 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(
|
||||
padding: MediaQuery.of(context).viewInsets,
|
||||
child: Stack(
|
||||
children: [
|
||||
AnimatedContainer(
|
||||
height: resultWidget != null
|
||||
? 350
|
||||
: 310,
|
||||
width: double.maxFinite,
|
||||
duration: const Duration(milliseconds: 200),
|
||||
curve: Curves.easeInOut,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(28),
|
||||
topRight: Radius.circular(28),
|
||||
child: Container(
|
||||
height: 350,
|
||||
width: double.maxFinite,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(28),
|
||||
topRight: Radius.circular(28),
|
||||
),
|
||||
color: Theme.of(context).dialogBackgroundColor
|
||||
),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 24),
|
||||
child: Icon(
|
||||
Icons.shield_rounded,
|
||||
size: 26,
|
||||
),
|
||||
),
|
||||
color: Theme.of(context).dialogBackgroundColor
|
||||
),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(top: 24),
|
||||
child: Icon(
|
||||
Icons.shield_rounded,
|
||||
size: 26,
|
||||
const SizedBox(height: 20),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.checkHostFiltered,
|
||||
style: const TextStyle(
|
||||
fontSize: 24
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
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,
|
||||
style: const TextStyle(
|
||||
fontSize: 24
|
||||
),
|
||||
),
|
||||
),
|
||||
if (resultWidget != null) Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 20,
|
||||
left: 20,
|
||||
right: 20
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
Padding(
|
||||
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,
|
||||
child: resultWidget,
|
||||
),
|
||||
),
|
||||
if (resultWidget == null) Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 20,
|
||||
left: 20,
|
||||
right: 20
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.insertDomain,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Theme.of(context).primaryColor
|
||||
),
|
||||
),
|
||||
),
|
||||
if (resultWidget != null) Padding(
|
||||
)
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
top: 20,
|
||||
left: 20,
|
||||
bottom: 20,
|
||||
right: 20
|
||||
),
|
||||
child: resultWidget,
|
||||
),
|
||||
Expanded(
|
||||
child: Column(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(AppLocalizations.of(context)!.close),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
TextButton(
|
||||
onPressed: checkHost,
|
||||
child: Text(AppLocalizations.of(context)!.check),
|
||||
),
|
||||
],
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(AppLocalizations.of(context)!.close),
|
||||
),
|
||||
const SizedBox(width: 20),
|
||||
TextButton(
|
||||
onPressed: domainController.text != '' && domainError == null
|
||||
? () => checkHost()
|
||||
: null,
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.check,
|
||||
style: TextStyle(
|
||||
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