Created
March 31, 2019 02:28
-
-
Save farhanrahmadi/97780b32719c3867d55d0783ba92e28e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_svg/flutter_svg.dart'; | |
class MainBottomBar extends StatelessWidget { | |
int index; | |
dynamic changeIndex; | |
MainBottomBar(this.index, this.changeIndex); | |
SvgPicture definePic(int i) { | |
switch (i) { | |
case 0: | |
{ | |
if (index == 0) { | |
return new SvgPicture.asset( | |
"assets/bottombar/booking-active.svg", | |
width: 40, | |
height: 30, | |
); | |
} else { | |
return new SvgPicture.asset("assets/bottombar/booking-unactive.svg", | |
width: 40, height: 30); | |
} | |
break; | |
} | |
case 1: | |
{ | |
if (index == 1) { | |
return SvgPicture.asset("assets/bottombar/booking-active.svg", | |
width: 40.0, height: 30.0); | |
} else { | |
return SvgPicture.asset("assets/bottombar/booking-unactive.svg", | |
width: 40.0, height: 30.0); | |
} | |
break; | |
} | |
case 2: | |
{ | |
if (index == 2) { | |
return SvgPicture.asset("assets/bottombar/news-active.svg", | |
width: 40.0, height: 30.0); | |
} else { | |
return SvgPicture.asset("assets/bottombar/news-unactive.svg", | |
width: 40.0, height: 30.0); | |
} | |
break; | |
} | |
case 3: | |
{ | |
if (index == 3) { | |
return SvgPicture.asset("assets/bottombar/news-active.svg", | |
width: 40.0, height: 30.0); | |
} else { | |
return SvgPicture.asset("assets/bottombar/news-unactive.svg", | |
width: 40.0, height: 30.0); | |
} | |
break; | |
} | |
} | |
} | |
@override | |
BottomNavigationBar build(BuildContext context) { | |
return BottomNavigationBar( | |
currentIndex: index, | |
items: bottomBarItem(), | |
onTap: changeIndex, | |
type: BottomNavigationBarType.fixed, | |
); | |
} | |
List<BottomNavigationBarItem> bottomBarItem() { | |
return [ | |
BottomNavigationBarItem( | |
icon: definePic(0), | |
title: Text('Home'), | |
), | |
BottomNavigationBarItem(icon: definePic(1), title: Text('Scan')), | |
// BottomNavigationBarItem(icon: definePic(2), title: Text('News')), | |
// BottomNavigationBarItem(icon: definePic(3), title: Text('Merchant')) | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment