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

@@ -122,7 +122,7 @@ class _RegisterState extends State<Register> {
//print("Here1");
} else if (userCreated["status"] == "FIELD_ERROR") {
Navigator.of(context).pop();
passwordError();
passwordReqError();
} else {
Navigator.of(context).pop();
internetConnectionPopUp();
@@ -162,6 +162,15 @@ class _RegisterState extends State<Register> {
}
void passwordError() {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(errorType: "Password Match");
},
);
}
void passwordReqError() {
showDialog(
context: context,
builder: (context) {
@@ -181,6 +190,21 @@ class _RegisterState extends State<Register> {
);
}
void validateInput() async {
if (emailController.text.isEmpty ||
passwordController.text.isEmpty ||
confirmPasswordController.text.isEmpty) {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(errorType: "Input Error");
},
);
} else {
await signUserUp();
}
}
void toggle() {
setState(() {
_obscureText = !_obscureText;
@@ -195,16 +219,7 @@ class _RegisterState extends State<Register> {
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 signUserUp();
}
validateInput();
}
},
child: Scaffold(
@@ -260,6 +275,7 @@ class _RegisterState extends State<Register> {
controller: passwordController,
hintText: 'Password',
required: true,
signIn: false,
),
),
//spacer
@@ -271,6 +287,7 @@ class _RegisterState extends State<Register> {
controller: confirmPasswordController,
hintText: 'Confirm Password',
required: true,
signIn: false,
),
),
//spacer
@@ -288,18 +305,7 @@ class _RegisterState extends State<Register> {
.theme
.primaryColor(),
onTap: () async {
if (emailController.text.isEmpty ||
passwordController.text.isEmpty) {
showDialog(
context: context,
builder: (context) {
return const MyErrorMessage(
errorType: "Input Error");
},
);
} else {
await signUserUp();
}
validateInput();
},
),
),

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();
},
),
),