1+ import  'package:firebase_app_web/Service/Auth_Service.dart' ;
2+ import  'package:firebase_app_web/pages/HomePage.dart' ;
13import  'package:flutter/material.dart' ;
24import  'package:flutter_svg/flutter_svg.dart' ;
5+ import  'package:firebase_auth/firebase_auth.dart'  as  firebase_auth;
36
47class  SignUpPage  extends  StatefulWidget  {
58 SignUpPage ({Key  key}) :  super (key:  key);
@@ -9,6 +12,12 @@ class SignUpPage extends StatefulWidget {
912}
1013
1114class  _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+ 
1221 @override 
1322 Widget  build (BuildContext  context) {
1423 return  Scaffold (
@@ -31,11 +40,14 @@ class _SignUpPageState extends State<SignUpPage> {
3140 SizedBox (
3241 height:  20 ,
3342 ),
34-  buttonItem ("assets/google.svg" , "Continue with Google" , 25 ),
43+  buttonItem ("assets/google.svg" , "Continue with Google" , 25 ,
44+  () async  {
45+  await  authClass.googleSignIn (context);
46+  }),
3547 SizedBox (
3648 height:  15 ,
3749 ),
38-  buttonItem ("assets/phone.svg" , "Continue with Mobile" , 30 ),
50+  buttonItem ("assets/phone.svg" , "Continue with Mobile" , 30 , () {} ),
3951 SizedBox (
4052 height:  18 ,
4153 ),
@@ -46,11 +58,11 @@ class _SignUpPageState extends State<SignUpPage> {
4658 SizedBox (
4759 height:  18 ,
4860 ),
49-  textItem ("Email...." ),
61+  textItem ("Email...." , emailController,  false ),
5062 SizedBox (
5163 height:  15 ,
5264 ),
53-  textItem ("Password..." ),
65+  textItem ("Password..." , pwdController,  true ),
5466 SizedBox (
5567 height:  40 ,
5668 ),
@@ -86,69 +98,115 @@ class _SignUpPageState extends State<SignUpPage> {
8698 }
8799
88100 Widget  colorButton () {
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-  ),
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+  ),
104151 ),
105152 ),
106153 );
107154 }
108155
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,
121-  ),
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 ,
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,
133171 ),
134-  Text (
135-  buttonName,
136-  style:  TextStyle (
137-  color:  Colors .white,
138-  fontSize:  17 ,
172+  ),
173+  child:  Row (
174+  mainAxisAlignment:  MainAxisAlignment .center,
175+  children:  [
176+  SvgPicture .asset (
177+  imagepath,
178+  height:  size,
179+  width:  size,
139180 ),
140-  ),
141-  ],
181+  SizedBox (
182+  width:  15 ,
183+  ),
184+  Text (
185+  buttonName,
186+  style:  TextStyle (
187+  color:  Colors .white,
188+  fontSize:  17 ,
189+  ),
190+  ),
191+  ],
192+  ),
142193 ),
143194 ),
144195 );
145196 }
146197
147-  Widget  textItem (String  labeltext) {
198+  Widget  textItem (
199+  String  labeltext, TextEditingController  controller, bool  obscureText) {
148200 return  Container (
149201 width:  MediaQuery .of (context).size.width -  70 ,
150202 height:  55 ,
151203 child:  TextFormField (
204+  obscureText:  obscureText,
205+  style:  TextStyle (
206+  fontSize:  17 ,
207+  color:  Colors .white,
208+  ),
209+  controller:  controller,
152210 decoration:  InputDecoration (
153211 labelText:  labeltext,
154212 labelStyle:  TextStyle (
@@ -162,6 +220,13 @@ class _SignUpPageState extends State<SignUpPage> {
162220 color:  Colors .grey,
163221 ),
164222 ),
223+  focusedBorder:  OutlineInputBorder (
224+  borderRadius:  BorderRadius .circular (15 ),
225+  borderSide:  BorderSide (
226+  width:  1.5 ,
227+  color:  Colors .amber,
228+  ),
229+  ),
165230 ),
166231 ),
167232 );
0 commit comments