-
Notifications
You must be signed in to change notification settings - Fork 74
/
convex_bottom_bar.dart
54 lines (48 loc) · 1.43 KB
/
convex_bottom_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
import 'package:flutter/material.dart';
import 'package:convex_bottom_bar/convex_bottom_bar.dart';
import 'pages/home_page.dart';
import 'pages/discovery_page.dart';
import 'pages/add_page.dart';
import 'pages/message_page.dart';
import 'pages/profile_page.dart';
class MyConvexBottomBar extends StatefulWidget {
const MyConvexBottomBar({Key? key}) : super(key: key);
@override
State<MyConvexBottomBar> createState() => _MyConvexBottomBarState();
}
class _MyConvexBottomBarState extends State<MyConvexBottomBar> {
int _selectIndex = 2;
void _navigateBottomBar(int index) {
setState(() {
_selectIndex = index;
});
}
final List<Widget> _pages = [
const HomePage(),
const DiscoveryPage(),
const AddPage(),
const MessagePage(),
const ProfilePage(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: _pages[_selectIndex],
bottomNavigationBar: ConvexAppBar(
backgroundColor: Colors.deepPurple,
items: const [
TabItem(icon: Icons.home, title: 'Home'),
TabItem(icon: Icons.map, title: 'Discovery'),
TabItem(icon: Icons.add, title: 'Add'),
TabItem(icon: Icons.message, title: 'Message'),
TabItem(icon: Icons.people, title: 'Profile'),
],
//optional, default as 0
initialActiveIndex: _selectIndex,
onTap: (int i) {
_navigateBottomBar(i);
},
),
);
}
}