first commit

This commit is contained in:
sokbunthean
2020-06-27 18:46:23 +07:00
commit de8d57ceec
77 changed files with 2243 additions and 0 deletions

49
lib/config.dart Normal file
View File

@@ -0,0 +1,49 @@
import 'package:testapp/models/category_model.dart';
class Config{
static final List<CatgoryModel> categories = [
CatgoryModel('Sport',1),
CatgoryModel('National', 5),
CatgoryModel('International', 4),
CatgoryModel('Entertainment', 5),
];
//// DataType/Class/Model
// static final List<String> news = [
// 'ABABA',
// '12345',
// 'dddd',
// ];
// static List<ArticleModel> articles = [
// ArticleModel(
// 1,
// 'assets/images/sport.png',
// 'Ronaldo scored 22 goals in Serie A against Top Scorer',
// '26th,June,2020',
//
// ),
// ArticleModel(
// 2,
// 'assets/images/inter.png',
// 'GE2020: Candidates introduced will elicit responses, ',
// '26th,June,2020',
//
// ),
// ArticleModel(
// 3,
// 'assets/images/news.png',
// 'Scientists just beginning to understand the many health problems caused by COVID-19',
// '26th,June,2020',
//
// ),
// ArticleModel(
// 4,
// 'assets/images/entertainment.png',
// 'It is clear that Rabbi has a very nice thigh, a man seen in the men,',
// '26th,June,2020',
//
// ),
// ];
}

35
lib/main.dart Normal file
View File

@@ -0,0 +1,35 @@
import 'package:flutter/material.dart';
import 'screens/home_screen.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
textTheme:TextTheme(
title: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 14,
),
subtitle: TextStyle(
color:Colors.black12,
fontSize: 12,
fontStyle: FontStyle.italic,
),
),
),
home: HomeScreen(),
);
}
}

View File

@@ -0,0 +1,9 @@
class CatgoryModel {
final String title;
final int articleCount;
const CatgoryModel(
this.title,
this.articleCount
);
}

View File

@@ -0,0 +1,68 @@
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
class InternalDetail extends StatefulWidget {
@override
_InternalDetailState createState() => _InternalDetailState();
}
class _InternalDetailState extends State<InternalDetail> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
title: Text('News'),
centerTitle: true,
),
body: Container(
child: ListView(
children: <Widget>[
Row(
children: <Widget>[
Text('27th,June,2020',
style: TextStyle(
fontSize: 18.0,
color: Colors.black,
),)
],
),
Container(
height: 205.0,
child: GridTile(
child: Container(
color: Colors.white,
child: Image.asset('assets/images/news.png'),
),
footer: Container(
color: Colors.white70,
child: ListTile(
leading: Text('Ronaldo has one of the most expensive rolex watches in the world',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
title: Row(
children: <Widget>[
],
),
),
),
),
),
Html(data:'The Rolex GMT Master Ice watch is priced at £ 371,000 (nearly 500,000). It was shown in January at the Dubai Globe Socce Awards.'
'The watch is made up of 18 carat white gold and many diamonds. Thirty diamonds were found on the head of the watch and its straps. '
'Ronaldo also posted the watch on Instagram when posting a photo with his girlfriend Georgina Rodriguez.',
),
],
),
),
);
}
}

View File

@@ -0,0 +1,67 @@
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
class NationDetail extends StatefulWidget {
@override
_NationDetailState createState() => _NationDetailState();
}
class _NationDetailState extends State<NationDetail> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
title: Text('News'),
centerTitle: true,
),
body: Container(
child: ListView(
children: <Widget>[
Row(
children: <Widget>[
Text('27th,June,2020',
style: TextStyle(
fontSize: 18.0,
color: Colors.black,
),)
],
),
Container(
height: 205.0,
child: GridTile(
child: Container(
color: Colors.white,
child: Image.asset('assets/images/inter.png'),
),
footer: Container(
color: Colors.white70,
child: ListTile(
leading: Text('Ronaldo has one of the most expensive rolex watches in the world',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
title: Row(
children: <Widget>[
],
),
),
),
),
),
Html(data:'The Rolex GMT Master Ice watch is priced at £ 371,000 (nearly 500,000). It was shown in January at the Dubai Globe Socce Awards.'
'The watch is made up of 18 carat white gold and many diamonds. Thirty diamonds were found on the head of the watch and its straps. '
'Ronaldo also posted the watch on Instagram when posting a photo with his girlfriend Georgina Rodriguez.',
),
],
),
),
);
}
}

View File

@@ -0,0 +1,70 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:testapp/config.dart';
class SportDetail extends StatefulWidget {
@override
_SportDetailState createState() => _SportDetailState();
}
class _SportDetailState extends State<SportDetail> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.red,
title: Text('News'),
centerTitle: true,
),
body: Container(
child: ListView(
children: <Widget>[
Row(
children: <Widget>[
Text('27th,June,2020',
style: TextStyle(
fontSize: 18.0,
color: Colors.black,
),)
],
),
Container(
height: 205.0,
child: GridTile(
child: Container(
color: Colors.white,
child: Image.asset('assets/images/sport.png'),
),
footer: Container(
color: Colors.white70,
child: ListTile(
leading: Text('Ronaldo has one of the most expensive rolex watches in the world',
style: TextStyle(
color: Colors.red,
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
title: Row(
children: <Widget>[
],
),
),
),
),
),
Html(data:'The Rolex GMT Master Ice watch is priced at £ 371,000 (nearly 500,000). It was shown in January at the Dubai Globe Socce Awards.'
'The watch is made up of 18 carat white gold and many diamonds. Thirty diamonds were found on the head of the watch and its straps. '
'Ronaldo also posted the watch on Instagram when posting a photo with his girlfriend Georgina Rodriguez.',
),
],
),
),
);
}
}

View 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,
),
);
}
}

View 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()
));
}
},
),
),
);
}
}

View File

@@ -0,0 +1,65 @@
import 'package:flutter/material.dart';
import 'package:testapp/page_detail/internal_detail.dart';
class InternatDetailWidget extends StatelessWidget {
const InternatDetailWidget({
Key key,
@required this.title,
}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return new InkWell(
onTap: (){
Navigator.push(context,
MaterialPageRoute(builder: (context) => InternalDetail(),),);
},
child: Card(
child: Row(
children: <Widget>[
SizedBox(
width:120,
height: 100,
child: Image.asset('assets/images/news.png',
fit: BoxFit.cover,
),
),
Expanded(
child: Container(
padding: EdgeInsets.only(top: 10, left: 10),
height: 100,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text("The US tightens its borders with the states to prevent the infection",
style: Theme.of(context).textTheme.title,
),
),
Row(
children: <Widget>[
Expanded(
child: Text("27th.June.20 " ,
)
),
IconButton(
icon: Icon(Icons.favorite_border),
),
IconButton(
icon: Icon(Icons.share),
)
],
)
],
),
),
)
],
),
),
);
}
}

View File

@@ -0,0 +1,70 @@
import 'package:flutter/material.dart';
import 'package:carousel_pro/carousel_pro.dart';
import 'package:testapp/widgets/Internal_detail_widget.dart';
import 'package:testapp/widgets/national_detail_widget.dart';
import 'package:testapp/widgets/sport_detail_widget.dart';
class HomeTabBarViewwidget extends StatelessWidget {
// parameter title
final String title;
int id;
HomeTabBarViewwidget( this.title, {this.id});
@override
Widget build(BuildContext context) {
return Container(
width: double.infinity,
height: double.infinity,
child: Column(
children: <Widget>[
SizedBox(
width: double.infinity,
child: Container(
color: Colors.grey,
height: 200,
child: Carousel(
images:
[
AssetImage('assets/images/sport.png'),
AssetImage('assets/images/inter.png'),
AssetImage('assets/images/news.png'),
AssetImage('assets/images/entertainment.png'),
],
autoplay: true,
animationCurve: Curves.fastOutSlowIn,
animationDuration: Duration(milliseconds: 1000),
boxFit: BoxFit.cover,
dotSize: 4.0,
indicatorBgPadding: 4.0,
// dotColor: Colors.red.withOpacity(0.2),
),
),
),
//**************THE FIRST CARS BOD**********
SportDetailWidget(title: title),
//***********THE SECOND CARD BODY********
NationDetialWidget(title: title),
//***********THE SECOND CARD BODY********
InternatDetailWidget(title: title),
//***********THE SECOND CARD BODY********
// EnterDetailWidget(title: title),
//***********THE SECOND CARD BODY********
],
),
);
}
}

View File

@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:testapp/page_detail/national_detail.dart';
class NationDetialWidget extends StatelessWidget {
const NationDetialWidget({
Key key,
@required this.title,
}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return new InkWell(
onTap: (){
Navigator.push(context,
MaterialPageRoute(builder: (context) => NationDetail(),),);
},
child: Card(
child: Row(
children: <Widget>[
SizedBox(
width:120,
height: 100,
child: Image.asset('assets/images/inter.png',
fit: BoxFit.cover,
),
),
Expanded(
child: Container(
padding: EdgeInsets.only(top: 10, left: 10),
height: 100,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text("The US tightens its borders with the states to prevent the infection",
style: Theme.of(context).textTheme.title,
),
),
Row(
children: <Widget>[
Expanded(
child: Text("27th.June.20 " ,
)
),
IconButton(
icon: Icon(Icons.favorite_border),
),
IconButton(
icon: Icon(Icons.share),
)
],
)
],
),
),
)
],
),
),
);
}
}

View File

@@ -0,0 +1,66 @@
import 'package:flutter/material.dart';
import 'package:testapp/page_detail/sport_detail.dart';
class SportDetailWidget extends StatelessWidget {
const SportDetailWidget({
Key key,
@required this.title,
}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return new InkWell(
onTap: (){
Navigator.push(context,
MaterialPageRoute(builder: (context) => SportDetail(),),);
},
child: Card(
child: Row(
children: <Widget>[
SizedBox(
width:120,
height: 100,
child: Image.asset('assets/images/sport.png',
fit: BoxFit.cover,
),
),
Expanded(
child: Container(
padding: EdgeInsets.only(top: 10, left: 10),
height: 100,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Text("Ronaldo has one of the most expensive rolex watches in the world",
style: Theme.of(context).textTheme.title,
),
),
Row(
children: <Widget>[
Expanded(
child: Text("27th.June.20 " ,
)
),
IconButton(
icon: Icon(Icons.favorite_border),
),
IconButton(
icon: Icon(Icons.share),
)
],
)
],
),
),
)
],
),
),
);
}
}