Skip to content

Commit ba075b5

Browse files
committed
Merge branch 'master' into youtube
2 parents 48c992f + b54d90e commit ba075b5

File tree

2 files changed

+313
-24
lines changed

2 files changed

+313
-24
lines changed

lib/pages/SignInPage.dart

Lines changed: 83 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import 'package:firebase_app_web/pages/SignUpPage.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flutter_svg/flutter_svg.dart';
4+
import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;
5+
6+
import 'HomePage.dart';
37

48
class SignInPage extends StatefulWidget {
59
SignInPage({Key key}) : super(key: key);
@@ -9,6 +13,11 @@ class SignInPage extends StatefulWidget {
913
}
1014

1115
class _SignInPageState extends State<SignInPage> {
16+
firebase_auth.FirebaseAuth firebaseAuth = firebase_auth.FirebaseAuth.instance;
17+
TextEditingController _emailController = TextEditingController();
18+
TextEditingController _pwdController = TextEditingController();
19+
bool circular = false;
20+
1221
@override
1322
Widget build(BuildContext context) {
1423
return Scaffold(
@@ -46,11 +55,11 @@ class _SignInPageState extends State<SignInPage> {
4655
SizedBox(
4756
height: 18,
4857
),
49-
textItem("Email...."),
58+
textItem("Email....", _emailController, false),
5059
SizedBox(
5160
height: 15,
5261
),
53-
textItem("Password..."),
62+
textItem("Password...", _pwdController, true),
5463
SizedBox(
5564
height: 40,
5665
),
@@ -68,12 +77,20 @@ class _SignInPageState extends State<SignInPage> {
6877
fontSize: 16,
6978
),
7079
),
71-
Text(
72-
"SignUp",
73-
style: TextStyle(
74-
color: Colors.white,
75-
fontSize: 16,
76-
fontWeight: FontWeight.w600,
80+
InkWell(
81+
onTap: () {
82+
Navigator.pushAndRemoveUntil(
83+
context,
84+
MaterialPageRoute(builder: (builder) => SignUpPage()),
85+
(route) => false);
86+
},
87+
child: Text(
88+
"SignUp",
89+
style: TextStyle(
90+
color: Colors.white,
91+
fontSize: 16,
92+
fontWeight: FontWeight.w600,
93+
),
7794
),
7895
),
7996
],
@@ -97,21 +114,49 @@ class _SignInPageState extends State<SignInPage> {
97114
}
98115

99116
Widget colorButton() {
100-
return Container(
101-
width: MediaQuery.of(context).size.width - 100,
102-
height: 60,
103-
decoration: BoxDecoration(
104-
borderRadius: BorderRadius.circular(20),
105-
gradient: LinearGradient(
106-
colors: [Color(0xfffd746c), Color(0xffff9068), Color(0xfffd746c)]),
107-
),
108-
child: Center(
109-
child: Text(
110-
"Sign In",
111-
style: TextStyle(
112-
color: Colors.white,
113-
fontSize: 20,
114-
),
117+
return InkWell(
118+
onTap: () async {
119+
try {
120+
firebase_auth.UserCredential userCredential =
121+
await firebaseAuth.signInWithEmailAndPassword(
122+
email: _emailController.text, password: _pwdController.text);
123+
print(userCredential.user.email);
124+
setState(() {
125+
circular = false;
126+
});
127+
Navigator.pushAndRemoveUntil(
128+
context,
129+
MaterialPageRoute(builder: (builder) => HomePage()),
130+
(route) => false);
131+
} catch (e) {
132+
final snackbar = SnackBar(content: Text(e.toString()));
133+
ScaffoldMessenger.of(context).showSnackBar(snackbar);
134+
setState(() {
135+
circular = false;
136+
});
137+
}
138+
},
139+
child: Container(
140+
width: MediaQuery.of(context).size.width - 100,
141+
height: 60,
142+
decoration: BoxDecoration(
143+
borderRadius: BorderRadius.circular(20),
144+
gradient: LinearGradient(colors: [
145+
Color(0xfffd746c),
146+
Color(0xffff9068),
147+
Color(0xfffd746c)
148+
]),
149+
),
150+
child: Center(
151+
child: circular
152+
? CircularProgressIndicator()
153+
: Text(
154+
"Sign In",
155+
style: TextStyle(
156+
color: Colors.white,
157+
fontSize: 20,
158+
),
159+
),
115160
),
116161
),
117162
);
@@ -155,17 +200,31 @@ class _SignInPageState extends State<SignInPage> {
155200
);
156201
}
157202

158-
Widget textItem(String labeltext) {
203+
Widget textItem(
204+
String labeltext, TextEditingController controller, bool obscureText) {
159205
return Container(
160206
width: MediaQuery.of(context).size.width - 70,
161207
height: 55,
162208
child: TextFormField(
209+
controller: controller,
210+
obscureText: obscureText,
211+
style: TextStyle(
212+
fontSize: 17,
213+
color: Colors.white,
214+
),
163215
decoration: InputDecoration(
164216
labelText: labeltext,
165217
labelStyle: TextStyle(
166218
fontSize: 17,
167219
color: Colors.white,
168220
),
221+
focusedBorder: OutlineInputBorder(
222+
borderRadius: BorderRadius.circular(15),
223+
borderSide: BorderSide(
224+
width: 1.5,
225+
color: Colors.amber,
226+
),
227+
),
169228
enabledBorder: OutlineInputBorder(
170229
borderRadius: BorderRadius.circular(15),
171230
borderSide: BorderSide(

lib/pages/SignUpPage.dart

Lines changed: 230 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,230 @@
1+
import 'package:firebase_app_web/pages/HomePage.dart';
2+
import 'package:firebase_app_web/pages/SignInPage.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:flutter_svg/flutter_svg.dart';
5+
import 'package:firebase_auth/firebase_auth.dart' as firebase_auth;
6+
7+
class SignUpPage extends StatefulWidget {
8+
SignUpPage({Key key}) : super(key: key);
9+
10+
@override
11+
_SignUpPageState createState() => _SignUpPageState();
12+
}
13+
14+
class _SignUpPageState extends State<SignUpPage> {
15+
firebase_auth.FirebaseAuth firebaseAuth = firebase_auth.FirebaseAuth.instance;
16+
TextEditingController _emailController = TextEditingController();
17+
TextEditingController _pwdController = TextEditingController();
18+
bool circular = false;
19+
20+
@override
21+
Widget build(BuildContext context) {
22+
return Scaffold(
23+
body: SingleChildScrollView(
24+
child: Container(
25+
height: MediaQuery.of(context).size.height,
26+
width: MediaQuery.of(context).size.width,
27+
color: Colors.black,
28+
child: Column(
29+
mainAxisAlignment: MainAxisAlignment.center,
30+
children: [
31+
Text(
32+
"Sign Up",
33+
style: TextStyle(
34+
fontSize: 35,
35+
color: Colors.white,
36+
fontWeight: FontWeight.bold,
37+
),
38+
),
39+
SizedBox(
40+
height: 20,
41+
),
42+
buttonItem("assets/google.svg", "Continue with Google", 25),
43+
SizedBox(
44+
height: 15,
45+
),
46+
buttonItem("assets/phone.svg", "Continue with Mobile", 30),
47+
SizedBox(
48+
height: 18,
49+
),
50+
Text(
51+
"Or",
52+
style: TextStyle(color: Colors.white, fontSize: 18),
53+
),
54+
SizedBox(
55+
height: 18,
56+
),
57+
textItem("Email....", _emailController, false),
58+
SizedBox(
59+
height: 15,
60+
),
61+
textItem("Password...", _pwdController, true),
62+
SizedBox(
63+
height: 40,
64+
),
65+
colorButton(),
66+
SizedBox(
67+
height: 20,
68+
),
69+
Row(
70+
mainAxisAlignment: MainAxisAlignment.center,
71+
children: [
72+
Text(
73+
"If you alredy have an Account? ",
74+
style: TextStyle(
75+
color: Colors.white,
76+
fontSize: 16,
77+
),
78+
),
79+
InkWell(
80+
onTap: () {
81+
Navigator.pushAndRemoveUntil(
82+
context,
83+
MaterialPageRoute(builder: (builder) => SignInPage()),
84+
(route) => false);
85+
},
86+
child: Text(
87+
"Login",
88+
style: TextStyle(
89+
color: Colors.white,
90+
fontSize: 16,
91+
fontWeight: FontWeight.w600,
92+
),
93+
),
94+
),
95+
],
96+
),
97+
],
98+
),
99+
),
100+
),
101+
);
102+
}
103+
104+
Widget colorButton() {
105+
return InkWell(
106+
onTap: () async {
107+
setState(() {
108+
circular = true;
109+
});
110+
try {
111+
firebase_auth.UserCredential userCredential =
112+
await firebaseAuth.createUserWithEmailAndPassword(
113+
email: _emailController.text, password: _pwdController.text);
114+
print(userCredential.user.email);
115+
setState(() {
116+
circular = false;
117+
});
118+
Navigator.pushAndRemoveUntil(
119+
context,
120+
MaterialPageRoute(builder: (builder) => HomePage()),
121+
(route) => false);
122+
} catch (e) {
123+
final snackbar = SnackBar(content: Text(e.toString()));
124+
ScaffoldMessenger.of(context).showSnackBar(snackbar);
125+
setState(() {
126+
circular = false;
127+
});
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+
),
151+
),
152+
),
153+
);
154+
}
155+
156+
Widget buttonItem(String imagepath, String buttonName, double size) {
157+
return Container(
158+
width: MediaQuery.of(context).size.width - 60,
159+
height: 60,
160+
child: Card(
161+
color: Colors.black,
162+
elevation: 8,
163+
shape: RoundedRectangleBorder(
164+
borderRadius: BorderRadius.circular(15),
165+
side: BorderSide(
166+
width: 1,
167+
color: Colors.grey,
168+
),
169+
),
170+
child: Row(
171+
mainAxisAlignment: MainAxisAlignment.center,
172+
children: [
173+
SvgPicture.asset(
174+
imagepath,
175+
height: size,
176+
width: size,
177+
),
178+
SizedBox(
179+
width: 15,
180+
),
181+
Text(
182+
buttonName,
183+
style: TextStyle(
184+
color: Colors.white,
185+
fontSize: 17,
186+
),
187+
),
188+
],
189+
),
190+
),
191+
);
192+
}
193+
194+
Widget textItem(
195+
String labeltext, TextEditingController controller, bool obscureText) {
196+
return Container(
197+
width: MediaQuery.of(context).size.width - 70,
198+
height: 55,
199+
child: TextFormField(
200+
controller: controller,
201+
obscureText: obscureText,
202+
style: TextStyle(
203+
fontSize: 17,
204+
color: Colors.white,
205+
),
206+
decoration: InputDecoration(
207+
labelText: labeltext,
208+
labelStyle: TextStyle(
209+
fontSize: 17,
210+
color: Colors.white,
211+
),
212+
focusedBorder: OutlineInputBorder(
213+
borderRadius: BorderRadius.circular(15),
214+
borderSide: BorderSide(
215+
width: 1.5,
216+
color: Colors.amber,
217+
),
218+
),
219+
enabledBorder: OutlineInputBorder(
220+
borderRadius: BorderRadius.circular(15),
221+
borderSide: BorderSide(
222+
width: 1,
223+
color: Colors.grey,
224+
),
225+
),
226+
),
227+
),
228+
);
229+
}
230+
}

0 commit comments

Comments
 (0)