import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:testapp/config.dart'; import 'package:testapp/screens/business_sreeen.dart'; import 'package:testapp/widgets/home_tabbar_view_widget.dart'; class HomeScreen extends StatelessWidget { @override Widget build(BuildContext context) { return DefaultTabController( length: Config.categories.length, initialIndex: 1, child: Scaffold( appBar: AppBar( backgroundColor: Colors.red, title: Text('News'), centerTitle: true, bottom: TabBar( isScrollable: true, indicatorColor: Colors.white, // labelPadding: EdgeInsets.only(right: 10), tabs: Config.categories.map((category){ return Tab( text: category.title + "" + category.articleCount.toString(), ); }).toList(), ), ), body: TabBarView( children: Config.categories.map((category){ return HomeTabBarViewwidget(category.title); }).toList() ), bottomNavigationBar: BottomNavigationBar( backgroundColor: Colors.red, items: const [ BottomNavigationBarItem( icon: Icon(Icons.home, color:Colors.white), title: Text('Home', style: TextStyle( color:Colors.white,) ), ), BottomNavigationBarItem( icon: Icon(Icons.business, color: Colors.white,), title: Text('Business', style: TextStyle( color: Colors.white,fontSize: 18),), ), BottomNavigationBarItem( icon: Icon(Icons.school, color: Colors.white,), title: Text('School', style: TextStyle( color: Colors.white,fontSize: 18), ), ), ], currentIndex: 0, // selectedItemColor: Colors.black, // unselectedItemColor: Colors.white, onTap: (index){ if(index== 0){ Navigator.of(context).push(MaterialPageRoute( builder: (context) =>HomeScreen() )); } else if(index== 1){ Navigator.of(context).push(MaterialPageRoute( builder: (context) =>BusinessScreen() )); } else if(index== 2){ Navigator.of(context).push(MaterialPageRoute( builder: (context) =>BusinessScreen() )); } }, ), ), ); } }