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'; import 'package:huixiang/retrofit/data/article.dart'; import 'package:huixiang/retrofit/data/collect_class_list.dart'; import 'package:huixiang/retrofit/data/course_list.dart'; import 'package:huixiang/retrofit/data/headlines_list.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'; import 'package:huixiang/view_widget/new_people_reward.dart'; class ActivityTopList extends StatefulWidget { final List
articleTop; ActivityTopList(this.articleTop); @override State createState() { return _ActivityTopList(); } } class _ActivityTopList extends State { 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/headlines_column_details', arguments: {"id": widget.articleTop[position].id}); }, child: headlinesCollectionItem(widget.articleTop[position], position), ); }, ), ); } Widget headlinesCollectionItem(Article articles, index) { return Container( 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, ), child:Column( children: [ Stack( alignment: Alignment.bottomLeft, children: [ 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.png", fadeSrc: "assets/image/default_1.png", ), ), 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.png", width: 20, height: 20, fit: BoxFit.fill, ), SizedBox( width: 4.w, ), Expanded( child: Text( "精选好文", overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.semi_bold, color: Colors.white, ), ), ), ], )), ], ), 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, ), ),) ], )), ], ), ], ) ); } }