Skip to content

Commit

Permalink
Merge pull request #177 from avinath1998/master
Browse files Browse the repository at this point in the history
Aligned the stats, fixed html issues
  • Loading branch information
dewmal authored Apr 9, 2020
2 parents 1ecc75b + a87a648 commit 8769729
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 134 deletions.
1 change: 1 addition & 0 deletions android/settings_aar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':app'
2 changes: 1 addition & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
final bool debugRelease = false;
final bool debugRelease = true;
//final String testingServer = "https://test.covid-19.health.gov.lk/api";
final String testingServer = "https://test.covid-19.health.gov.lk/api";
162 changes: 102 additions & 60 deletions lib/page/screen/dashboard_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ class _DashboardScreenState extends State<DashboardScreen>
SharedPreferences prefs = await SharedPreferences.getInstance();
bool forceUpdate = true;

print("Fetching the articles");
int id = await ApiClient().getLastMessageId();
print("last fetched $id");
int lowerID = 1;
if (id >= 10) {
lowerID = id - 9;
Expand Down Expand Up @@ -132,7 +130,7 @@ class _DashboardScreenState extends State<DashboardScreen>
AppLocalizations.of(context).locale == Locale("ta", "TA")
? 100
: 60,
)
),
];
},
body: TabBarView(
Expand Down Expand Up @@ -189,9 +187,6 @@ class _DashboardScreenState extends State<DashboardScreen>
}

Widget _createNewsArticle(NewsArticle article) {
print(
"${article.id} ${article.title},${article.message} ${article.created}");

Icon _icon = Icon(
Icons.info,
color: Colors.blue,
Expand Down Expand Up @@ -357,7 +352,7 @@ class _DashboardScreenState extends State<DashboardScreen>
figure,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 20.0,
fontSize: 23.0,
color: colorCode),
),
),
Expand All @@ -369,7 +364,77 @@ class _DashboardScreenState extends State<DashboardScreen>

Widget _buildNewsScreen() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: FutureBuilder(
future: _articleFetch,
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return Center(
child: Text("An error has occured, try again"),
);
break;
case ConnectionState.waiting:
return Center(
child: CircularProgressIndicator(),
);
break;
case ConnectionState.active:
return Center(
child: Text("An error has occured, try again"),
);
break;
case ConnectionState.done:
return Consumer<StoriesModel>(
builder: (context, model, child) {
List<NewsArticle> stories = model.articles;
return ListView.builder(
itemCount: stories.length + 1,
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
return _buildTopStats();
} else
return _createNewsArticle(stories[index - 1]);
});
},
);
break;
default:
return Center(
child: CircularProgressIndicator(),
);
}
},
),
),
],
);
}

