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
84
85
import 'package:flutter/material.dart';
import 'package:ifarm/Screens/AB/Home.dart';
import 'package:ifarm/Screens/AB/Profile.dart';
import 'package:ifarm/Screens/AB/settings.dart';
import 'package:ifarm/Screens/AB/shop.dart';
class Navbar extends StatefulWidget {
Navbar({
Key? key,
}) : super(key: key);
@override
State<Navbar> createState() => _NavbarState();
}
class _NavbarState extends State<Navbar> {
int _selectedIndex = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xff024F8E),
appBar: AppBar(
title: const SizedBox(
width: 100,
child: Image(
image: AssetImage(
'assets/images/IFarm_Logo_White.png',
))),
backgroundColor: Colors.transparent,
elevation: 0,
automaticallyImplyLeading: false,
),
body: Column(
children: [
const SizedBox(
height: 20,
),
Expanded(
child: buildPages(),
)
],
),
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Color.fromARGB(150, 6, 91, 161),
type: BottomNavigationBarType.fixed,
elevation: 1,
currentIndex: _selectedIndex,
selectedItemColor: Colors.white,
unselectedItemColor: Colors.grey,
showSelectedLabels: false,
showUnselectedLabels: false,
items: const [
BottomNavigationBarItem(label: 'Home', icon: Icon(Icons.home)),
BottomNavigationBarItem(label: 'Buy', icon: Icon(Icons.shopping_bag)),
BottomNavigationBarItem(label: 'Profile', icon: Icon(Icons.person)),
BottomNavigationBarItem(label: 'Settings', icon: Icon(Icons.settings))
],
onTap: _onItemTapped,
),
);
}
Widget buildPages() {
switch (_selectedIndex) {
case 1:
return shop();
case 2:
return profile();
case 3:
return settings();
case 0:
default:
return Home();
}
}
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
}