You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
4.4 KiB

4 years ago
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
4 years ago
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/article.dart';
import 'package:huixiang/view_widget/custom_image.dart';
4 years ago
import 'package:huixiang/view_widget/icon_text.dart';
class HotArticleItem extends StatelessWidget {
4 years ago
final Article article;
4 years ago
4 years ago
HotArticleItem({this.article});
4 years ago
4 years ago
@override
Widget build(BuildContext context) {
4 years ago
return GestureDetector(
4 years ago
onTap: () {
4 years ago
Navigator.of(context).pushNamed('/router/store_detail_page', arguments: {
"html": article.content,
"title": article.mainTitle,
"author":article.author.name,
"time":article.createTime,
});
4 years ago
},
4 years ago
child: hotItem(context),
4 years ago
);
4 years ago
}
4 years ago
Widget hotItem(BuildContext context) {
4 years ago
return Container(
4 years ago
padding: EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(12),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
borderRadius: BorderRadius.circular(4),
),
child: Row(
children: [
Visibility(
4 years ago
visible: article != null &&
article.coverImg != null &&
article.coverImg != "",
4 years ago
child: Row(
4 years ago
children: [
4 years ago
Stack(
alignment: Alignment.center,
children: [
MImage(
4 years ago
article != null ? article.coverImg : "",
4 years ago
fit: BoxFit.cover,
4 years ago
radius: BorderRadius.circular(2),
aspectRatio: 1,
errorSrc: "assets/image/default_1.png",
fadeSrc: "assets/image/default_1.png",
4 years ago
),
4 years ago
Visibility(
4 years ago
visible: (article != null &&
article.coverImg != "" &&
article.coverImg.endsWith(".mp4")),
4 years ago
child: Icon(
Icons.play_circle_outline,
size: 24,
color: Colors.white,
),
),
],
),
SizedBox(
width: 12,
4 years ago
),
4 years ago
],
),
4 years ago
),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
4 years ago
article != null ? article.mainTitle : "",
4 years ago
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14.sp,
color: Colors.black,
4 years ago
),
4 years ago
),
Text(
4 years ago
article != null ? (article.viceTitle ?? "") : "",
4 years ago
maxLines: 2,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12.sp,
color: Color(0xFF353535),
4 years ago
),
4 years ago
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
IconText(
4 years ago
article != null ? article.createTime : "",
4 years ago
textStyle: TextStyle(
fontSize: 10.sp,
color: Color(0xFFB2B2B2),
4 years ago
),
4 years ago
leftIcon: Icons.access_time_rounded,
iconSize: 10,
iconColor: Color(0xFFB2B2B2),
),
Text(
S.of(context).zuozhe(
4 years ago
(article != null && article.author != null)
? article.author.name
4 years ago
: ""),
style: TextStyle(
fontSize: 10.sp,
color: Color(0xFFB2B2B2),
4 years ago
),
4 years ago
),
],
),
],
4 years ago
),
4 years ago
),
],
),
4 years ago
);
}
}