90 lines
2.9 KiB
Dart
90 lines
2.9 KiB
Dart
import 'package:aitrainer_app/localization/app_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
class BottomNavigator extends StatefulWidget {
|
|
int bottomNavIndex = 0;
|
|
BottomNavigator({this.bottomNavIndex}) {
|
|
this.bottomNavIndex = bottomNavIndex;
|
|
}
|
|
|
|
@override
|
|
_NawDrawerWidget createState() => _NawDrawerWidget();
|
|
}
|
|
|
|
class _NawDrawerWidget extends State<BottomNavigator> {
|
|
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
|
|
return BottomNavigationBar(
|
|
currentIndex: widget.bottomNavIndex, // this will be set when a new tab is tapped
|
|
backgroundColor: Colors.transparent,
|
|
selectedItemColor: Colors.yellow,
|
|
unselectedItemColor: Colors.lightGreen,
|
|
//type: BottomNavigationBarType.shifting,
|
|
showSelectedLabels: true,
|
|
showUnselectedLabels: true,
|
|
items: [
|
|
BottomNavigationBarItem(
|
|
backgroundColor: Colors.black12,
|
|
icon: new Icon(Icons.home, color: Colors.lightGreen),
|
|
activeIcon: new Icon(Icons.home, color: Colors.yellow,),
|
|
title: new Text(AppLocalizations.of(context).translate("Home")),
|
|
),
|
|
BottomNavigationBarItem(
|
|
backgroundColor: Colors.black12,
|
|
icon: new Icon(Icons.confirmation_number, color: Colors.lightGreen),
|
|
activeIcon: new Icon(Icons.event, color: Colors.yellow,),
|
|
title: new Text(AppLocalizations.of(context).translate("Events")),
|
|
),
|
|
|
|
BottomNavigationBarItem(
|
|
backgroundColor: Colors.black12,
|
|
icon: Icon(Icons.person, color: Colors.lightGreen,),
|
|
activeIcon: new Icon(Icons.person, color: Colors.yellow,),
|
|
title: Text(AppLocalizations.of(context).translate("Account"))
|
|
),
|
|
BottomNavigationBarItem(
|
|
backgroundColor: Colors.black12,
|
|
icon: Icon(Icons.settings, color: Colors.lightGreen),
|
|
activeIcon: new Icon(Icons.settings, color: Colors.yellow,),
|
|
title: Text(AppLocalizations.of(context).translate("Settings"))
|
|
)
|
|
],
|
|
onTap:(index) {
|
|
setState(() {
|
|
widget.bottomNavIndex = index;
|
|
});
|
|
switch (index) {
|
|
case 0:
|
|
Navigator.of(context).pop();
|
|
Navigator.of(context).pushNamed('home');
|
|
|
|
break;
|
|
case 1:
|
|
//throw new StateError('This is a Dart exception on event.');
|
|
|
|
break;
|
|
case 2:
|
|
Navigator.of(context).pop();
|
|
Navigator.of(context).pushNamed('account');
|
|
|
|
break;
|
|
case 3:
|
|
Navigator.of(context).pop();
|
|
Navigator.of(context).pushNamed('settings');
|
|
|
|
break;
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
|
|
} |