Skip to content

Commit da56314

Browse files
committed
Added drawer
1 parent 84b6327 commit da56314

File tree

4 files changed

+99
-10
lines changed

4 files changed

+99
-10
lines changed

lib/Pages/HomePage.dart

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'package:blogapp/Screen/HomeScreen.dart';
2+
import 'package:blogapp/Screen/ProfileScreen.dart';
13
import 'package:flutter/material.dart';
24

35
class HomePage extends StatefulWidget {
@@ -8,18 +10,59 @@ class HomePage extends StatefulWidget {
810
}
911

1012
class _HomePageState extends State<HomePage> {
13+
int currentState = 0;
14+
List<Widget> widgets = [HomeScreen(), ProfileScreen()];
15+
List<String> titleString = ["Home Page", "Profile Page"];
16+
1117
@override
1218
Widget build(BuildContext context) {
1319
return Scaffold(
20+
drawer: Drawer(
21+
child: ListView(
22+
children: <Widget>[
23+
DrawerHeader(
24+
child: Column(
25+
children: <Widget>[
26+
Container(
27+
height: 100,
28+
width: 100,
29+
decoration: BoxDecoration(
30+
color: Colors.black,
31+
borderRadius: BorderRadius.circular(50),
32+
),
33+
),
34+
SizedBox(
35+
height: 10,
36+
),
37+
Text("@username"),
38+
],
39+
),
40+
),
41+
ListTile(
42+
title: Text("all post"),
43+
),
44+
],
45+
),
46+
),
47+
appBar: AppBar(
48+
backgroundColor: Colors.teal,
49+
title: Text(titleString[currentState]),
50+
centerTitle: true,
51+
actions: <Widget>[
52+
IconButton(icon: Icon(Icons.notifications), onPressed: () {}),
53+
],
54+
),
1455
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
1556
floatingActionButton: FloatingActionButton(
16-
onPressed: null,
57+
backgroundColor: Colors.teal,
58+
onPressed: () {},
1759
child: Text(
1860
"+",
19-
style: TextStyle(fontSize: 35),
61+
style: TextStyle(fontSize: 40),
2062
),
2163
),
2264
bottomNavigationBar: BottomAppBar(
65+
color: Colors.teal,
2366
shape: CircularNotchedRectangle(),
2467
notchMargin: 12,
2568
child: Container(
@@ -31,22 +74,30 @@ class _HomePageState extends State<HomePage> {
3174
children: <Widget>[
3275
IconButton(
3376
icon: Icon(Icons.home),
34-
onPressed: null,
35-
iconSize: 35,
77+
color: currentState == 0 ? Colors.white : Colors.white54,
78+
onPressed: () {
79+
setState(() {
80+
currentState = 0;
81+
});
82+
},
83+
iconSize: 40,
3684
),
3785
IconButton(
3886
icon: Icon(Icons.person),
39-
onPressed: null,
40-
iconSize: 35,
87+
color: currentState == 1 ? Colors.white : Colors.white54,
88+
onPressed: () {
89+
setState(() {
90+
currentState = 1;
91+
});
92+
},
93+
iconSize: 40,
4194
)
4295
],
4396
),
4497
),
4598
),
4699
),
47-
body: Center(
48-
child: Text("Welcome on blog app"),
49-
),
100+
body: widgets[currentState],
50101
);
51102
}
52103
}

lib/Screen/HomeScreen.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import 'package:flutter/material.dart';
2+
3+
class HomeScreen extends StatefulWidget {
4+
HomeScreen({Key key}) : super(key: key);
5+
6+
@override
7+
_HomeScreenState createState() => _HomeScreenState();
8+
}
9+
10+
class _HomeScreenState extends State<HomeScreen> {
11+
@override
12+
Widget build(BuildContext context) {
13+
return Scaffold(
14+
body: Center(
15+
child: Text("Home page"),
16+
),
17+
);
18+
}
19+
}

lib/Screen/ProfileScreen.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import 'package:flutter/material.dart';
2+
3+
class ProfileScreen extends StatefulWidget {
4+
ProfileScreen({Key key}) : super(key: key);
5+
6+
@override
7+
_ProfileScreenState createState() => _ProfileScreenState();
8+
}
9+
10+
class _ProfileScreenState extends State<ProfileScreen> {
11+
@override
12+
Widget build(BuildContext context) {
13+
return Scaffold(
14+
body: Center(
15+
child: Text("Profile page"),
16+
),
17+
);
18+
}
19+
}

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class _MyAppState extends State<MyApp> {
2525

2626
void checkLogin() async {
2727
String token = await storage.read(key: "token");
28-
if (token != null) {
28+
if (token == null) {
2929
setState(() {
3030
page = HomePage();
3131
});

0 commit comments

Comments
 (0)