Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/form_validation'
Browse files Browse the repository at this point in the history
# Conflicts:
#	lib/auth/signin.dart
  • Loading branch information
Furqankhanzada committed Oct 21, 2019
2 parents b68e8b7 + 481ea31 commit 5444b4c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 14 deletions.
34 changes: 21 additions & 13 deletions lib/auth/signin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,25 @@ class _SignInState extends State<SignIn> {
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Please Enter Email or Username';
}
return null;
},
decoration: InputDecoration(
hintText: 'Enter Username Or Email',
labelText: 'Email',
),
),
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Please Enter Password';
}
return null;
},
decoration: InputDecoration(
hintText: 'Enter Password',
labelText: 'Password',
Expand All @@ -45,19 +57,15 @@ class _SignInState extends State<SignIn> {
child: SizedBox(
width: double.infinity,
height: 50,
child: Consumer<AuthBlock>(
builder: (context, auth, child) {
return RaisedButton(
color: Colors.deepOrange,
textColor: Colors.white,
child: Text(auth.loading ? 'Loading...' : 'Sign In'),
onPressed: () {
auth.loading = true;
final t = Timer(Duration(seconds: 3), () {
auth.loading = false;
});
},
);
child: RaisedButton(
color: Colors.deepOrange,
textColor: Colors.white,
child: Text('Sign In'),
onPressed: (){
if (_formKey.currentState.validate()) {
// If the form is valid, display a snackbar. In the real world,
// you'd often call a server or save the information in a database.
}
},
),
),
Expand Down
29 changes: 28 additions & 1 deletion lib/auth/signup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class _SignUpState extends State<SignUp> {
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Please Enter Username';
}
return null;
},
decoration: InputDecoration(
hintText: 'Enter Username',
labelText: 'Username',
Expand All @@ -30,6 +36,12 @@ class _SignUpState extends State<SignUp> {
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Please Enter Email Address';
}
return null;
},
decoration: InputDecoration(
hintText: 'Enter Email',
labelText: 'Email',
Expand All @@ -39,6 +51,12 @@ class _SignUpState extends State<SignUp> {
Padding(
padding: const EdgeInsets.only(bottom: 12.0),
child: TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Please Enter Password';
}
return null;
},
decoration: InputDecoration(
hintText: 'Enter Password',
labelText: 'Password',
Expand All @@ -47,6 +65,12 @@ class _SignUpState extends State<SignUp> {
),
),
TextFormField(
validator: (value) {
if (value.isEmpty) {
return 'Please Enter Confirm Password';
}
return null;
},
decoration: InputDecoration(
hintText: 'Enter Same Password',
labelText: 'Confirm Password',
Expand All @@ -63,7 +87,10 @@ class _SignUpState extends State<SignUp> {
textColor: Colors.white,
child: Text('Sign Up'),
onPressed: (){

if (_formKey.currentState.validate()) {
// If the form is valid, display a snackbar. In the real world,
// you'd often call a server or save the information in a database.
}
},
),
),
Expand Down

0 comments on commit 5444b4c

Please sign in to comment.