import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart'; import 'package:huixiang/retrofit/data/collect_class_list.dart'; import 'package:huixiang/retrofit/data/course_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'; class HomeClass extends StatefulWidget { final Map> collectMap; final List collectList; HomeClass(this.collectMap,this.collectList); @override State createState() { return _HomeClass(); } } class _HomeClass extends State { ApiService apiService; BMFCoordinate latLng; final TextEditingController editingController = TextEditingController(); @override void initState() { super.initState(); } @override Widget build(BuildContext context) { return ListView.builder( padding: EdgeInsets.zero, itemCount:widget.collectList == null ? 0 : widget.collectList.length, scrollDirection: Axis.vertical, shrinkWrap: true, physics: NeverScrollableScrollPhysics(), itemBuilder: (context, position) { return collectItem(widget.collectList[position]); }, ); } Widget collectItem(CollectClassList collectList) { return Container( width: 168, // height: 250, margin: EdgeInsets.symmetric( horizontal: 6.w, vertical:10, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding(padding: EdgeInsets.only(left: 16,top: 5), child: Text( collectList.name, style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.medium, color: Colors.black, ), ),), Container( height: 195, margin: EdgeInsets.only(top:10), child: ListView.builder( scrollDirection: Axis.horizontal, physics: BouncingScrollPhysics(), padding: EdgeInsets.symmetric(horizontal: 10), itemCount:widget.collectMap[collectList.id] == null ? 0 : widget.collectMap[collectList.id].length, itemBuilder: (context, position) { return GestureDetector( onTap: () { Navigator.of(context).pushNamed('/router/class_details', arguments: {"id":widget.collectMap[collectList.id][position].id}) .then((value) => {widget.collectMap[collectList.id][position].viewers = value != null?value:widget.collectMap[collectList.id][position].viewers+1}); }, child: classItem(widget.collectMap[collectList.id][position]), ); }, ), ), ], ), ); } Widget classItem(CourseList collect) { return Container( width: 168, height: 195, decoration: BoxDecoration( borderRadius: BorderRadius.vertical( bottom: Radius.circular(4), ), boxShadow: [ BoxShadow( color: Colors.black.withAlpha(10), offset: Offset(0, 3), blurRadius: 14, spreadRadius: 0, ) ], color: Colors.white, ), margin: EdgeInsets.symmetric( horizontal:6, ), child: Column( children: [ Stack( alignment: Alignment.topRight, children: [ Stack( alignment: Alignment(0.9,0.9), children: [ Container( decoration: BoxDecoration( borderRadius: BorderRadius.only( topLeft: Radius.circular(4), topRight: Radius.circular(4), ), boxShadow: [ BoxShadow( color: Colors.black.withAlpha(10), offset: Offset(0, 3), blurRadius: 14, spreadRadius: 0, ) ], color: Color.fromARGB(90, 0, 0, 0), ), child: ClipRRect( child: Opacity( opacity: 0.6, child: MImage( collect.coverImg, width: double.infinity, height: 120, fit: BoxFit.cover, errorSrc: "assets/image/default_1.png", fadeSrc: "assets/image/default_1.png", ), ), borderRadius: BorderRadius.vertical( top: Radius.circular(4), ), ), ), Container( padding: EdgeInsets.only(left: 4), child:Row( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.asset( "assets/image/ketang_play.png", width: 16.w, height: 16.h, color: Colors.white, ), SizedBox(width:5), Text( collect.viewers.toString(), style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, color: Colors.white, ), ), ], ), SizedBox(width:8), // Row( // children: [ // Image.asset( // "assets/image/ketang_message.png", // width: 16.w, // height: 16.h, // color: Colors.white, // ), // SizedBox(width:5), // Text( // collect.viewers.toString(), // style: TextStyle( // fontSize: 12.sp, // fontWeight: MyFontWeight.regular, // color: Colors.white, // ), // ), // ], // ), ], ), ), ], ), Row( children: [ Spacer(), Container( margin: EdgeInsets.only(top: 8,right: 8), padding:EdgeInsets.only(left:2,right:2), height: 16.h, alignment: Alignment.center, decoration: BoxDecoration( borderRadius: BorderRadius.circular(2), color: Color(0xFFFFCD00), ), child: Text( ( collect?.tags != null && collect.tags.length > 0 )?collect.tags[0] : "", style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.medium, color: Color(0xFF634815), ), ), ), ],), ], ), Expanded(child: Container( padding: EdgeInsets.all(8), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded(child: Text( collect.subject, overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.semi_bold, color: Colors.black, ), ),), ], ), SizedBox(height:2), Text( "讲师:${collect.author.name}", overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, color: Colors.black, ), ), ], ), ),), ], ), ); } }