Skip to content

Commit

Permalink
Finished version 1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
MateusPedrosoSilva committed May 19, 2020
1 parent 5a15818 commit 04cb96b
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 84 deletions.
41 changes: 30 additions & 11 deletions lib/homepage.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:convert';

import 'package:covidapp/datasorce.dart';
import 'package:covidapp/pages/countryPage.dart';
import 'package:covidapp/panels/infoPanel.dart';
import 'package:covidapp/panels/mosteffectedcontries.dart';
import 'package:covidapp/panels/worldwidepanel.dart';
Expand Down Expand Up @@ -77,17 +78,25 @@ class _HomePageState extends State<HomePage> {
fontSize: 22,
),
),
Container(
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: primaryBlack,
borderRadius: BorderRadius.circular(15.0)),
child: Text(
'REGIONAL',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CountryPage()));
},
child: Container(
padding: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: primaryBlack,
borderRadius: BorderRadius.circular(15.0)),
child: Text(
'REGIONAL',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
)
Expand All @@ -114,6 +123,16 @@ class _HomePageState extends State<HomePage> {
? Container()
: MostAffectedPanel(countryData: countryData),
InfoPanel(),
SizedBox(height: 20),
Center(
child: Text(
'WE ARE TOGETHER IN THIS FIGHT!',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
),
),
),
SizedBox(height: 50),
],
),
Expand Down
119 changes: 119 additions & 0 deletions lib/pages/countryPage.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

class CountryPage extends StatefulWidget {
@override
_CountryPageState createState() => _CountryPageState();
}

class _CountryPageState extends State<CountryPage> {
List countryData;
fetchCountryData() async {
http.Response response = await http
.get('https://disease.sh/v2/countries?yesterday=false&sort=deaths');
setState(() {
countryData = json.decode(response.body);
});
}

@override
void initState() {
fetchCountryData();
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('COUNTRY DATA'),
),
body: countryData == null
? Center(
child: CircularProgressIndicator(),
)
: ListView.builder(
itemBuilder: (context, index) {
return Container(
height: 130,
margin: EdgeInsets.all(10),
decoration: BoxDecoration(color: Colors.white, boxShadow: [
BoxShadow(
color: Colors.grey[100],
blurRadius: 10,
offset: Offset(0, 10),
),
]),
child: Row(
children: <Widget>[
Container(
margin: EdgeInsets.symmetric(horizontal: 10),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
countryData[index]['country'],
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
Image.network(
countryData[index]['countryInfo']['flag'],
height: 40,
width: 60,
)
],
),
),
Expanded(
child: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'CONFIRMED ' +
countryData[index]['cases'].toString(),
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.red,
),
),
Text(
'ACTIVE' +
countryData[index]['active'].toString(),
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.blue,
),
),
Text(
'RECOVERED' +
countryData[index]['recovered'].toString(),
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.green,
),
),
Text(
'DEATHS' +
countryData[index]['deaths'].toString(),
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.grey[800],
),
),
],
),
),
),
],
),
);
},
itemCount: countryData == null ? 0 : countryData.length,
),
);
}
}
33 changes: 33 additions & 0 deletions lib/pages/faqs.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:covidapp/datasorce.dart';
import 'package:flutter/material.dart';

class FAQPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('FAQs'),
),
body: ListView.builder(
itemCount: DataSource.questionAnswers.length,
itemBuilder: (context, index) {
return ExpansionTile(
title: Text(
DataSource.questionAnswers[index]['question'],
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
children: <Widget>[
Padding(
padding: EdgeInsets.all(8.0),
child: Text(
DataSource.questionAnswers[index]['answer'],
),
),
],
);
}),
);
}
}
Loading

0 comments on commit 04cb96b

Please sign in to comment.