Skip to content

Commit ef25cff

Browse files
committed
Profile Page
1 parent 764388e commit ef25cff

File tree

5 files changed

+182
-6
lines changed

5 files changed

+182
-6
lines changed

final_app/assets/profile.jpg

26 KB
Loading

final_app/lib/Helper/nav_drawer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ class _DrawerWidgetState extends State<DrawerWidget> {
6161
BorderRadius.only(bottomLeft: Radius.circular(35)),
6262
),
6363
accountName: Text(
64-
this.user.name,
64+
""+this.user.name,
6565
style: Theme.of(context).textTheme.title,
6666
),
6767
accountEmail: Text(
68-
this.user.email,
68+
""+this.user.email,
6969
style: Theme.of(context).textTheme.caption,
7070
),
7171
),

final_app/lib/pages/MainPage.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:final_app/Helper/SubCategoriesApi.dart';
99
import 'package:final_app/Helper/TrendingNow.dart';
1010
import 'package:final_app/Helper/TrendingNowApi.dart';
1111
import 'package:final_app/pages/HomePage.dart';
12+
import 'package:final_app/pages/ProfilePage.dart';
1213
import 'package:flutter/services.dart';
1314
import '../Preferences.dart';
1415
import 'package:final_app/api/Categories.dart';
@@ -52,9 +53,7 @@ class _MainPageState extends State<MainPage> {
5253
Center(
5354
child: Text("TV"),
5455
),
55-
Center(
56-
child: Text("Profile"),
57-
), //new Login()
56+
new ProfilePage(), //new Login()
5857
];
5958

6059
@override
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
import 'package:final_app/Helper/BlockButton.dart';
2+
import 'package:final_app/Helper/FoodCategories.dart';
3+
import 'package:final_app/Helper/SubCategoriesApi.dart';
4+
import 'package:final_app/Helper/TrendingNowApi.dart';
5+
import 'package:final_app/api/loginApi.dart';
6+
import 'package:final_app/models/user.dart';
7+
import 'package:flutter/material.dart';
8+
import 'package:flutter_spinkit/flutter_spinkit.dart';
9+
import 'package:google_fonts/google_fonts.dart';
10+
import 'package:progress_dialog/progress_dialog.dart';
11+
12+
import '../Constants.dart';
13+
import '../Preferences.dart';
14+
15+
class ProfilePage extends StatefulWidget {
16+
@override
17+
_ProfilePageState createState() => _ProfilePageState();
18+
}
19+
20+
class _ProfilePageState extends State<ProfilePage> {
21+
ProgressDialog pr;
22+
User user = new User();
23+
24+
@override
25+
initState() {
26+
super.initState();
27+
initPrefs();
28+
}
29+
30+
void initPrefs() async {
31+
await Preferences.getUser().then((value) {
32+
setState(() {
33+
user = value;
34+
});
35+
});
36+
}
37+
38+
@override
39+
Widget build(BuildContext context) {
40+
pr = ProgressDialog(context,
41+
isDismissible: false,
42+
customBody: Container(
43+
color: Colors.transparent,
44+
child: SpinKitCubeGrid(
45+
color: Theme.of(context).accentColor,
46+
)));
47+
pr.style(
48+
backgroundColor: Colors.transparent,
49+
);
50+
if (this.user.name != '--') {
51+
return Scaffold(
52+
backgroundColor: Colors.white70,
53+
body: Padding(
54+
padding: EdgeInsets.fromLTRB(30.4, 40.0, 30.0, 0.0),
55+
child: Column(
56+
crossAxisAlignment: CrossAxisAlignment.start,
57+
children: <Widget>[
58+
Center(
59+
child: CircleAvatar(
60+
backgroundImage: AssetImage('assets/profile.jpg'),
61+
radius: 40.0,
62+
),
63+
),
64+
Divider(
65+
height: 60.0,
66+
color: Colors.grey[700],
67+
),
68+
Center(
69+
child: Text(
70+
"" + this.user.name,
71+
style: TextStyle(
72+
color: Colors.redAccent,
73+
fontSize: 28.0,
74+
fontWeight: FontWeight.bold,
75+
letterSpacing: 1.0,
76+
),
77+
),
78+
),
79+
SizedBox(
80+
height: 30,
81+
),
82+
Center(
83+
child: Text(
84+
"" + this.user.email,
85+
style: TextStyle(
86+
color: Colors.redAccent,
87+
fontSize: 20.0,
88+
fontWeight: FontWeight.bold,
89+
letterSpacing: 1.0,
90+
),
91+
),
92+
),
93+
Center(
94+
child: FlatButton.icon(
95+
icon: Icon(Icons.edit),
96+
label: Text('Edit Profile',
97+
style: TextStyle(color: Colors.black87)),
98+
color: Colors.white70,
99+
onPressed: () {},
100+
),
101+
),
102+
Center(
103+
child: RaisedButton.icon(
104+
icon: Icon(
105+
Icons.exit_to_app,
106+
color: Colors.white70,
107+
),
108+
label:
109+
Text('Logout', style: TextStyle(color: Colors.white70)),
110+
color: Colors.redAccent,
111+
onPressed: () {
112+
CustomAlertDialog(context);
113+
},
114+
),
115+
),
116+
],
117+
),
118+
),
119+
);
120+
} else {
121+
return Scaffold(
122+
backgroundColor: Colors.white70,
123+
body: Center(
124+
child: FlatButton(
125+
onPressed: () {
126+
Navigator.of(context).pushNamed('/LoginPage');
127+
},
128+
color: Colors.redAccent,
129+
child: Text(
130+
'Login',
131+
style: TextStyle(color: Colors.black87, fontSize: 30),
132+
),
133+
),
134+
),
135+
);
136+
}
137+
}
138+
139+
CustomAlertDialog(BuildContext context) {
140+
return showDialog(
141+
context: context,
142+
builder: (context) {
143+
return AlertDialog(
144+
title: Text(
145+
"Are you sure want to logout?",
146+
style: Theme.of(context).textTheme.subhead,
147+
),
148+
actions: <Widget>[
149+
MaterialButton(
150+
onPressed: () async {
151+
// Services _services = Services();
152+
pr.show();
153+
Login.LogoutUser().then((response) {
154+
pr.hide();
155+
Navigator.pushNamed(context, '/LoginPage');
156+
});
157+
},
158+
child: Text(
159+
"Yes",
160+
style: Theme.of(context).textTheme.subhead,
161+
),
162+
),
163+
MaterialButton(
164+
color: Theme.of(context).accentColor,
165+
onPressed: () {
166+
Navigator.of(context).pop();
167+
},
168+
child: Text(
169+
"No",
170+
style: Theme.of(context).textTheme.subhead,
171+
),
172+
)
173+
],
174+
);
175+
});
176+
}
177+
}

final_app/lib/pages/SplashScreen.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class _SplashScreenPageState extends State<SplashScreenPage> {
1616
@override
1717
Widget build(BuildContext context) {
1818
return SplashScreen(
19-
seconds: 5,
19+
seconds: 6,
2020
photoSize: 150,
2121
image: Image.asset('assets/freshodaily.png'),
2222
navigateAfterSeconds: check_if_already_login(context),

0 commit comments

Comments
 (0)