From ad8454ca292c4cbd8f4794ae89c6c37140cb2c19 Mon Sep 17 00:00:00 2001 From: lcy <2503978335@qq.com> Date: Mon, 26 Jun 2023 18:53:37 +0800 Subject: [PATCH] feat:调整模型 --- lib/pages/home/bloc/home_bloc.dart | 3 +-- lib/pages/home/home_page.dart | 2 +- lib/pages/home/widgets/home_vidoe_item.dart | 80 ++++++++++++++++++++++++++++++++++++++++++++------------------------------------ 3 files changed, 46 insertions(+), 39 deletions(-) diff --git a/lib/pages/home/bloc/home_bloc.dart b/lib/pages/home/bloc/home_bloc.dart index 1daf7e2..6252675 100644 --- a/lib/pages/home/bloc/home_bloc.dart +++ b/lib/pages/home/bloc/home_bloc.dart @@ -24,8 +24,7 @@ class HomeBloc extends Bloc { Future requestData() async { try { await loading(() async { - await HomeDao.courseLesson(moduleId: moduleId??''); - // _modelData = await HomeDao.courseLesson(moduleId: moduleId??''); + _modelData = await HomeDao.courseLesson(moduleId: moduleId??''); emit(HomeDataLoadState()); }); } catch (e) { diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 2ad7be1..760a3c5 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -72,7 +72,7 @@ class _HomePageView extends StatelessWidget { ), Expanded( child: ListView.builder( - itemCount: 0, + itemCount: bloc.modelData?.totalCourseLesson, scrollDirection: Axis.horizontal, itemBuilder: (BuildContext context, int index){ String? title = bloc.modelData?.courseLessons?[index]?.name; diff --git a/lib/pages/home/widgets/home_vidoe_item.dart b/lib/pages/home/widgets/home_vidoe_item.dart index 3b21b46..a9ec31d 100644 --- a/lib/pages/home/widgets/home_vidoe_item.dart +++ b/lib/pages/home/widgets/home_vidoe_item.dart @@ -10,45 +10,53 @@ class HomeVideoItem extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - height: 202.h, - width: 165.w, - padding: EdgeInsets.symmetric(horizontal: 16.w,vertical: 12.h), - decoration: BoxDecoration( - image: DecorationImage( - image: AssetImage(''.assetPng) - ) - ), - child: Column( - children: [ - Container( - decoration: BoxDecoration( - border: Border.all( - width: 2, - color: const Color(0xFF140C10), - ), - borderRadius: BorderRadius.circular(6) + return Padding( + padding: EdgeInsets.symmetric(horizontal: 12.w), + child: Container( + width: 165.w, + padding: EdgeInsets.symmetric(horizontal: 16.w,vertical: 24.h), + decoration: BoxDecoration( + image: DecorationImage( + image: AssetImage('gendubeij'.assetPng), ), - child: Image.network(lessons?.coverUrl??''), - ), - Container( - decoration: BoxDecoration( - border: Border.all( - width: 2, - color: const Color(0xFF140C10), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + Expanded( + child: Container( + decoration: BoxDecoration( + border: Border.all( + width: 2, + color: const Color(0xFF140C10), + ), + borderRadius: BorderRadius.circular(6) + ), + child: Image.network( + lessons?.coverUrl??'', + fit: BoxFit.fill, + ), + )), + 24.verticalSpace, + Container( + decoration: BoxDecoration( + border: Border.all( + width: 2, + color: const Color(0xFF140C10), + ), + borderRadius: BorderRadius.circular(6) + ), + padding: EdgeInsets.symmetric(horizontal: 10.w), + child: Text( + lessons?.name??'', + style: TextStyle( + fontSize: 25.sp, + color: const Color(0xFF333333) ), - borderRadius: BorderRadius.circular(6) - ), - padding: EdgeInsets.symmetric(horizontal: 10.w,vertical: 8.h), - child: Text( - lessons?.name??'', - style: TextStyle( - fontSize: 25.sp, - color: const Color(0xFF333333) ), - ), - ) - ], + ) + ], + ), ), ); } -- libgit2 0.22.2