|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; |
|
|
|
|
import 'package:huixiang/retrofit/data/course_list.dart'; |
|
|
|
|
import 'package:huixiang/utils/flutter_utils.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
@ -27,37 +28,62 @@ class _ClassListView extends State<ClassListView> {
|
|
|
|
|
text: "当前分类暂无精彩内容", |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
margin: EdgeInsets.only( left: 60.w, right: 60.w,bottom: 30), |
|
|
|
|
): GridView.builder( |
|
|
|
|
itemCount:widget.classList == null ? 0 : widget.classList.length, |
|
|
|
|
padding: EdgeInsets.only( |
|
|
|
|
left: 16.w, |
|
|
|
|
right: 16.w, |
|
|
|
|
top: 13.h, |
|
|
|
|
bottom: 16.h, |
|
|
|
|
), |
|
|
|
|
): |
|
|
|
|
// GridView.builder( |
|
|
|
|
// itemCount:widget.classList == null ? 0 : widget.classList.length, |
|
|
|
|
// padding: EdgeInsets.only( |
|
|
|
|
// left: 16.w, |
|
|
|
|
// right: 16.w, |
|
|
|
|
// top: 13.h, |
|
|
|
|
// bottom: 16.h, |
|
|
|
|
// ), |
|
|
|
|
// shrinkWrap: true, |
|
|
|
|
// physics: NeverScrollableScrollPhysics(), |
|
|
|
|
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
|
// //一行的Widget数量 |
|
|
|
|
// crossAxisCount:2, |
|
|
|
|
// //水平子Widget之间间距 |
|
|
|
|
// crossAxisSpacing: 11.w, |
|
|
|
|
// //垂直子Widget之间间距 |
|
|
|
|
// mainAxisSpacing: 16.w, |
|
|
|
|
// //子Widget宽高比例 0.59 |
|
|
|
|
// childAspectRatio: |
|
|
|
|
// 225 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), |
|
|
|
|
// ), |
|
|
|
|
// itemBuilder: (context, index) { |
|
|
|
|
// return GestureDetector( |
|
|
|
|
// onTap: () { |
|
|
|
|
// Navigator.of(context).pushNamed('/router/class_details', |
|
|
|
|
// arguments: {"id": widget.classList[index].id}) |
|
|
|
|
// .then((value) => {widget.classList[index].viewers = value != null?value:widget.classList[index].viewers+1}); |
|
|
|
|
// }, |
|
|
|
|
// child: classListItem(widget.classList[index]), |
|
|
|
|
// ); |
|
|
|
|
// }, |
|
|
|
|
// ); |
|
|
|
|
StaggeredGridView.countBuilder( |
|
|
|
|
crossAxisCount: 2, |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( |
|
|
|
|
//一行的Widget数量 |
|
|
|
|
crossAxisCount:2, |
|
|
|
|
//水平子Widget之间间距 |
|
|
|
|
crossAxisSpacing: 11.w, |
|
|
|
|
//垂直子Widget之间间距 |
|
|
|
|
mainAxisSpacing: 16.w, |
|
|
|
|
//子Widget宽高比例 0.59 |
|
|
|
|
childAspectRatio: |
|
|
|
|
225 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), |
|
|
|
|
), |
|
|
|
|
itemBuilder: (context, index) { |
|
|
|
|
itemCount: widget.classList.length, |
|
|
|
|
mainAxisSpacing: 8, |
|
|
|
|
crossAxisSpacing: 8, |
|
|
|
|
padding: EdgeInsets.all(16), |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
// scrollDirection: Axis.vertical, |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap: () { |
|
|
|
|
onTap: (){ |
|
|
|
|
Navigator.of(context).pushNamed('/router/class_details', |
|
|
|
|
arguments: {"id": widget.classList[index].id}) |
|
|
|
|
.then((value) => {widget.classList[index].viewers = value != null?value:widget.classList[index].viewers+1}); |
|
|
|
|
arguments: {"id": widget.classList[position].id}) |
|
|
|
|
.then((value) => {widget.classList[position].viewers = value != null?value:widget.classList[position].viewers+1}); |
|
|
|
|
}, |
|
|
|
|
child: classListItem(widget.classList[index]), |
|
|
|
|
child: classListItem(widget.classList[position]), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
staggeredTileBuilder: (position) { |
|
|
|
|
// return StaggeredTile.count(1,position==0?1:1.2); |
|
|
|
|
return StaggeredTile.fit(1); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -106,7 +132,7 @@ class _ClassListView extends State<ClassListView> {
|
|
|
|
|
child:MImage( |
|
|
|
|
classList.coverImg, |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 120, |
|
|
|
|
height: 220.h, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
errorSrc: "assets/image/default_1.webp", |
|
|
|
|
fadeSrc: "assets/image/default_1.webp", |
|
|
|
@ -167,7 +193,7 @@ class _ClassListView extends State<ClassListView> {
|
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Expanded(child:Container( |
|
|
|
|
Container( |
|
|
|
|
padding: EdgeInsets.all(5), |
|
|
|
|
child: Column( |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
|
|
@ -179,24 +205,40 @@ class _ClassListView extends State<ClassListView> {
|
|
|
|
|
maxLines: 1, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
height: 1.5.h, |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(height: 2), |
|
|
|
|
SizedBox(height:5.h), |
|
|
|
|
Text( |
|
|
|
|
"讲师:${classList.author.name}", |
|
|
|
|
"简介 : ${classList.introduce}", |
|
|
|
|
overflow: TextOverflow.ellipsis, |
|
|
|
|
maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 13.sp, |
|
|
|
|
height: 1.2.h, |
|
|
|
|
fontWeight: MyFontWeight.medium, |
|
|
|
|
color: Colors.black, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
SizedBox(height:7.h), |
|
|
|
|
if(classList.author.name != "") |
|
|
|
|
Text( |
|
|
|
|
"讲师:${classList.author.name}", |
|
|
|
|
// overflow: TextOverflow.ellipsis, |
|
|
|
|
// maxLines: 2, |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
color: Colors.black, |
|
|
|
|
color: Color(0xFF32A060), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
if(classList.author.name != "") |
|
|
|
|
SizedBox(height:5.h), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
),) |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|