-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from fga-eps-mds/fix#59/ajusta-menssagem-regis…
…ter_account fix#59/melhora menssagem de erro e ajusta casos de teste (fga-eps-mds/2024.2-ARANDU-DOC#59)
- Loading branch information
Showing
10 changed files
with
83 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; | |
|
||
class TextEmail extends StatelessWidget{ | ||
|
||
|
||
final String label; | ||
final TextEditingController controller; | ||
final EdgeInsetsGeometry padding; | ||
|
||
|
@@ -11,8 +11,9 @@ class TextEmail extends StatelessWidget{ | |
|
||
const TextEmail ({ | ||
super.key, | ||
this.label = 'E-mail', | ||
required this.padding, | ||
required this.controller | ||
required this.controller, | ||
}); | ||
|
||
|
||
|
@@ -22,12 +23,18 @@ class TextEmail extends StatelessWidget{ | |
return Padding( | ||
padding: padding, | ||
child: TextFormField( | ||
validator: (value) => value == null|| emailRegex.hasMatch(value) ? null : 'E-mail inválido', | ||
validator: (value) { | ||
if (value == null || value.trim().isEmpty) { | ||
return '$label Obrigatório.'; | ||
} else if (!emailRegex.hasMatch(value.trim())) { | ||
return 'Opa, $label inválido!\n(Ex: [email protected])'; | ||
} | ||
return null; | ||
}, | ||
controller: controller, | ||
decoration: InputDecoration ( | ||
prefixIcon: Icon ( Icons.email_outlined, color: Theme.of(context).colorScheme.primary), | ||
labelText: 'E-mail' | ||
), | ||
labelText: label), | ||
), | ||
); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,56 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class TextPassWord extends StatefulWidget { | ||
|
||
final String label; | ||
final TextEditingController controller; | ||
final EdgeInsetsGeometry padding; | ||
|
||
const TextPassWord ({ | ||
super.key, | ||
required this.padding, | ||
required this.controller | ||
const TextPassWord({ | ||
super.key, | ||
this.label = 'Senha', | ||
required this.padding, | ||
required this.controller, | ||
}); | ||
|
||
|
||
@override | ||
State<StatefulWidget> createState() { | ||
return _TextPassWord(); | ||
} | ||
} | ||
} | ||
|
||
|
||
class _TextPassWord extends State<TextPassWord> { | ||
bool _hidePassord = true; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
|
||
return | ||
Padding( | ||
padding: widget.padding, | ||
child: TextFormField( | ||
return Padding( | ||
padding: widget.padding, | ||
child: TextFormField( | ||
validator: (value) { | ||
if (value == null || value.isEmpty || value.length < 8) { | ||
return 'Senha inválida'; | ||
if (value == null || value.isEmpty) { | ||
return '${widget.label} Obrigatória.'; | ||
} else if (value.length < 8) { | ||
return '${widget.label} deve ter no mínimo 8 caracteres.\n(Ex: @abd1234)'; | ||
} | ||
return null; | ||
}, | ||
controller: widget.controller, | ||
obscureText: _hidePassord, | ||
decoration: InputDecoration ( | ||
prefixIcon: Icon ( Icons.lock_outline, color: Theme.of(context).colorScheme.primary), | ||
suffixIcon: GestureDetector ( | ||
onTap: () => setState(() { _hidePassord = !_hidePassord; }), | ||
child: Icon( | ||
_hidePassord ? Icons.visibility_off_outlined : Icons.visibility_outlined, | ||
color: Theme.of(context).colorScheme.primary | ||
) | ||
), | ||
labelText: 'Senha' | ||
), | ||
obscureText: _hidePassord, | ||
decoration: InputDecoration( | ||
prefixIcon: Icon(Icons.lock_outline, | ||
color: Theme.of(context).colorScheme.primary), | ||
suffixIcon: GestureDetector( | ||
onTap: () => setState(() { | ||
_hidePassord = !_hidePassord; | ||
}), | ||
child: Icon( | ||
_hidePassord | ||
? Icons.visibility_off_outlined | ||
: Icons.visibility_outlined, | ||
color: Theme.of(context).colorScheme.primary)), | ||
labelText: widget.label, | ||
), | ||
); | ||
|
||
|
||
} | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,10 @@ void main() { | |
} | ||
|
||
// Teste de validação para diferentes casos | ||
await testEmail("", "E-mail inválido"); // Campo vazio | ||
await testEmail("joaozinhi", "E-mail inválido"); // Sem '@' | ||
await testEmail("joaozinhi@", "E-mail inválido"); // Sem domínio | ||
await testEmail("joao@domain", "E-mail inválido"); // Sem extensão | ||
await testEmail("", "E-mail Obrigatório."); // Campo vazio | ||
await testEmail("joaozinhi", "Opa, E-mail inválido!\n(Ex: [email protected])"); // Sem '@' | ||
await testEmail("joaozinhi@", "Opa, E-mail inválido!\n(Ex: [email protected])"); // Sem domínio | ||
await testEmail("joao@domain", "Opa, E-mail inválido!\n(Ex: [email protected])"); // Sem extensão | ||
await testEmail("[email protected]", null); // Entrada válida | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters