1+ ![ preview] ( doc/preview.png )
2+
13# convex_bottom_bar|[ 中文] ( README-zh.md )
24
35This package extends the official BottomAppBar to display a convex tab, example can be preview as bellow.
@@ -6,59 +8,65 @@ This package extends the official BottomAppBar to display a convex tab, example
68
79![ Screenshot] ( doc/Screenshot_1571041912.png )
810
11+ ** Install Demo** [ app-release.apk] ( doc/app-release.apk )
12+
913## How to use
10- Follow the steps to setup ` Scaffold ` with custom attributes :
14+ To use ConvexAppBar, follow these steps to setup ` Scaffold ` :
11151 . add FAB with ` floatingActionButton `
12162 . center the FAB with ` floatingActionButtonLocation `
13173 . setup App Bar by ` bottomNavigationBar `
1418
15- ### Add FAB
16- Display the FAB as a Container which contains Icon & Label
17-
19+ The ` ConvexAppBar ` has to two constructors, the ` ConvexAppBar() ` will use default layout to simplify the tab creation.
20+
1821``` dart
19- floatingActionButton: GestureDetector(
20- onTap: () => _onItemTapped(INDEX_PUBLISH),
21- child: Container(
22- width: 60,
23- height: 80,
24- padding: EdgeInsets.only(bottom: 2),
25- child: Column(
26- mainAxisAlignment: MainAxisAlignment.end,
27- children: <Widget>[
28- Icon(Icons.add, size: 50, color: convexColor),
29- Text('Publish', style: TextStyle(color: convexColor)),
30- ],
31- ),
22+ Scaffold(
23+ appBar: AppBar(
24+ title: const Text('Default ConvexAppBar'),
25+ ),
26+ body: Center(
27+ child: Text('TAB $_selectedIndex', style: TextStyle(fontSize: 20)),
28+ ),
29+ floatingActionButton: ConvexAppBar.fab(
30+ text: 'Publish',
31+ active: _selectedIndex == INDEX_PUBLISH,
32+ activeColor: ACTIVE_COLOR,
33+ color: NORMAL_COLOR,
34+ onTap: () => onTabSelected(INDEX_PUBLISH),
35+ ),
36+ floatingActionButtonLocation: ConvexAppBar.centerDocked,
37+ bottomNavigationBar: ConvexAppBar(
38+ items: TAB_ITEMS,
39+ index: _selectedIndex,
40+ activeColor: ACTIVE_COLOR,
41+ color: NORMAL_COLOR,
42+ onTap: onTabSelected,
3243 ),
3344)
3445```
35- ### Center the FAB
36- Make the FAB center in BottomApp
3746
38- ``` dart
39- floatingActionButtonLocation: ExtendLocation.centerDocked,
40- ```
41- ### Setup App Bar
47+ ### Custom
48+ If the default style does not match with your situation, try with ` ConvexAppBar.builder() ` , which allow you to custom nearly all the tab features.
4249
4350``` dart
44- bottomNavigationBar: ConvexAppBar.builder(
45- count: 5,
46- builder: (BuildContext context, int index) {
47- var data = _navigationItems[index];
48- var color = _selected == index ? Colors.red : Colors.black;
49- return GestureDetector(
50- onTap: () => _onItemTapped(index),
51- child: Container(
52- height: 50,
53- padding: EdgeInsets.only(bottom: 2),
54- child: Column(
55- mainAxisAlignment: MainAxisAlignment.end,
56- children: <Widget>[
57- Icon(data.icon, color: color),
58- Text(data.title, style: TextStyle(color: color))
59- ],
60- )));
61- }),
51+ Scaffold(
52+ appBar: AppBar(title: const Text('Custom ConvexAppBar')),
53+ body: paletteBody(),
54+ floatingActionButton: GestureDetector(
55+ onTap: () => _onItemTapped(INDEX_PUBLISH),
56+ child: fabContent(convexColor),
57+ ),
58+ floatingActionButtonLocation: ConvexAppBar.centerDocked,
59+ bottomNavigationBar: ConvexAppBar.builder(
60+ count: 5,
61+ backgroundColor: _tabBackgroundColor,
62+ builder: (BuildContext context, int index) {
63+ var data = _navigationItems[index];
64+ var color = _currentIndex == index ? Colors.white : Colors.white60;
65+ return GestureDetector(
66+ onTap: () => _onItemTapped(index),
67+ child: tabContent(data, color));
68+ }),
69+ );
6270```
6371
6472## Example
0 commit comments