Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class _SiteScreenState extends State<SiteScreen> {
- String clientID;
- int _currentIndex = 0;
- final List<Widget> _children = [
- SiteHomeWidget(),
- ProductionWidget(Colors.amberAccent),
- AlarmsWidget(),
- TankLevelWidget(Colors.blue),
- ];
- _SiteScreenState(String clientID){
- clientID = clientID;
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- centerTitle: true,
- title: Container(
- padding: EdgeInsets.fromLTRB(0,0,40.0,0),
- child: Center(
- child: Text(
- titleChanger(_currentIndex),
- style: TextStyle(
- fontSize: 30.0,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ),
- ),
- body: _children[_currentIndex],
- bottomNavigationBar: BottomNavigationBar(
- type: BottomNavigationBarType.fixed,
- onTap: onTabTapped,
- currentIndex:
- _currentIndex, // this will be set when a new tab is tapped
- items: [
- BottomNavigationBarItem(
- icon: new Icon(Icons.home),
- title: new Text('Sites'),
- ),
- BottomNavigationBarItem(
- icon: new Icon(Icons.show_chart),
- title: new Text('Production'),
- ),
- BottomNavigationBarItem(
- icon: new Icon(Icons.add_alarm),
- title: new Text('Alarms'),
- ),
- BottomNavigationBarItem(
- icon: Icon(Icons.storage), title: Text('Tank Levels'))
- ],
- ),
- );
- }
- void onTabTapped(int index) {
- setState(() {
- _currentIndex = index;
- });
- }
- String titleChanger(int index){
- switch(index){
- case 0:
- return 'Sites';
- case 1:
- return 'Production';
- case 2:
- return 'Alarms';
- case 3:
- return 'Tank Levels';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement