Skip to content

Commit 848456b

Browse files
committed
login page added
1 parent 90cd2ad commit 848456b

File tree

5 files changed

+208
-27
lines changed

5 files changed

+208
-27
lines changed

lib/Pages/SinInPage.dart

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
import 'package:blogapp/Pages/SignUpPage.dart';
2+
import "package:flutter/material.dart";
3+
4+
import '../NetworkHandler.dart';
5+
6+
class SignInPage extends StatefulWidget {
7+
SignInPage({Key key}) : super(key: key);
8+
9+
@override
10+
_SignInPageState createState() => _SignInPageState();
11+
}
12+
13+
class _SignInPageState extends State<SignInPage> {
14+
bool vis = true;
15+
final _globalkey = GlobalKey<FormState>();
16+
NetworkHandler networkHandler = NetworkHandler();
17+
TextEditingController _usernameController = TextEditingController();
18+
TextEditingController _emailController = TextEditingController();
19+
TextEditingController _passwordController = TextEditingController();
20+
String errorText;
21+
bool validate = false;
22+
bool circular = false;
23+
@override
24+
Widget build(BuildContext context) {
25+
return Scaffold(
26+
body: Container(
27+
// height: MediaQuery.of(context).size.height,
28+
// width: MediaQuery.of(context).size.width,
29+
decoration: BoxDecoration(
30+
gradient: LinearGradient(
31+
colors: [Colors.white, Colors.green[200]],
32+
begin: const FractionalOffset(0.0, 1.0),
33+
end: const FractionalOffset(0.0, 1.0),
34+
stops: [0.0, 1.0],
35+
tileMode: TileMode.repeated,
36+
),
37+
),
38+
child: Form(
39+
key: _globalkey,
40+
child: Padding(
41+
padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 10.0),
42+
child: Column(
43+
mainAxisAlignment: MainAxisAlignment.center,
44+
children: [
45+
Text(
46+
"Sign In with Email",
47+
style: TextStyle(
48+
fontSize: 30,
49+
fontWeight: FontWeight.bold,
50+
letterSpacing: 2,
51+
),
52+
),
53+
SizedBox(
54+
height: 20,
55+
),
56+
usernameTextField(),
57+
SizedBox(
58+
height: 15,
59+
),
60+
passwordTextField(),
61+
SizedBox(
62+
height: 20,
63+
),
64+
Row(
65+
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
66+
children: [
67+
Text(
68+
"Forgot Password ?",
69+
style: TextStyle(
70+
color: Colors.blue,
71+
fontSize: 15,
72+
fontWeight: FontWeight.bold,
73+
),
74+
),
75+
SizedBox(width: 20),
76+
InkWell(
77+
onTap: () {
78+
Navigator.pushReplacement(
79+
context,
80+
MaterialPageRoute(
81+
builder: (context) => SignUpPage()));
82+
},
83+
child: Text(
84+
"New User?",
85+
style: TextStyle(
86+
color: Colors.blue[900],
87+
fontSize: 15,
88+
fontWeight: FontWeight.bold,
89+
),
90+
),
91+
),
92+
],
93+
),
94+
SizedBox(
95+
height: 30,
96+
),
97+
InkWell(
98+
onTap: () async {},
99+
child: circular
100+
? CircularProgressIndicator()
101+
: Container(
102+
width: 150,
103+
height: 50,
104+
decoration: BoxDecoration(
105+
borderRadius: BorderRadius.circular(10),
106+
color: Color(0xff00A86B),
107+
),
108+
child: Center(
109+
child: Text(
110+
"Sign In",
111+
style: TextStyle(
112+
color: Colors.white,
113+
fontSize: 18,
114+
fontWeight: FontWeight.bold,
115+
),
116+
),
117+
),
118+
),
119+
),
120+
// Divider(
121+
// height: 50,
122+
// thickness: 1.5,
123+
// ),
124+
],
125+
),
126+
),
127+
),
128+
),
129+
);
130+
}
131+
132+
Widget usernameTextField() {
133+
return Column(
134+
children: [
135+
Text("Username"),
136+
TextFormField(
137+
controller: _usernameController,
138+
decoration: InputDecoration(
139+
errorText: validate ? null : errorText,
140+
focusedBorder: UnderlineInputBorder(
141+
borderSide: BorderSide(
142+
color: Colors.black,
143+
width: 2,
144+
),
145+
),
146+
),
147+
)
148+
],
149+
);
150+
}
151+
152+
Widget passwordTextField() {
153+
return Column(
154+
children: [
155+
Text("Password"),
156+
TextFormField(
157+
controller: _passwordController,
158+
validator: (value) {
159+
if (value.isEmpty) return "Password can't be empty";
160+
if (value.length < 8) return "Password lenght must have >=8";
161+
return null;
162+
},
163+
obscureText: vis,
164+
decoration: InputDecoration(
165+
suffixIcon: IconButton(
166+
icon: Icon(vis ? Icons.visibility_off : Icons.visibility),
167+
onPressed: () {
168+
setState(() {
169+
vis = !vis;
170+
});
171+
},
172+
),
173+
helperStyle: TextStyle(
174+
fontSize: 14,
175+
),
176+
focusedBorder: UnderlineInputBorder(
177+
borderSide: BorderSide(
178+
color: Colors.black,
179+
width: 2,
180+
),
181+
),
182+
),
183+
)
184+
],
185+
);
186+
}
187+
}
Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import 'package:flutter_facebook_login/flutter_facebook_login.dart';
55
import 'SignUpPage.dart';
66
import 'package:http/http.dart' as http;
77

8+
import 'SinInPage.dart';
9+
810
class WelcomePage extends StatefulWidget {
911
@override
1012
_WelcomePageState createState() => _WelcomePageState();
@@ -141,12 +143,19 @@ class _WelcomePageState extends State<WelcomePage>
141143
SizedBox(
142144
width: 10,
143145
),
144-
Text(
145-
"Sign In",
146-
style: TextStyle(
147-
color: Colors.green,
148-
fontSize: 17,
149-
fontWeight: FontWeight.bold,
146+
InkWell(
147+
onTap: () {
148+
Navigator.of(context).push(MaterialPageRoute(
149+
builder: (context) => SignInPage(),
150+
));
151+
},
152+
child: Text(
153+
"Sign In",
154+
style: TextStyle(
155+
color: Colors.green,
156+
fontSize: 17,
157+
fontWeight: FontWeight.bold,
158+
),
150159
),
151160
),
152161
],

lib/main.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import 'package:flutter/material.dart';
2-
import 'package:frenzo/pages/SignUp.dart';
3-
import 'package:frenzo/pages/Welcome.dart';
42
import 'package:google_fonts/google_fonts.dart';
3+
import 'Pages/WelcomePage.dart';
54

65
void main() {
76
runApp(MyApp());
@@ -11,12 +10,11 @@ class MyApp extends StatelessWidget {
1110
@override
1211
Widget build(BuildContext context) {
1312
return MaterialApp(
14-
theme: ThemeData(
15-
textTheme: GoogleFonts.openSansTextTheme(
16-
Theme.of(context).textTheme,
13+
theme: ThemeData(
14+
textTheme: GoogleFonts.openSansTextTheme(
15+
Theme.of(context).textTheme,
16+
),
1717
),
18-
),
19-
home: SignUpPage(),
20-
);
18+
home: WelcomePage());
2119
}
2220
}

lib/pages/FbSignUp.dart

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)