update siugnin and register to cover validations

This commit is contained in:
2024-08-02 10:47:39 +02:00
parent 04f1b31fb2
commit 1d81b36954
2 changed files with 48 additions and 52 deletions

View File

@@ -91,6 +91,22 @@ class _SignInState extends State<SignIn> {
);
}
void validateInput() async {
if (emailController.text.isEmpty || passwordController.text.isEmpty) {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(errorType: "Input Error");
},
);
} else {
await signUserIn();
if (successfulSignIn) {
Navigator.of(context).pushNamed('/home');
}
}
}
@override
Widget build(BuildContext context) {
return KeyboardListener(
@@ -99,19 +115,7 @@ class _SignInState extends State<SignIn> {
onKeyEvent: (event) async {
if (event is KeyDownEvent &&
event.logicalKey == LogicalKeyboardKey.enter) {
if (emailController.text.isEmpty || passwordController.text.isEmpty) {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(errorType: "Input Error");
},
);
} else {
await signUserIn();
if (successfulSignIn) {
Navigator.of(context).pushNamed('/home');
}
}
validateInput();
}
},
child: Scaffold(
@@ -167,6 +171,7 @@ class _SignInState extends State<SignIn> {
controller: passwordController,
hintText: 'Password',
required: true,
signIn: true,
),
),
//spacer
@@ -184,22 +189,7 @@ class _SignInState extends State<SignIn> {
.theme
.primaryColor(),
onTap: () async {
if (emailController.text.isEmpty ||
passwordController.text.isEmpty) {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(
errorType: "Input Error");
},
);
} else {
await signUserIn();
//print(successfulSignIn);
if (successfulSignIn) {
Navigator.of(context).pushNamed('/home');
}
}
validateInput();
},
),
),