Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.93 KB | None | 0 0
  1. class _SiteScreenState extends State<SiteScreen> {
  2.  
  3.   String clientID;
  4.   int _currentIndex = 0;
  5.   final List<Widget> _children = [
  6.     SiteHomeWidget(),
  7.     ProductionWidget(Colors.amberAccent),
  8.     AlarmsWidget(),
  9.     TankLevelWidget(Colors.blue),
  10.   ];
  11.  
  12.  _SiteScreenState(String clientID){
  13.    clientID = clientID;
  14.  }
  15.  
  16.   @override
  17.   Widget build(BuildContext context) {
  18.     return Scaffold(
  19.       appBar: AppBar(
  20.         centerTitle: true,
  21.         title: Container(
  22.           padding: EdgeInsets.fromLTRB(0,0,40.0,0),
  23.           child: Center(
  24.             child: Text(
  25.               titleChanger(_currentIndex),
  26.               style: TextStyle(
  27.                 fontSize: 30.0,
  28.                 fontWeight: FontWeight.bold,
  29.               ),
  30.             ),
  31.           ),
  32.         ),
  33.       ),
  34.       body: _children[_currentIndex],
  35.       bottomNavigationBar: BottomNavigationBar(
  36.         type: BottomNavigationBarType.fixed,
  37.         onTap: onTabTapped,
  38.         currentIndex:
  39.             _currentIndex, // this will be set when a new tab is tapped
  40.         items: [
  41.           BottomNavigationBarItem(
  42.             icon: new Icon(Icons.home),
  43.             title: new Text('Sites'),
  44.           ),
  45.           BottomNavigationBarItem(
  46.             icon: new Icon(Icons.show_chart),
  47.             title: new Text('Production'),
  48.           ),
  49.           BottomNavigationBarItem(
  50.             icon: new Icon(Icons.add_alarm),
  51.             title: new Text('Alarms'),
  52.           ),
  53.           BottomNavigationBarItem(
  54.               icon: Icon(Icons.storage), title: Text('Tank Levels'))
  55.         ],
  56.       ),
  57.     );
  58.   }
  59.  
  60.   void onTabTapped(int index) {
  61.     setState(() {
  62.       _currentIndex = index;
  63.     });
  64.   }
  65.  
  66.   String titleChanger(int index){
  67.    switch(index){
  68.      case 0:
  69.        return 'Sites';
  70.      case 1:
  71.        return 'Production';
  72.      case 2:
  73.        return 'Alarms';
  74.      case 3:
  75.        return 'Tank Levels';
  76.    }
  77.  
  78.   }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement