From 79df9962f24f48e6de9e2b137d8d916e66e1cae2 Mon Sep 17 00:00:00 2001 From: ivirtex Date: Fri, 13 Oct 2023 10:05:05 +0200 Subject: [PATCH] Fix overflow bug with article preview text --- lib/explore/widgets/articles_preview.dart | 2 +- lib/news/widgets/article_card.dart | 50 +++++++++++++---------- 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/lib/explore/widgets/articles_preview.dart b/lib/explore/widgets/articles_preview.dart index c354b2d..7bf0825 100644 --- a/lib/explore/widgets/articles_preview.dart +++ b/lib/explore/widgets/articles_preview.dart @@ -31,7 +31,7 @@ class ArticlesPreview extends StatelessWidget { child: Text('Latest News'), ), SizedBox( - height: 340, + height: 350, child: articles.isNotEmpty ? ListView.builder( scrollDirection: Axis.horizontal, diff --git a/lib/news/widgets/article_card.dart b/lib/news/widgets/article_card.dart index f883a4d..0c424e8 100644 --- a/lib/news/widgets/article_card.dart +++ b/lib/news/widgets/article_card.dart @@ -42,32 +42,38 @@ class ArticleCard extends StatelessWidget { dateFormat: DateFormat.yMMMd(), )!, ), - slideOutPadding: EdgeInsets.zero, - slideOut: ClipRRect( - borderRadius: const BorderRadius.vertical( - top: Radius.circular(kBorderRadius), - ), - child: SizedBox( - height: 150, - child: MissionImage( - fit: BoxFit.cover, - imageUrl: article.imageUrl, - ), - ), - ), + padding: EdgeInsets.zero, onTap: () => launchUrlString(article.url), child: Column( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.stretch, + mainAxisSize: MainAxisSize.min, children: [ - AutoSizeText( - article.title, - style: Theme.of(context).textTheme.titleMedium, + SizedBox( + height: 150, + child: MissionImage( + fit: BoxFit.cover, + imageUrl: article.imageUrl, + ), ), - const SizedBox(height: kListSpacing), - Text( - article.summary, - overflow: TextOverflow.ellipsis, - maxLines: 3, + Expanded( + child: Padding( + padding: const EdgeInsets.all(10), + child: Column( + children: [ + AutoSizeText( + article.title, + style: Theme.of(context).textTheme.titleMedium, + maxLines: 3, + ), + const SizedBox(height: kListSpacing), + Flexible( + child: AutoSizeText( + '${article.summary.split(' ').take(25).join(' ')}...', + ), + ), + ], + ), + ), ), ], ),