Widget _buildTopStats() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Padding(
// padding: const EdgeInsets.only(left: 15, top: 20.0),
// child: Text("ONGOING:",
// textAlign: TextAlign.start,
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.bold,
// fontSize: 15.0)),
// ),
// Padding(
// padding: const EdgeInsets.only(left: 15),
// child: Text("COVID-19 Statistics",
// textAlign: TextAlign.start,
// style: TextStyle(
// color: Colors.black,
// fontWeight: FontWeight.bold,
// fontSize: 30.0)),
// ),
Container(
width: double.maxFinite,
height: MediaQuery.of(context).size.height /
Expand All @@ -380,19 +445,37 @@ class _DashboardScreenState extends State<DashboardScreen>
padding: const EdgeInsets.all(10.0),
child: Row(
children: <Widget>[
_createCountCard(
AppLocalizations.of(context)
.translate("dashboard_confirmed_card_text"),
"$confirmed",
Color(0XFFc53030),
width: MediaQuery.of(context).size.width / 4,
Expanded(
child: Column(
children: <Widget>[
Expanded(
child: Container(
width: double.maxFinite,
height: MediaQuery.of(context).size.height / 2,
child: _createCountCard(
AppLocalizations.of(context)
.translate("dashboard_confirmed_card_text"),
"$confirmed",
Color(0XFFc53030),
width: MediaQuery.of(context).size.width / 4,
),
),
),
Expanded(
child: Container(
width: double.maxFinite,
height: MediaQuery.of(context).size.height / 2,
child: _createCountCard(
AppLocalizations.of(context)
.translate("dashboard_suspected_card_text"),
"$suspected",
Color(0XFFed8936),
width: MediaQuery.of(context).size.width / 4),
),
),
],
),
),
_createCountCard(
AppLocalizations.of(context)
.translate("dashboard_suspected_card_text"),
"$suspected",
Color(0XFFed8936),
width: MediaQuery.of(context).size.width / 4),
Expanded(
child: Column(
children: <Widget>[
Expand Down Expand Up @@ -437,47 +520,6 @@ class _DashboardScreenState extends State<DashboardScreen>
),
),
),
Expanded(
child: FutureBuilder(
future: _articleFetch,
builder: (context, snapshot) {
switch (snapshot.connectionState) {
case ConnectionState.none:
return Center(
child: Text("An error has occured, try again"),
);
break;
case ConnectionState.waiting:
return Center(
child: CircularProgressIndicator(),
);
break;
case ConnectionState.active:
return Center(
child: Text("An error has occured, try again"),
);
break;
case ConnectionState.done:
return Consumer<StoriesModel>(
builder: (context, model, child) {
print("CHANGED: ${model.articles.length}");
List<NewsArticle> stories = model.articles;
return ListView.builder(
itemCount: stories.length,
itemBuilder: (BuildContext context, int index) {
return _createNewsArticle(stories[index]);
});
},
);
break;
default:
return Center(
child: CircularProgressIndicator(),
);
}
},
),
),
],
);
}
Expand Down
151 changes: 81 additions & 70 deletions lib/page/screen/news_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class _NewsDetailScreenState extends State<NewsDetailScreen> {
@override
void initState() {
super.initState();
print(widget.article.message);
}

void _shareArticle(NewsArticle article) {
Expand Down Expand Up @@ -90,75 +91,85 @@ class _NewsDetailScreenState extends State<NewsDetailScreen> {
),
body: Container(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Text(
widget.article.title,
textAlign: TextAlign.start,
style: Theme.of(context).textTheme.title.copyWith(
fontWeight: FontWeight.bold,
),
),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"By ${widget.article.originator}",
textAlign: TextAlign.start,
style: Theme.of(context)
.textTheme
.body1
.copyWith(fontSize: 12),
),
Spacer(),
Text(
"${dateFormat.format(widget.article.created)}",
//published data needs to facilitated into the messages from the API
style: Theme.of(context)
.textTheme
.body1
.copyWith(fontSize: 12),
),
],
),
],
)
],
),
SizedBox(
height: 20,
),
SingleChildScrollView(
child: Html(
data: widget.article.message,
shrinkToFit: true,
customTextAlign: (val) {
return TextAlign.justify;
},
),
)
],
),
)));
padding: const EdgeInsets.all(0.0),
child: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Expanded(
child: Text(
widget.article.title,
textAlign: TextAlign.start,
style: Theme.of(context)
.textTheme
.title
.copyWith(
fontWeight: FontWeight.bold,
),
),
),
],
),
SizedBox(
height: 5,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(
"By ${widget.article.originator}",
textAlign: TextAlign.start,
style: Theme.of(context)
.textTheme
.body1
.copyWith(fontSize: 12),
),
Spacer(),
Text(
"${dateFormat.format(widget.article.created)}",
//published data needs to facilitated into the messages from the API
style: Theme.of(context)
.textTheme
.body1
.copyWith(fontSize: 12),
),
],
),
],
)
],
),
SizedBox(
height: 20,
),
Html(
data: widget.article.message,
shrinkToFit: false,
customTextAlign: (val) {
return TextAlign.justify;
},
),
],
),
),
))));
}

// var testhtml =
// "<div style=\"text-align: justify;\">\n <h2 style=\"line-height: 40.8%;\">What is Lorem Ipsum?</h2><p></p><p><strong>Lorem Ipsum</strong>&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p><h2 style=\"line-height: 40.8%;\">Why do we use it?</h2><p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here',</p><ol><li>one</li><li>two</li><li>three</li></ol><p></p>\n</div>";

}
Loading

0 comments on commit 8769729

Please sign in to comment.