mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-06-04 05:40:20 +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,17 +31,33 @@ 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']);
|
||||||
|
if (mounted) {
|
||||||
setState(() => resultWidget = Row(
|
setState(() => resultWidget = Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
@ -67,7 +81,9 @@ class _CheckHostModalState extends State<CheckHostModal> {
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
|
if (mounted) {
|
||||||
setState(() => resultWidget = Row(
|
setState(() => resultWidget = Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
|
@ -87,21 +103,15 @@ class _CheckHostModalState extends State<CheckHostModal> {
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
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(
|
|
||||||
height: resultWidget != null
|
|
||||||
? 350
|
|
||||||
: 310,
|
|
||||||
width: double.maxFinite,
|
width: double.maxFinite,
|
||||||
duration: const Duration(milliseconds: 200),
|
|
||||||
curve: Curves.easeInOut,
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: const BorderRadius.only(
|
borderRadius: const BorderRadius.only(
|
||||||
topLeft: Radius.circular(28),
|
topLeft: Radius.circular(28),
|
||||||
|
@ -144,7 +154,8 @@ class _CheckHostModalState extends State<CheckHostModal> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (resultWidget != null) Padding(
|
if (resultWidget != null) Expanded(
|
||||||
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
top: 20,
|
top: 20,
|
||||||
left: 20,
|
left: 20,
|
||||||
|
@ -152,12 +163,33 @@ class _CheckHostModalState extends State<CheckHostModal> {
|
||||||
),
|
),
|
||||||
child: resultWidget,
|
child: resultWidget,
|
||||||
),
|
),
|
||||||
Expanded(
|
),
|
||||||
child: Column(
|
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
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
),
|
||||||
|
Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.only(
|
||||||
|
bottom: 20,
|
||||||
|
right: 20
|
||||||
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
|
@ -167,56 +199,27 @@ class _CheckHostModalState extends State<CheckHostModal> {
|
||||||
),
|
),
|
||||||
const SizedBox(width: 20),
|
const SizedBox(width: 20),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: checkHost,
|
onPressed: domainController.text != '' && domainError == null
|
||||||
child: Text(AppLocalizations.of(context)!.check),
|
? () => 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