update siugnin and register to cover validations
This commit is contained in:
@@ -122,7 +122,7 @@ class _RegisterState extends State<Register> {
|
|||||||
//print("Here1");
|
//print("Here1");
|
||||||
} else if (userCreated["status"] == "FIELD_ERROR") {
|
} else if (userCreated["status"] == "FIELD_ERROR") {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
passwordError();
|
passwordReqError();
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
internetConnectionPopUp();
|
internetConnectionPopUp();
|
||||||
@@ -162,6 +162,15 @@ class _RegisterState extends State<Register> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void passwordError() {
|
void passwordError() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) {
|
||||||
|
return const MyErrorMessage(errorType: "Password Match");
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void passwordReqError() {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (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() {
|
void toggle() {
|
||||||
setState(() {
|
setState(() {
|
||||||
_obscureText = !_obscureText;
|
_obscureText = !_obscureText;
|
||||||
@@ -195,16 +219,7 @@ class _RegisterState extends State<Register> {
|
|||||||
onKeyEvent: (event) async {
|
onKeyEvent: (event) async {
|
||||||
if (event is KeyDownEvent &&
|
if (event is KeyDownEvent &&
|
||||||
event.logicalKey == LogicalKeyboardKey.enter) {
|
event.logicalKey == LogicalKeyboardKey.enter) {
|
||||||
if (emailController.text.isEmpty || passwordController.text.isEmpty) {
|
validateInput();
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return const MyErrorMessage(errorType: "Input Error");
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await signUserUp();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@@ -260,6 +275,7 @@ class _RegisterState extends State<Register> {
|
|||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
hintText: 'Password',
|
hintText: 'Password',
|
||||||
required: true,
|
required: true,
|
||||||
|
signIn: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
//spacer
|
//spacer
|
||||||
@@ -271,6 +287,7 @@ class _RegisterState extends State<Register> {
|
|||||||
controller: confirmPasswordController,
|
controller: confirmPasswordController,
|
||||||
hintText: 'Confirm Password',
|
hintText: 'Confirm Password',
|
||||||
required: true,
|
required: true,
|
||||||
|
signIn: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
//spacer
|
//spacer
|
||||||
@@ -288,18 +305,7 @@ class _RegisterState extends State<Register> {
|
|||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (emailController.text.isEmpty ||
|
validateInput();
|
||||||
passwordController.text.isEmpty) {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return const MyErrorMessage(
|
|
||||||
errorType: "Input Error");
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await signUserUp();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return KeyboardListener(
|
return KeyboardListener(
|
||||||
@@ -99,19 +115,7 @@ class _SignInState extends State<SignIn> {
|
|||||||
onKeyEvent: (event) async {
|
onKeyEvent: (event) async {
|
||||||
if (event is KeyDownEvent &&
|
if (event is KeyDownEvent &&
|
||||||
event.logicalKey == LogicalKeyboardKey.enter) {
|
event.logicalKey == LogicalKeyboardKey.enter) {
|
||||||
if (emailController.text.isEmpty || passwordController.text.isEmpty) {
|
validateInput();
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return const MyErrorMessage(errorType: "Input Error");
|
|
||||||
},
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
await signUserIn();
|
|
||||||
if (successfulSignIn) {
|
|
||||||
Navigator.of(context).pushNamed('/home');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
@@ -167,6 +171,7 @@ class _SignInState extends State<SignIn> {
|
|||||||
controller: passwordController,
|
controller: passwordController,
|
||||||
hintText: 'Password',
|
hintText: 'Password',
|
||||||
required: true,
|
required: true,
|
||||||
|
signIn: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
//spacer
|
//spacer
|
||||||
@@ -184,22 +189,7 @@ class _SignInState extends State<SignIn> {
|
|||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
if (emailController.text.isEmpty ||
|
validateInput();
|
||||||
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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user