Skip to content

Commit c8160ee

Browse files
committed
Drawer work completed
1 parent d621880 commit c8160ee

File tree

1 file changed

+48
-9
lines changed

1 file changed

+48
-9
lines changed

lib/Pages/HomePage.dart

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:blogapp/Screen/HomeScreen.dart';
44
import 'package:blogapp/Profile/ProfileScreen.dart';
55
import 'package:flutter/material.dart';
66
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
7+
import 'package:blogapp/NetworkHandler.dart';
78

89
class HomePage extends StatefulWidget {
910
HomePage({Key key}) : super(key: key);
@@ -17,6 +18,51 @@ class _HomePageState extends State<HomePage> {
1718
List<Widget> widgets = [HomeScreen(), ProfileScreen()];
1819
List<String> titleString = ["Home Page", "Profile Page"];
1920
final storage = FlutterSecureStorage();
21+
NetworkHandler networkHandler = NetworkHandler();
22+
String username = "";
23+
24+
Widget profilePhoto = Container(
25+
height: 100,
26+
width: 100,
27+
decoration: BoxDecoration(
28+
color: Colors.black,
29+
borderRadius: BorderRadius.circular(50),
30+
),
31+
);
32+
33+
@override
34+
void initState() {
35+
// TODO: implement initState
36+
super.initState();
37+
checkProfile();
38+
}
39+
40+
void checkProfile() async {
41+
var response = await networkHandler.get("/profile/checkProfile");
42+
setState(() {
43+
username = response['username'];
44+
});
45+
if (response["status"] == true) {
46+
setState(() {
47+
profilePhoto = CircleAvatar(
48+
radius: 50,
49+
backgroundImage: NetworkHandler().getImage(response['username']),
50+
);
51+
});
52+
} else {
53+
setState(() {
54+
profilePhoto = Container(
55+
height: 100,
56+
width: 100,
57+
decoration: BoxDecoration(
58+
color: Colors.black,
59+
borderRadius: BorderRadius.circular(50),
60+
),
61+
);
62+
});
63+
}
64+
}
65+
2066
@override
2167
Widget build(BuildContext context) {
2268
return Scaffold(
@@ -26,18 +72,11 @@ class _HomePageState extends State<HomePage> {
2672
DrawerHeader(
2773
child: Column(
2874
children: <Widget>[
29-
Container(
30-
height: 100,
31-
width: 100,
32-
decoration: BoxDecoration(
33-
color: Colors.black,
34-
borderRadius: BorderRadius.circular(50),
35-
),
36-
),
75+
profilePhoto,
3776
SizedBox(
3877
height: 10,
3978
),
40-
Text("@username"),
79+
Text("@$username"),
4180
],
4281
),
4382
),

0 commit comments

Comments
 (0)