-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbottom-nav-bar.dart
83 lines (73 loc) · 3.1 KB
/
bottom-nav-bar.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//A demo to implement bottomnavigationbar in flutter
class _ChatPageState extends State<ChatPage> {
int _selectedIndex = 0;
final List<Widget> _children = [Chats(),Calls(), People()];
@override
Widget build(BuildContext context) {
return Scaffold(
body: _children[_selectedIndex],
floatingActionButton: FloatingActionButton(
onPressed: () {},
backgroundColor: pPrimaryColor,
child: Icon(
Icons.person_add_alt_1_rounded,
color: Colors.white,
),
),
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
currentIndex: _selectedIndex,
onTap: (value) {
setState(() {
_selectedIndex = value;
});
},
items: [
BottomNavigationBarItem(icon: Icon(Icons.messenger), label: "Chats"),
BottomNavigationBarItem(icon: Icon(Icons.people), label: "People"),
BottomNavigationBarItem(icon: Icon(Icons.call), label: "Calls"),
],
),
);
}
}
-----------------------------/\/\/\/\/\/\\/\/\/\/\/\/\/\\/\/\/\/\/\/\----------------------------------------------------------
//Bottom navbar with circle avartar + change of icons when moved from one page to another
Scaffold(
body: _children[_selectedIndex],
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
selectedIconTheme: IconThemeData(color: pPrimaryColor),
currentIndex: _selectedIndex,
backgroundColor: !isDark?Colors.white:Colors.black,
selectedItemColor: isDark?Colors.grey:Colors.black,
showSelectedLabels: false,
showUnselectedLabels: false,
elevation: 0,
onTap: (value) {
setState(() {
_selectedIndex = value;
});
},
items: [
BottomNavigationBarItem(
icon: _selectedIndex==0?Icon(Icons.home,color: Colors.black,size: 28,): Icon(Icons.home_outlined,color: Colors.black,size: 28,),label: 'home'),
BottomNavigationBarItem(icon: _selectedIndex==1?Icon(Icons.search,color: Colors.black,size: 28,): Icon(Icons.search_outlined,color: Colors.black,size: 28,),label: 'search'),
BottomNavigationBarItem(icon: _selectedIndex==2?Icon(Icons.video_collection_sharp,color: Colors.black,size: 28,): Icon(Icons.video_collection_outlined,color: Colors.black,size: 28,),label: 'reels' ),
BottomNavigationBarItem(icon: _selectedIndex==3?Icon(Icons.favorite,color: Colors.black,size: 28,):Icon(Icons.favorite_border_outlined,color: Colors.black,size: 28,),label: 'notif'),
BottomNavigationBarItem(icon: _selectedIndex==4?
CircleAvatar(
radius: 14,
backgroundColor: Colors.black,
child: CircleAvatar(
radius: 13,
backgroundImage:AssetImage('assets/profilepic.jpg') ,),
):
CircleAvatar(
radius: 14,
backgroundImage:AssetImage('assets/profilepic.jpg') ,),
label: 'profile'
),
],
),
);