86 lines
2.4 KiB
Dart
86 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:le_kiosque_by_gcs/model/news.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
class ItemTopNews extends StatelessWidget {
|
|
const ItemTopNews({Key key, this.news}) : super(key: key);
|
|
|
|
final News news;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
height: 259,
|
|
width: 270,
|
|
child: InkWell(
|
|
onTap: () {
|
|
_showFullArticle(context, news.fullPostUrl);
|
|
},
|
|
child: Stack(
|
|
alignment: Alignment.bottomLeft,
|
|
children: [
|
|
Container(
|
|
height: 259,
|
|
width: 270,
|
|
decoration: BoxDecoration(
|
|
color: Colors.grey,
|
|
shape: BoxShape.rectangle,
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(10),
|
|
),
|
|
image: DecorationImage(
|
|
image: NetworkImage(news.previewUrl),
|
|
fit: BoxFit.cover,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
height: 259,
|
|
width: 270,
|
|
decoration: BoxDecoration(
|
|
color: Colors.black38,
|
|
shape: BoxShape.rectangle,
|
|
borderRadius: BorderRadius.all(
|
|
Radius.circular(10),
|
|
),
|
|
),
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.all(16.0),
|
|
child: Text(
|
|
news.title,
|
|
maxLines: 4,
|
|
style: TextStyle(
|
|
fontSize: 17,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 16, bottom: 16),
|
|
child: SizedBox(
|
|
height: 16,
|
|
child: Image.network(news.sourceUrl),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
void _showFullArticle(BuildContext context, String fullPostUrl) async {
|
|
if (await canLaunch(fullPostUrl)) {
|
|
await launch(fullPostUrl);
|
|
} else {
|
|
throw 'Could not launch $fullPostUrl';
|
|
}
|
|
}
|
|
}
|