first commit
This commit is contained in:
15
lib/screens/business_sreeen.dart
Normal file
15
lib/screens/business_sreeen.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class BusinessScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.red,
|
||||
title: Text('News'),
|
||||
centerTitle: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
81
lib/screens/home_screen.dart
Normal file
81
lib/screens/home_screen.dart
Normal file
@@ -0,0 +1,81 @@
|
||||
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>[
|
||||
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()
|
||||
));
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user