From cd2b2b411dd46487d63e03e3db3a9e8d2eace683 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Fri, 5 Nov 2021 18:43:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/community/community_course.dart | 2 ++ lib/community/community_view/class_details.dart | 4 ++-- lib/community/community_view/class_list_view.dart | 4 ++-- lib/community/community_view/home_class.dart | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/community/community_course.dart b/lib/community/community_course.dart index 93ba3cf5..a3b14de2 100644 --- a/lib/community/community_course.dart +++ b/lib/community/community_course.dart @@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/retrofit/data/banner.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; @@ -83,6 +84,7 @@ class _CommunityCourse extends State refreshController.refreshCompleted(); } else { refreshController.refreshFailed(); + // SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } EasyLoading.dismiss(); } diff --git a/lib/community/community_view/class_details.dart b/lib/community/community_view/class_details.dart index 706c4a34..3fdee0d4 100644 --- a/lib/community/community_view/class_details.dart +++ b/lib/community/community_view/class_details.dart @@ -180,7 +180,7 @@ class _ClassDetails extends State with WidgetsBindingObserver{ height: 24, ), onTap: () { - Navigator.of(context).pop(course.viewers+1); + Navigator.of(context).pop(course != null ? course.viewers+1 :0); }, ), ], @@ -369,7 +369,7 @@ class _ClassDetails extends State with WidgetsBindingObserver{ //自动播放 looping: false, //循环播放 - allowFullScreen: true, + allowFullScreen: false, // 拖动条样式颜色 materialProgressColors: chewie.ChewieProgressColors( playedColor: Colors.white, diff --git a/lib/community/community_view/class_list_view.dart b/lib/community/community_view/class_list_view.dart index 884b6b50..4622a8e8 100644 --- a/lib/community/community_view/class_list_view.dart +++ b/lib/community/community_view/class_list_view.dart @@ -38,7 +38,7 @@ class _ClassListView extends State { mainAxisSpacing: 16.w, //子Widget宽高比例 0.59 childAspectRatio: - 260 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), + 225 / (281 / 2 + (281 / 2) * AppUtils.textScale(context)), ), itemBuilder: (context, index) { return GestureDetector( @@ -160,7 +160,7 @@ class _ClassListView extends State { ], ), Expanded(child:Container( - padding: EdgeInsets.all(10), + padding: EdgeInsets.all(5), child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/community/community_view/home_class.dart b/lib/community/community_view/home_class.dart index a48984ea..8f330c45 100644 --- a/lib/community/community_view/home_class.dart +++ b/lib/community/community_view/home_class.dart @@ -65,7 +65,7 @@ class _HomeClass extends State { ), ),), Container( - height: 189, + height: 195, margin: EdgeInsets.only(top:10), child: ListView.builder( scrollDirection: Axis.horizontal, @@ -92,7 +92,7 @@ class _HomeClass extends State { Widget classItem(CourseList collect) { return Container( width: 168, - height: 189, + height: 195, decoration: BoxDecoration( borderRadius: BorderRadius.vertical( bottom: Radius.circular(4), @@ -222,7 +222,7 @@ class _HomeClass extends State { ), Expanded(child: Container( - padding: EdgeInsets.all(10), + padding: EdgeInsets.all(8), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, @@ -243,7 +243,7 @@ class _HomeClass extends State { ),), ], ), - SizedBox(height:5), + SizedBox(height:2), Text( "讲师:${collect.author.name}", overflow: TextOverflow.ellipsis, From 9b82b67a9fa4ef9d9fa8d9c9cead5d2b45460c9d Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Mon, 8 Nov 2021 18:03:10 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=BB=86=E8=8A=82bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/community/community_course.dart | 17 ++++++++++------- lib/community/community_view/class_details.dart | 15 --------------- lib/community/community_view/home_class.dart | 14 +++++++------- lib/view_widget/hot_item.dart | 9 +++++---- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/lib/community/community_course.dart b/lib/community/community_course.dart index a3b14de2..78d10567 100644 --- a/lib/community/community_course.dart +++ b/lib/community/community_course.dart @@ -3,7 +3,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/retrofit/data/banner.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; @@ -44,8 +43,8 @@ class _CommunityCourse extends State List classList = []; List classTabList = []; List collectList = []; - List collect = []; int checkIndex = 0; + Map> collectMap = new Map(); @override void initState() { @@ -166,8 +165,9 @@ class _CommunityCourse extends State setState(() { collectList.clear(); collectList.addAll(baseData.data); - if(collectList.length > 0) - collectCourse(collectList[0].id); + collectList.forEach((element) { + collectCourse(element.id); + }); }); } EasyLoading.dismiss(); @@ -187,8 +187,11 @@ class _CommunityCourse extends State }); if (baseData != null && baseData.isSuccess) { setState(() { - collect.clear(); - collect.addAll(baseData.data); + if(!collectMap.containsKey(collectId)){ + collectMap[collectId] = []; + } + collectMap[collectId].clear(); + collectMap[collectId].addAll(baseData.data); }); } } @@ -259,7 +262,7 @@ class _CommunityCourse extends State SizedBox(height: 28), ///合集列表 - HomeClass(collect,collectList,), + HomeClass(collectMap,collectList,), ///课程导航栏 ClassTitleTab(classSelectList,(index){ diff --git a/lib/community/community_view/class_details.dart b/lib/community/community_view/class_details.dart index 3fdee0d4..18a25480 100644 --- a/lib/community/community_view/class_details.dart +++ b/lib/community/community_view/class_details.dart @@ -523,21 +523,6 @@ class _ClassDetails extends State with WidgetsBindingObserver{ ); } - // ///给文章/活动点赞 - // _queryInformationLikes() async { - // BaseData baseData = await apiService.courseLikes(widget.arguments["id"]).catchError((onError) {}); - // if (baseData != null && baseData.isSuccess) { - // commentKey.currentState.setState(() {}); - // setState(() { - // comunity.likes -= 1; - // else - // comunity.likes += 1; - // - // }); - // } else { - // // SmartDialog.showToast(baseData.msg, alignment: Alignment.center); - // } - // } ///课程点赞 _queryCourseLikes() async { diff --git a/lib/community/community_view/home_class.dart b/lib/community/community_view/home_class.dart index 8f330c45..86903d5c 100644 --- a/lib/community/community_view/home_class.dart +++ b/lib/community/community_view/home_class.dart @@ -9,10 +9,10 @@ import 'package:huixiang/view_widget/custom_image.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class HomeClass extends StatefulWidget { - final List collect; + final Map> collectMap; final List collectList; - HomeClass(this.collect,this.collectList); + HomeClass(this.collectMap,this.collectList); @override State createState() { return _HomeClass(); @@ -47,7 +47,7 @@ class _HomeClass extends State { Widget collectItem(CollectClassList collectList) { return Container( width: 168, - height: 230, + // height: 250, margin: EdgeInsets.symmetric( horizontal: 6.w, vertical:10, @@ -71,15 +71,15 @@ class _HomeClass extends State { scrollDirection: Axis.horizontal, physics: BouncingScrollPhysics(), padding: EdgeInsets.symmetric(horizontal: 10), - itemCount:widget.collect == null ? 0 : widget.collect.length, + 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.collect[position].id}) - .then((value) => {widget.collect[position].viewers = value != null?value:widget.collect[position].viewers+1}); + 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.collect[position]), + child: classItem(widget.collectMap[collectList.id][position]), ); }, ), diff --git a/lib/view_widget/hot_item.dart b/lib/view_widget/hot_item.dart index f6f28574..79be95e1 100644 --- a/lib/view_widget/hot_item.dart +++ b/lib/view_widget/hot_item.dart @@ -169,7 +169,7 @@ class _HotArticleItem extends State { ), ), SizedBox(width: 12.w,), - Visibility( + Expanded(child: Visibility( visible: widget.article != null && widget.article.coverImg != null && widget.article.coverImg != "", @@ -193,7 +193,8 @@ class _HotArticleItem extends State { ), ], ), - ), + ),), + SizedBox(width:5.w,), ], )), @@ -484,7 +485,7 @@ class _HotArticleItem extends State { ), ), SizedBox( - width: 32.w, + width:22.w, ), Container( alignment: Alignment.topRight, @@ -508,7 +509,7 @@ class _HotArticleItem extends State { ), ), SizedBox( - width: 32.w, + width:22.w, ), Container( alignment: Alignment.topRight,