1- import 'package:firebase_app_web/Service/Auth_Service.dart' ;
2- import 'package:firebase_app_web/pages/HomePage.dart' ;
31import 'package:flutter/material.dart' ;
42import 'package:flutter_svg/flutter_svg.dart' ;
5- import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;
63
74class SignUpPage extends StatefulWidget {
85 SignUpPage ({Key key}) : super (key: key);
@@ -12,12 +9,6 @@ class SignUpPage extends StatefulWidget {
129}
1310
1411class _SignUpPageState extends State <SignUpPage > {
15- TextEditingController emailController = TextEditingController ();
16- TextEditingController pwdController = TextEditingController ();
17- firebase_auth.FirebaseAuth firebaseAuth = firebase_auth.FirebaseAuth .instance;
18- bool circular = false ;
19- AuthClass authClass = AuthClass ();
20-
2112 @override
2213 Widget build (BuildContext context) {
2314 return Scaffold (
@@ -40,14 +31,11 @@ class _SignUpPageState extends State<SignUpPage> {
4031 SizedBox (
4132 height: 20 ,
4233 ),
43- buttonItem ("assets/google.svg" , "Continue with Google" , 25 ,
44- () async {
45- await authClass.googleSignIn (context);
46- }),
34+ buttonItem ("assets/google.svg" , "Continue with Google" , 25 ),
4735 SizedBox (
4836 height: 15 ,
4937 ),
50- buttonItem ("assets/phone.svg" , "Continue with Mobile" , 30 , () {} ),
38+ buttonItem ("assets/phone.svg" , "Continue with Mobile" , 30 ),
5139 SizedBox (
5240 height: 18 ,
5341 ),
@@ -58,11 +46,11 @@ class _SignUpPageState extends State<SignUpPage> {
5846 SizedBox (
5947 height: 18 ,
6048 ),
61- textItem ("Email...." , emailController, false ),
49+ textItem ("Email...." ),
6250 SizedBox (
6351 height: 15 ,
6452 ),
65- textItem ("Password..." , pwdController, true ),
53+ textItem ("Password..." ),
6654 SizedBox (
6755 height: 40 ,
6856 ),
@@ -98,115 +86,69 @@ class _SignUpPageState extends State<SignUpPage> {
9886 }
9987
10088 Widget colorButton () {
101- return InkWell (
102- onTap: circular
103- ? null
104- : () async {
105- setState (() {
106- circular = true ;
107- });
108- try {
109- firebase_auth.UserCredential userCredential =
110- await firebaseAuth.createUserWithEmailAndPassword (
111- email: emailController.text,
112- password: pwdController.text);
113- print (userCredential.user.email);
114- setState (() {
115- circular = false ;
116- });
117- Navigator .pushAndRemoveUntil (
118- context,
119- MaterialPageRoute (builder: (builder) => HomePage ()),
120- (route) => false );
121- } catch (e) {
122- print (e);
123- setState (() {
124- circular = false ;
125- });
126- final snackBar = SnackBar (content: Text (e.toString ()));
127- ScaffoldMessenger .of (context).showSnackBar (snackBar);
128- }
129- },
130- child: Container (
131- width: MediaQuery .of (context).size.width - 100 ,
132- height: 60 ,
133- decoration: BoxDecoration (
134- borderRadius: BorderRadius .circular (20 ),
135- gradient: LinearGradient (colors: [
136- Color (0xfffd746c ),
137- Color (0xffff9068 ),
138- Color (0xfffd746c )
139- ]),
140- ),
141- child: Center (
142- child: circular
143- ? CircularProgressIndicator ()
144- : Text (
145- "Sign Up" ,
146- style: TextStyle (
147- color: Colors .white,
148- fontSize: 20 ,
149- ),
150- ),
89+ return Container (
90+ width: MediaQuery .of (context).size.width - 100 ,
91+ height: 60 ,
92+ decoration: BoxDecoration (
93+ borderRadius: BorderRadius .circular (20 ),
94+ gradient: LinearGradient (
95+ colors: [Color (0xfffd746c ), Color (0xffff9068 ), Color (0xfffd746c )]),
96+ ),
97+ child: Center (
98+ child: Text (
99+ "Sign Up" ,
100+ style: TextStyle (
101+ color: Colors .white,
102+ fontSize: 20 ,
103+ ),
151104 ),
152105 ),
153106 );
154107 }
155108
156- Widget buttonItem (
157- String imagepath, String buttonName, double size, Function onTap) {
158- return InkWell (
159- onTap: onTap,
160- child: Container (
161- width: MediaQuery .of (context).size.width - 60 ,
162- height: 60 ,
163- child: Card (
164- color: Colors .black,
165- elevation: 8 ,
166- shape: RoundedRectangleBorder (
167- borderRadius: BorderRadius .circular (15 ),
168- side: BorderSide (
169- width: 1 ,
170- color: Colors .grey,
171- ),
109+ Widget buttonItem (String imagepath, String buttonName, double size) {
110+ return Container (
111+ width: MediaQuery .of (context).size.width - 60 ,
112+ height: 60 ,
113+ child: Card (
114+ color: Colors .black,
115+ elevation: 8 ,
116+ shape: RoundedRectangleBorder (
117+ borderRadius: BorderRadius .circular (15 ),
118+ side: BorderSide (
119+ width: 1 ,
120+ color: Colors .grey,
172121 ),
173- child : Row (
174- mainAxisAlignment : MainAxisAlignment .center,
175- children : [
176- SvgPicture . asset (
177- imagepath,
178- height : size ,
179- width : size,
180- ) ,
181- SizedBox (
182- width : 15 ,
183- ) ,
184- Text (
185- buttonName,
186- style : TextStyle (
187- color : Colors .white,
188- fontSize : 17 ,
189- ) ,
122+ ),
123+ child : Row (
124+ mainAxisAlignment : MainAxisAlignment .center,
125+ children : [
126+ SvgPicture . asset (
127+ imagepath ,
128+ height : size,
129+ width : size ,
130+ ),
131+ SizedBox (
132+ width : 15 ,
133+ ),
134+ Text (
135+ buttonName,
136+ style : TextStyle (
137+ color : Colors .white ,
138+ fontSize : 17 ,
190139 ),
191- ] ,
192- ) ,
140+ ) ,
141+ ] ,
193142 ),
194143 ),
195144 );
196145 }
197146
198- Widget textItem (
199- String labeltext, TextEditingController controller, bool obscureText) {
147+ Widget textItem (String labeltext) {
200148 return Container (
201149 width: MediaQuery .of (context).size.width - 70 ,
202150 height: 55 ,
203151 child: TextFormField (
204- obscureText: obscureText,
205- style: TextStyle (
206- fontSize: 17 ,
207- color: Colors .white,
208- ),
209- controller: controller,
210152 decoration: InputDecoration (
211153 labelText: labeltext,
212154 labelStyle: TextStyle (
@@ -220,13 +162,6 @@ class _SignUpPageState extends State<SignUpPage> {
220162 color: Colors .grey,
221163 ),
222164 ),
223- focusedBorder: OutlineInputBorder (
224- borderRadius: BorderRadius .circular (15 ),
225- borderSide: BorderSide (
226- width: 1.5 ,
227- color: Colors .amber,
228- ),
229- ),
230165 ),
231166 ),
232167 );
0 commit comments