mirror of
https://github.com/JGeek00/adguard-home-manager.git
synced 2025-05-04 20:30:35 +00:00
Improvements to add server form
This commit is contained in:
parent
dc229716e0
commit
8ed65579fa
3 changed files with 54 additions and 5 deletions
|
@ -70,5 +70,9 @@
|
||||||
"selectedServer": "Selected server:",
|
"selectedServer": "Selected server:",
|
||||||
"noServerSelected": "No server selected",
|
"noServerSelected": "No server selected",
|
||||||
"manageServer": "Manage server",
|
"manageServer": "Manage server",
|
||||||
"allProtections": "All protections"
|
"allProtections": "All protections",
|
||||||
|
"userNotEmpty": "Username cannot be empty",
|
||||||
|
"passwordNotEmpty": "Password cannot be empty",
|
||||||
|
"examplePath": "Example: /adguard",
|
||||||
|
"helperPath": "If you are using a reverse proxy"
|
||||||
}
|
}
|
|
@ -70,5 +70,9 @@
|
||||||
"selectedServer": "Servidor seleccionado:",
|
"selectedServer": "Servidor seleccionado:",
|
||||||
"noServerSelected": "No hay servidor seleccionado",
|
"noServerSelected": "No hay servidor seleccionado",
|
||||||
"manageServer": "Gestión del servidor",
|
"manageServer": "Gestión del servidor",
|
||||||
"allProtections": "Todas las protecciones"
|
"allProtections": "Todas las protecciones",
|
||||||
|
"userNotEmpty": "Usuario no puede estar vacío",
|
||||||
|
"passwordNotEmpty": "Contraseña no puede estar vacío",
|
||||||
|
"examplePath": "Ejemplo: /adguard",
|
||||||
|
"helperPath": "Si estás usando un reverse proxy"
|
||||||
}
|
}
|
|
@ -43,8 +43,10 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
String? portError;
|
String? portError;
|
||||||
|
|
||||||
final TextEditingController userController = TextEditingController();
|
final TextEditingController userController = TextEditingController();
|
||||||
|
String? userError;
|
||||||
|
|
||||||
final TextEditingController passwordController = TextEditingController();
|
final TextEditingController passwordController = TextEditingController();
|
||||||
|
String? passwordError;
|
||||||
|
|
||||||
bool defaultServer = false;
|
bool defaultServer = false;
|
||||||
|
|
||||||
|
@ -75,15 +77,21 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
required IconData icon,
|
required IconData icon,
|
||||||
TextInputType? keyboardType,
|
TextInputType? keyboardType,
|
||||||
Function(String)? onChanged,
|
Function(String)? onChanged,
|
||||||
|
bool? obscureText,
|
||||||
|
String? hintText,
|
||||||
|
String? helperText
|
||||||
}) {
|
}) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 20),
|
padding: const EdgeInsets.symmetric(horizontal: 20),
|
||||||
child: TextFormField(
|
child: TextFormField(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
|
obscureText: obscureText ?? false,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
prefixIcon: Icon(icon),
|
prefixIcon: Icon(icon),
|
||||||
errorText: error,
|
errorText: error,
|
||||||
|
hintText: hintText,
|
||||||
|
helperText: helperText,
|
||||||
border: const OutlineInputBorder(
|
border: const OutlineInputBorder(
|
||||||
borderRadius: BorderRadius.all(
|
borderRadius: BorderRadius.all(
|
||||||
Radius.circular(10)
|
Radius.circular(10)
|
||||||
|
@ -184,6 +192,34 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
checkDataValid();
|
checkDataValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void validateUser(String? value) {
|
||||||
|
if (value != null && value != '') {
|
||||||
|
setState(() {
|
||||||
|
userError = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setState(() {
|
||||||
|
userError = AppLocalizations.of(context)!.userNotEmpty;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
checkDataValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
void validatePassword(String? value) {
|
||||||
|
if (value != null && value != '') {
|
||||||
|
setState(() {
|
||||||
|
passwordError = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setState(() {
|
||||||
|
passwordError = AppLocalizations.of(context)!.passwordNotEmpty;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
checkDataValid();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
if (widget.server != null) {
|
if (widget.server != null) {
|
||||||
|
@ -432,7 +468,9 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
controller: pathController,
|
controller: pathController,
|
||||||
icon: Icons.route_rounded,
|
icon: Icons.route_rounded,
|
||||||
error: pathError,
|
error: pathError,
|
||||||
onChanged: validateSubroute
|
onChanged: validateSubroute,
|
||||||
|
hintText: AppLocalizations.of(context)!.examplePath,
|
||||||
|
helperText: AppLocalizations.of(context)!.helperPath,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
textField(
|
textField(
|
||||||
|
@ -448,7 +486,8 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
label: AppLocalizations.of(context)!.username,
|
label: AppLocalizations.of(context)!.username,
|
||||||
controller: userController,
|
controller: userController,
|
||||||
icon: Icons.person_rounded,
|
icon: Icons.person_rounded,
|
||||||
onChanged: (_) => checkDataValid()
|
onChanged: validateUser,
|
||||||
|
error: userError
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
textField(
|
textField(
|
||||||
|
@ -456,7 +495,9 @@ class _AddServerModalState extends State<AddServerModal> {
|
||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
icon: Icons.lock_rounded,
|
icon: Icons.lock_rounded,
|
||||||
keyboardType: TextInputType.visiblePassword,
|
keyboardType: TextInputType.visiblePassword,
|
||||||
onChanged: (_) => checkDataValid()
|
onChanged: validatePassword,
|
||||||
|
error: passwordError,
|
||||||
|
obscureText: true
|
||||||
),
|
),
|
||||||
sectionLabel(AppLocalizations.of(context)!.other),
|
sectionLabel(AppLocalizations.of(context)!.other),
|
||||||
Material(
|
Material(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue