This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 260
/
article_item.dart
62 lines (58 loc) · 1.9 KB
/
article_item.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import 'package:app/constants.dart';
import 'package:app/data/model/article.dart';
import 'package:app/util/ext/context.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class ArticleItem extends StatelessWidget {
const ArticleItem({@required Article article}) : _article = article;
final Article _article;
static BorderRadius borderRadiusAll = BorderRadius.circular(8.0);
static BorderRadius borderRadiusTop = const BorderRadius.only(
topRight: Radius.circular(8.0),
topLeft: Radius.circular(8.0),
bottomLeft: Radius.circular(0.0),
bottomRight: Radius.circular(0.0),
);
@override
Widget build(BuildContext context) {
return Card(
shape: RoundedRectangleBorder(borderRadius: borderRadiusAll),
elevation: 4,
child: GestureDetector(
child: Column(
children: <Widget>[
Hero(
tag: _article.url,
child: SizedBox(
width: double.infinity,
height: 200,
child: ClipRRect(
borderRadius: borderRadiusTop,
child: _article.urlToImage == null
? Image.asset(
'assets/images/article_placeholder.webp',
fit: BoxFit.cover,
)
: Image.network(
_article.urlToImage,
fit: BoxFit.cover,
),
)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
_article.title,
style: const TextStyle(fontSize: 12),
),
),
],
),
onTap: () => context.navigator.pushNamed(
Constants.PAGE_DETAIL,
arguments: _article,
),
),
);
}
}