💄 Optimize news
This commit is contained in:
parent
180876949e
commit
687e720956
@ -12,7 +12,7 @@ post {
|
|||||||
|
|
||||||
body:json {
|
body:json {
|
||||||
{
|
{
|
||||||
"sources": ["shadiao"],
|
"sources": ["taiwan-yahoo"],
|
||||||
"eager": true
|
"eager": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,9 @@ class _NewsDetailScreenState extends State<NewsDetailScreen> {
|
|||||||
final width = double.tryParse(node.attributes['width'] ?? 'null');
|
final width = double.tryParse(node.attributes['width'] ?? 'null');
|
||||||
final height = double.tryParse(node.attributes['height'] ?? 'null');
|
final height = double.tryParse(node.attributes['height'] ?? 'null');
|
||||||
final ratio = width != null && height != null ? width / height : 1.0;
|
final ratio = width != null && height != null ? width / height : 1.0;
|
||||||
if (!src.startsWith('http')) {
|
if (src.startsWith('//')) {
|
||||||
|
src = 'https:$src';
|
||||||
|
} else if (!src.startsWith('http')) {
|
||||||
final baseUri = Uri.parse(_article!.url);
|
final baseUri = Uri.parse(_article!.url);
|
||||||
final baseUrl = '${baseUri.scheme}://${baseUri.host}';
|
final baseUrl = '${baseUri.scheme}://${baseUri.host}';
|
||||||
src = '$baseUrl/$src';
|
src = '$baseUrl/$src';
|
||||||
@ -120,7 +122,13 @@ class _NewsDetailScreenState extends State<NewsDetailScreen> {
|
|||||||
height: height ?? double.infinity,
|
height: height ?? double.infinity,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
borderRadius: BorderRadius.all(Radius.circular(8)),
|
||||||
child: AutoResizeUniversalImage(src, fit: BoxFit.cover),
|
child: Container(
|
||||||
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
child: AutoResizeUniversalImage(
|
||||||
|
src,
|
||||||
|
fit: width != null && height != null ? BoxFit.cover : BoxFit.contain,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -178,11 +178,17 @@ class _NewsArticleListWidgetState extends State<_NewsArticleListWidget> {
|
|||||||
children: [
|
children: [
|
||||||
if (article.thumbnail.isNotEmpty && !article.thumbnail.endsWith('.svg'))
|
if (article.thumbnail.isNotEmpty && !article.thumbnail.endsWith('.svg'))
|
||||||
ClipRRect(
|
ClipRRect(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(8)),
|
borderRadius: BorderRadius.only(
|
||||||
|
topRight: Radius.circular(8),
|
||||||
|
topLeft: Radius.circular(8),
|
||||||
|
),
|
||||||
child: AspectRatio(
|
child: AspectRatio(
|
||||||
aspectRatio: 16 / 9,
|
aspectRatio: 16 / 9,
|
||||||
child: AutoResizeUniversalImage(
|
child: Container(
|
||||||
article.thumbnail.startsWith('http') ? article.thumbnail : '$baseUrl/${article.thumbnail}',
|
color: Theme.of(context).colorScheme.surfaceContainer,
|
||||||
|
child: AutoResizeUniversalImage(
|
||||||
|
article.thumbnail.startsWith('http') ? article.thumbnail : '$baseUrl/${article.thumbnail}',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user