@@ -5,9 +5,11 @@ import 'package:flutter_twitter_clone/helper/enum.dart';
5
5
import 'package:flutter_twitter_clone/helper/theme.dart' ;
6
6
import 'package:flutter_twitter_clone/helper/utility.dart' ;
7
7
import 'package:flutter_twitter_clone/model/user.dart' ;
8
+ import 'package:flutter_twitter_clone/page/Auth/widget/googleLoginButton.dart' ;
8
9
import 'package:flutter_twitter_clone/state/authState.dart' ;
9
10
import 'package:flutter_twitter_clone/widgets/customWidgets.dart' ;
10
11
import 'package:flutter_twitter_clone/widgets/newWidget/customLoader.dart' ;
12
+ import 'package:flutter_twitter_clone/widgets/newWidget/rippleButton.dart' ;
11
13
import 'package:flutter_twitter_clone/widgets/newWidget/title_text.dart' ;
12
14
import 'package:provider/provider.dart' ;
13
15
@@ -22,7 +24,6 @@ class Signup extends StatefulWidget {
22
24
class _SignupState extends State <Signup > {
23
25
TextEditingController _nameController;
24
26
TextEditingController _emailController;
25
- // TextEditingController _mobileController;
26
27
TextEditingController _passwordController;
27
28
TextEditingController _confirmController;
28
29
CustomLoader loader;
@@ -33,18 +34,17 @@ class _SignupState extends State<Signup> {
33
34
loader = CustomLoader ();
34
35
_nameController = TextEditingController ();
35
36
_emailController = TextEditingController ();
36
- // _mobileController = TextEditingController();
37
37
_passwordController = TextEditingController ();
38
38
_confirmController = TextEditingController ();
39
- // _emailController.text = '[email protected] ';
40
- // _passwordController.text = '1234567';
41
- // _nameController.text = 'Bruce Wayne';
42
- // _mobileController.text = '9871234567';
43
- // _passwordController.text = '1234567';
44
- // _confirmController.text = '1234567';
45
39
super .initState ();
46
40
}
47
-
41
+ void dispose () {
42
+ _emailController.dispose ();
43
+ _passwordController.dispose ();
44
+ _nameController.dispose ();
45
+ _confirmController.dispose ();
46
+ super .dispose ();
47
+ }
48
48
Widget _body (BuildContext context) {
49
49
return Container (
50
50
height: fullHeight (context) - 88 ,
@@ -64,8 +64,14 @@ class _SignupState extends State<Signup> {
64
64
controller: _confirmController, isPassword: true ),
65
65
_submitButton (context),
66
66
67
- Divider (),
68
- _googleLoginButton (context)
67
+ Divider (height: 30 ),
68
+ SizedBox (height: 30 ),
69
+ // _googleLoginButton(context),
70
+ GoogleLoginButton (
71
+ loginCallback: widget.loginCallback,
72
+ loader: loader,
73
+ ),
74
+ SizedBox (height: 30 ),
69
75
],
70
76
),
71
77
),
@@ -117,41 +123,34 @@ class _SignupState extends State<Signup> {
117
123
);
118
124
}
119
125
120
- Widget _googleLoginButton (BuildContext context) {
121
- return Container (
122
- alignment: Alignment .center,
123
- margin: EdgeInsets .symmetric (vertical: 35 ),
124
- child: Row (
125
- mainAxisAlignment: MainAxisAlignment .center,
126
- children: < Widget > [
127
- MaterialButton (
128
- elevation: 2 ,
129
- shape:
130
- RoundedRectangleBorder (borderRadius: BorderRadius .circular (10 )),
131
- color: Colors .white,
132
- onPressed: _googleLogin,
133
- padding: EdgeInsets .symmetric (horizontal: 30 , vertical: 10 ),
134
- child: Row (
135
- children: < Widget > [
136
- Image .asset (
137
- 'assets/images/google_logo.png' ,
138
- height: 20 ,
139
- width: 20 ,
140
- ),
141
- SizedBox (width: 10 ),
142
- TitleText (
143
- 'Continue with Google' ,
144
- color: Colors .black54,
145
- ),
146
- ],
147
- ),
148
- ),
149
- ],
150
- ),
151
- );
126
+ void _googleLogin () {
127
+ var state = Provider .of <AuthState >(context, listen: false );
128
+ if (state.isbusy) {
129
+ return ;
130
+ }
131
+ loader.showLoader (context);
132
+ state.handleGoogleSignIn ().then ((status) {
133
+ // print(status)
134
+ if (state.user != null ) {
135
+ loader.hideLoader ();
136
+ Navigator .pop (context);
137
+ widget.loginCallback ();
138
+ } else {
139
+ loader.hideLoader ();
140
+ cprint ('Unable to login' , errorIn: '_googleLoginButton' );
141
+ }
142
+ });
152
143
}
153
144
154
145
void _submitForm () {
146
+ if (_emailController.text.isEmpty) {
147
+ customSnackBar (_scaffoldKey, 'Please enter name' );
148
+ return ;
149
+ }
150
+ if (_emailController.text.length > 27 ) {
151
+ customSnackBar (_scaffoldKey, 'Name length cannot exceed 27 character' );
152
+ return ;
153
+ }
155
154
if (_emailController.text == null ||
156
155
_emailController.text.isEmpty ||
157
156
_passwordController.text == null ||
@@ -164,6 +163,7 @@ class _SignupState extends State<Signup> {
164
163
_scaffoldKey, 'Password and confirm password did not match' );
165
164
return ;
166
165
}
166
+
167
167
loader.showLoader (context);
168
168
var state = Provider .of <AuthState >(context, listen: false );
169
169
Random random = new Random ();
@@ -199,25 +199,6 @@ class _SignupState extends State<Signup> {
199
199
);
200
200
}
201
201
202
- void _googleLogin () {
203
- var state = Provider .of <AuthState >(context,listen: false );
204
- if (state.isbusy) {
205
- return ;
206
- }
207
- loader.showLoader (context);
208
- state.handleGoogleSignIn ().then ((status) {
209
- // print(status)
210
- if (state.user != null ) {
211
- loader.hideLoader ();
212
- Navigator .pop (context);
213
- widget.loginCallback ();
214
- } else {
215
- loader.hideLoader ();
216
- cprint ('Unable to login' , errorIn: '_googleLoginButton' );
217
- }
218
- });
219
- }
220
-
221
202
@override
222
203
Widget build (BuildContext context) {
223
204
return Scaffold (
0 commit comments