From 2a2b1ff269fd942a51c27ed08f53542538702bb5 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Tue, 26 Oct 2021 15:12:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/home/home_view/featured_acticvity.dart | 121 +++++++++++---------- lib/web/web_page.dart | 2 +- 2 files changed, 66 insertions(+), 57 deletions(-) diff --git a/lib/home/home_view/featured_acticvity.dart b/lib/home/home_view/featured_acticvity.dart index 3d1b9736..0782343e 100644 --- a/lib/home/home_view/featured_acticvity.dart +++ b/lib/home/home_view/featured_acticvity.dart @@ -39,13 +39,12 @@ class _FeaturedActivity extends State { "searchKey": "", "type": 1, "state": 1 - }).catchError((error) { - }); + }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { activityList = baseData.data.list; - if(activityList != null && activityList.length == 1) + if (activityList != null && activityList.length == 1) activityList.add(activityList[0]); - if(activityList != null && activityList.length == 2) + if (activityList != null && activityList.length == 2) activityList.add(activityList[1]); } } @@ -69,64 +68,66 @@ class _FeaturedActivity extends State { margin: EdgeInsets.symmetric(horizontal: 9.w), child: Row( children: [ - if(activityList != null && activityList.length > 0) - Container( - child: stackItem(18.sp,activityList[0]), - margin: EdgeInsets.symmetric(horizontal: 5.w), - width: (MediaQuery.of(context).size.width - 42) / 2, - height: 190.h, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: Colors.red, - image: DecorationImage( - image: NetworkImage( - activityList[0].coverImg, + if (activityList != null && activityList.length > 0) + Container( + child: stackItem(18.sp, activityList[0]), + margin: EdgeInsets.symmetric(horizontal: 5.w), + width: (MediaQuery.of(context).size.width - 42) / 2, + height: 190.h, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: Colors.red, + image: DecorationImage( + image: NetworkImage( + activityList[0].coverImg, + ), + fit: BoxFit.cover, ), - fit: BoxFit.cover, ), ), - ), - if(activityList != null && activityList.length > 1) - Container( - child: Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - Container( - child: stackItem(12.sp,activityList[1]), - margin: EdgeInsets.symmetric(horizontal: 5.w), - width: (MediaQuery.of(context).size.width - 42) / 2, - height: 190.h / 2, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: Colors.green, - image: DecorationImage( - image: NetworkImage( - activityList[1].coverImg, + if (activityList != null && activityList.length > 1) + Container( + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Container( + child: stackItem(12.sp, activityList[1]), + margin: EdgeInsets.symmetric(horizontal: 5.w), + width: (MediaQuery.of(context).size.width - 42) / 2, + height: 190.h / 2, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: Colors.green, + image: DecorationImage( + image: NetworkImage( + activityList[2].coverImg, + ), + fit: BoxFit.cover, ), - fit: BoxFit.cover, ), ), - ), - SizedBox(height: 5,), - Container( - child: stackItem(12.sp,activityList[2]), - margin: EdgeInsets.symmetric(horizontal: 5.w), - width: (MediaQuery.of(context).size.width - 42) / 2, - height: 190.h / 2, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(4), - color: Colors.blue, - image: DecorationImage( - image: NetworkImage( - activityList[2].coverImg, + SizedBox( + height: 5, + ), + Container( + child: stackItem(12.sp, activityList[2]), + margin: EdgeInsets.symmetric(horizontal: 5.w), + width: (MediaQuery.of(context).size.width - 42) / 2, + height: 190.h / 2, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(4), + color: Colors.blue, + image: DecorationImage( + image: NetworkImage( + activityList[2].coverImg, + ), + fit: BoxFit.cover, ), - fit: BoxFit.cover, ), - ), - ), - ], + ) + ], + ), ), - ), ], ), ), @@ -137,7 +138,7 @@ class _FeaturedActivity extends State { ); } - Widget stackItem(double textSize,Activity activity) { + Widget stackItem(double textSize, Activity activity) { return Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, @@ -149,6 +150,8 @@ class _FeaturedActivity extends State { children: [ Text( activity.mainTitle, + overflow: TextOverflow.ellipsis, + maxLines: 1, style: TextStyle( fontWeight: MyFontWeight.semi_bold, fontSize: textSize, @@ -181,7 +184,13 @@ class _FeaturedActivity extends State { borderRadius: BorderRadius.circular(20), ), alignment: Alignment.center, - child: Row( + child: + GestureDetector( + onTap: (){ + Navigator.of(context).pushNamed('/router/web_page', + arguments: {"activityId": activity.id}); + }, + child:Row( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ @@ -199,7 +208,7 @@ class _FeaturedActivity extends State { size: 12, ), ], - ), + )), ), ], ); diff --git a/lib/web/web_page.dart b/lib/web/web_page.dart index c5fc53be..9d397e17 100644 --- a/lib/web/web_page.dart +++ b/lib/web/web_page.dart @@ -271,7 +271,7 @@ class _WebPage extends State with WidgetsBindingObserver { /// 富文本的评论 CommentList( commentKey, - article?.likes ?? activity?.likes ?? "0", + article?.likes ?? activity?.likes.toString() ?? "0", article?.id ?? activity?.id, isKeyBoardShow, _reply,