Skip to content

Commit

Permalink
fixed the news article screen alignment and scrolling issue
Browse files Browse the repository at this point in the history
  • Loading branch information
avinath1998 committed Apr 8, 2020
1 parent 1ecc75b commit 15e4174
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 80 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";
6 changes: 0 additions & 6 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 @@ -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 @@ -460,7 +455,6 @@ class _DashboardScreenState extends State<DashboardScreen>
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,
Expand Down
150 changes: 80 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,84 @@ 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,
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>";

}
4 changes: 1 addition & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: Self tracking app
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.11.0+26
version: 1.10.0+25

environment:
sdk: ">=2.1.0 <3.0.0"
Expand Down Expand Up @@ -45,11 +45,9 @@ dependencies:
auto_size_text: ^2.1.0
flutter_html: ^0.11.1


flutter_localizations:
sdk: flutter


# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
Expand Down

0 comments on commit 15e4174

Please sign in to comment.