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.

268 lines
9.2 KiB

3 years ago
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_baidu_mapapi_base/flutter_baidu_mapapi_base.dart';
3 years ago
import 'package:huixiang/retrofit/data/collect_class_list.dart';
3 years ago
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 {
3 years ago
final Map<String,List<CourseList>> collectMap;
3 years ago
final List<CollectClassList> collectList;
3 years ago
3 years ago
HomeClass(this.collectMap,this.collectList);
3 years ago
@override
State<StatefulWidget> createState() {
return _HomeClass();
}
}
class _HomeClass extends State<HomeClass> {
ApiService apiService;
BMFCoordinate latLng;
final TextEditingController editingController = TextEditingController();
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
3 years ago
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,
3 years ago
// height: 250,
3 years ago
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(
3 years ago
height: 195,
3 years ago
margin: EdgeInsets.only(top:10),
child: ListView.builder(
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
padding: EdgeInsets.symmetric(horizontal: 10),
3 years ago
itemCount:widget.collectMap[collectList.id] == null ? 0 : widget.collectMap[collectList.id].length,
3 years ago
itemBuilder: (context, position) {
return GestureDetector(
onTap: () {
Navigator.of(context).pushNamed('/router/class_details',
3 years ago
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});
3 years ago
},
3 years ago
child: classItem(widget.collectMap[collectList.id][position]),
3 years ago
);
},
),
3 years ago
),
3 years ago
],
),
3 years ago
);
}
3 years ago
Widget classItem(CourseList collect) {
3 years ago
return Container(
width: 168,
3 years ago
height: 195,
3 years ago
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,
),
3 years ago
margin: EdgeInsets.symmetric(
3 years ago
horizontal:6,
3 years ago
),
child: Column(
children: [
3 years ago
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),
),
3 years ago
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(10),
offset: Offset(0, 3),
blurRadius: 14,
spreadRadius: 0,
)
],
color: Color.fromARGB(90, 0, 0, 0),
3 years ago
),
3 years ago
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),
),
3 years ago
),
),
3 years ago
Container(
padding: EdgeInsets.only(left: 4),
child:Row(
3 years ago
children: [
3 years ago
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,
),
),
],
3 years ago
),
3 years ago
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,
// ),
// ),
// ],
// ),
3 years ago
],
),
3 years ago
),
],
),
Container(
margin: EdgeInsets.only(top: 8,right: 8),
height: 16.h,
width: 30.w,
alignment: Alignment.center,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(2),
color: Color(0xFFFFCD00),
3 years ago
),
3 years ago
child: Text(
( collect?.tags != null && collect.tags.length > 0 )?collect.tags[0] : "",
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF634815),
),
3 years ago
),
3 years ago
),
],
),
Expanded(child:
Container(
3 years ago
padding: EdgeInsets.all(8),
3 years ago
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,
3 years ago
),
3 years ago
),),
],
),
3 years ago
SizedBox(height:2),
3 years ago
Text(
"讲师:${collect.author.name}",
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Colors.black,
3 years ago
),
3 years ago
),
],
3 years ago
),
3 years ago
),),
3 years ago
],
),
);
}
}