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.

288 lines
10 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/generated/l10n.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 {
final Map<String, List<CourseList>> collectMap;
3 years ago
final List<CollectClassList> collectList;
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,
3 years ago
scrollDirection: Axis.vertical,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (context, position) {
return collectItem(widget.collectList[position]);
},
);
}
Widget collectItem(CollectClassList collectList) {
return Container(
margin: EdgeInsets.symmetric(
horizontal: 6.w,
3 years ago
vertical: 10.h,
3 years ago
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
3 years ago
padding: EdgeInsets.only(left: 16.w, top: 5.h),
child: Text(
collectList.name,
style: TextStyle(
fontSize: 15.sp,
fontWeight: MyFontWeight.medium,
color: Colors.black,
),
3 years ago
),
),
3 years ago
Container(
2 years ago
height: 195.h,
3 years ago
margin: EdgeInsets.only(top: 10.h),
3 years ago
child: ListView.builder(
scrollDirection: Axis.horizontal,
physics: BouncingScrollPhysics(),
3 years ago
padding: EdgeInsets.symmetric(horizontal: 10.w),
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',
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(
3 years ago
width: 168.w,
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.w,
3 years ago
),
child: Column(
children: [
3 years ago
Stack(
alignment: Alignment.topRight,
children: [
Stack(
alignment: Alignment(0.9, 0.9),
3 years ago
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.7,
3 years ago
child: MImage(
collect.coverImg,
width: double.infinity,
3 years ago
height: 120.h,
3 years ago
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),
),
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.webp",
3 years ago
width: 16.w,
height: 16.h,
color: Colors.white,
),
3 years ago
SizedBox(width: 5.w),
3 years ago
Text(
collect.viewers.toString(),
style: TextStyle(
fontSize: 12.sp,
fontWeight: MyFontWeight.regular,
color: Colors.white,
),
),
],
3 years ago
),
3 years ago
SizedBox(width: 8.w),
3 years ago
// Row(
// children: [
// Image.asset(
// "assets/image/ketang_message.webp",
3 years ago
// 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
),
],
),
3 years ago
Row(
children: [
Spacer(),
Container(
3 years ago
margin: EdgeInsets.only(top: 8.h, right: 8.w),
padding: EdgeInsets.only(left: 2.w, right: 2.w),
height: 20.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]
: "",
overflow:TextOverflow.ellipsis,
style: TextStyle(
fontSize: 11.sp,
fontWeight: MyFontWeight.medium,
color: Color(0xFF634815),
),
3 years ago
),
3 years ago
),
],
),
3 years ago
],
),
Expanded(
child: Container(
3 years ago
padding: EdgeInsets.all(8.w),
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,
3 years ago
maxLines: 1,
style: TextStyle(
fontSize: 14.sp,
fontWeight: MyFontWeight.semi_bold,
color: Colors.black,
),
),
3 years ago
),
],
),
3 years ago
SizedBox(height: 2.h),
Text(
3 years ago
"${S.of(context).jiangshi}:${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
],
),
);
}
}