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.

169 lines
5.5 KiB

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
3 years ago
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/data/article.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/font_weight.dart';
import 'package:huixiang/view_widget/custom_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ActivityTopList extends StatefulWidget {
final List<Article> articleTop;
ActivityTopList(this.articleTop);
@override
State<StatefulWidget> createState() {
return _ActivityTopList();
}
}
class _ActivityTopList extends State<ActivityTopList> {
ApiService apiService;
BMFCoordinate latLng;
final TextEditingController editingController = TextEditingController();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
height: 220.h,
margin: EdgeInsets.only(top: 10),
child: ListView.builder(
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
padding: EdgeInsets.symmetric(horizontal: 10),
itemCount: widget.articleTop == null ? 0 : widget.articleTop.length,
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/web_page',
arguments: {"articleId": widget.articleTop[position].id});
widget.articleTop[position].viewers =
(widget.articleTop[position].viewers + 1);
setState(() {});
},
child: headlinesCollectionItem(widget.articleTop[position], position),
);
},
),
);
}
Widget headlinesCollectionItem(Article articles, index) {
return Container(
3 years ago
width: 340.w,
height: 220.h,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4),
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(10),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
color: Colors.black,
),
margin: EdgeInsets.symmetric(
horizontal: 6,
),
3 years ago
child:Column(
children: [
Stack(
3 years ago
alignment: Alignment.bottomLeft,
children: [
3 years ago
Stack(
children: [
ClipRRect(
child: Opacity(
opacity: 0.8,
child: MImage(
widget?.articleTop[index]?.coverImg ?? "",
width: 340.w,
height: 220.h,
fit: BoxFit.cover,
errorSrc: "assets/image/default_1.webp",
fadeSrc: "assets/image/default_1.webp",
),
3 years ago
),
borderRadius: BorderRadius.vertical(
top: Radius.circular(4),
bottom: Radius.circular(4),
),
),
Container(
padding: EdgeInsets.only(left: 12.w, right: 12.w, top: 8),
alignment: Alignment.topLeft,
child: Row(
children: [
Image.asset(
"assets/image/activity_hot.webp",
3 years ago
width: 20,
height: 20,
fit: BoxFit.fill,
),
3 years ago
SizedBox(
width: 4.w,
),
Expanded(
child: Text(
3 years ago
S.of(context).jingxuanhaowen,
3 years ago
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Colors.white,
),
),
),
],
)),
],
),
3 years ago
Padding(padding:EdgeInsets.only(left: 12.w, right: 12.w, bottom: 8),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget?.articleTop[index]?.mainTitle ?? "",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 16.sp,
fontWeight: MyFontWeight.semi_bold,
color: Colors.white,
),
),
SizedBox(height: 5.h),
Opacity(opacity:0.8,
child: Text(
widget?.articleTop[index]?.viceTitle ?? "",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Colors.white,
),
),)
3 years ago
],
)),
],
),
],
3 years ago
)
);
}
}