Skip to content

Commit

Permalink
Fix tiles border on long press
Browse files Browse the repository at this point in the history
  • Loading branch information
Ritam Chakraborty committed Oct 13, 2020
1 parent bb0ee1d commit 0fd227b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 42 deletions.
4 changes: 4 additions & 0 deletions lib/data/constants.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';

const String GLOBAL_API = "https://disease.sh/v3/covid-19/all";
const String CONTINENT_API = "https://disease.sh/v3/covid-19/continents";
const String COUNTRY_API = "https://disease.sh/v3/covid-19/countries";

final NumberFormat NUMBER_FORMAT = NumberFormat.compact(locale: "en_us");
final ShapeBorder SHAPE = RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
);
46 changes: 23 additions & 23 deletions lib/providers/service_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@ class ServiceProvider extends ChangeNotifier {
List<Country> _countries;

Global get global {
_global = Global.fromMap(map: {
"updated": 1601909792858,
"cases": 35483998,
"todayCases": 93887,
"deaths": 1043087,
"todayDeaths": 1538,
"recovered": 26694334,
"todayRecovered": 79500,
"active": 7746577,
"critical": 66550,
"casesPerOneMillion": 4552,
"deathsPerOneMillion": 133.8,
"tests": 671031644,
"testsPerOneMillion": 86266.67,
"population": 7778573974,
"oneCasePerPeople": 0,
"oneDeathPerPeople": 0,
"oneTestPerPeople": 0,
"activePerOneMillion": 995.89,
"recoveredPerOneMillion": 3431.78,
"criticalPerOneMillion": 8.56,
"affectedCountries": 216
});
// _global = Global.fromMap(map: {
// "updated": 1601909792858,
// "cases": 35483998,
// "todayCases": 93887,
// "deaths": 1043087,
// "todayDeaths": 1538,
// "recovered": 26694334,
// "todayRecovered": 79500,
// "active": 7746577,
// "critical": 66550,
// "casesPerOneMillion": 4552,
// "deathsPerOneMillion": 133.8,
// "tests": 671031644,
// "testsPerOneMillion": 86266.67,
// "population": 7778573974,
// "oneCasePerPeople": 0,
// "oneDeathPerPeople": 0,
// "oneTestPerPeople": 0,
// "activePerOneMillion": 995.89,
// "recoveredPerOneMillion": 3431.78,
// "criticalPerOneMillion": 8.56,
// "affectedCountries": 216
// });

if (_global == null) {
_httpService.fetchGlobalData().then((Global global) {
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/continent_tile.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:coronatracker/data/constants.dart';
import 'package:coronatracker/models/continent.dart';
import 'package:coronatracker/pages/continent_page.dart';
import 'package:flutter/material.dart';
Expand All @@ -18,10 +19,9 @@ class ContinentTile extends StatelessWidget {
margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
child: Card(
elevation: 10.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
shape: SHAPE,
child: MaterialButton(
shape: SHAPE,
onPressed: () {
Navigator.push(
context,
Expand Down
26 changes: 13 additions & 13 deletions lib/widgets/country_tile.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:coronatracker/data/constants.dart';
import 'package:coronatracker/data/sorting.dart';
import 'package:coronatracker/models/country.dart';
import 'package:coronatracker/pages/country_page.dart';
Expand Down Expand Up @@ -42,10 +43,9 @@ class CountryTile extends StatelessWidget {
margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
child: Card(
elevation: 10.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
shape: SHAPE,
child: MaterialButton(
shape: SHAPE,
onPressed: () {
Navigator.push(
context,
Expand All @@ -58,16 +58,6 @@ class CountryTile extends StatelessWidget {
);
},
child: ListTile(
trailing: SizedBox(
height: 50,
width: 50,
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: HeroFlag(
country: _country,
),
),
),
title: Text(
_country.country,
style: TextStyle(fontSize: 20.0),
Expand All @@ -80,6 +70,16 @@ class CountryTile extends StatelessWidget {
],
),
),
trailing: SizedBox(
height: 50,
width: 50,
child: ClipRRect(
borderRadius: BorderRadius.circular(50),
child: HeroFlag(
country: _country,
),
),
),
leading: _index == null
? null
: Text(
Expand Down
6 changes: 3 additions & 3 deletions lib/widgets/tile_demo.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:coronatracker/data/constants.dart';
import 'package:coronatracker/widgets/text_demo.dart';
import 'package:flutter/material.dart';

Expand All @@ -15,10 +16,9 @@ class TileDemo extends StatelessWidget {
margin: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
child: Card(
elevation: 10.0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
shape: SHAPE,
child: MaterialButton(
shape: SHAPE,
onPressed: null,
child: ListTile(
title: TextDemo(
Expand Down

0 comments on commit 0fd227b

Please sign in to comment.