From fef6d9fabbcf6775175772a2db12c57e62f53bc7 Mon Sep 17 00:00:00 2001 From: w-R <953969641@qq.com> Date: Thu, 31 Mar 2022 16:27:09 +0800 Subject: [PATCH] 11 --- lib/community/community_child_page.dart | 89 +++++++++++++------------ 1 file changed, 46 insertions(+), 43 deletions(-) diff --git a/lib/community/community_child_page.dart b/lib/community/community_child_page.dart index b4c84200..9c8770de 100644 --- a/lib/community/community_child_page.dart +++ b/lib/community/community_child_page.dart @@ -18,7 +18,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; class CommunityChildPage extends StatefulWidget { final String typeStr; - CommunityChildPage(Key key, this.typeStr): super(key: key); + CommunityChildPage(Key key, this.typeStr) : super(key: key); @override State createState() { @@ -26,7 +26,8 @@ class CommunityChildPage extends StatefulWidget { } } -class CommunityChildPageState extends State with AutomaticKeepAliveClientMixin { +class CommunityChildPageState extends State + with AutomaticKeepAliveClientMixin { RefreshController refreshController = RefreshController(); ApiService apiService; int pageNum = 1; @@ -56,13 +57,13 @@ class CommunityChildPageState extends State with AutomaticKe token: value.getString("token"), ); } - if(isLoadMore){ + if (isLoadMore) { pageNum += 1; isLoadMore = false; - } - else pageNum = 1; + } else + pageNum = 1; BaseData> baseData = await apiService.trendList({ - "mid":"", + "mid": "", "onlyFollow": widget.typeStr == "关注" ? true : false, "onlyMe": false, "pageNum": pageNum, @@ -83,7 +84,7 @@ class CommunityChildPageState extends State with AutomaticKe var article = Article(); article.id = element.id; article.content = jsonEncode(element.subjectInfo); - article.mainTitle =element.subject; + article.mainTitle = element.subject; article.followed = element.selfFollow; article.authorHeadImg = element.memberInfo?.avatar; article.authorName = element.memberInfo?.nickname; @@ -125,44 +126,46 @@ class CommunityChildPageState extends State with AutomaticKe isLoadMore = true; setState(() {}); }, - child: (articles == null || articles.length == 0)? NoDataView( - src: "assets/image/guan_zhu.webp", - isShowBtn: false, - text: "目前暂无添加关注,可在推荐中关注自己喜欢的人哦~", - fontSize: 16.sp, - margin: EdgeInsets.only(top: 120.h,left: 60.w,right: 60.w), - ):ListView.builder( - physics: NeverScrollableScrollPhysics(), - itemBuilder: (context, position) { - return InkWell( - child: CommunityDynamic( - articles[position], - 0, - userId: userId, - isList: true, - exitFull: () { - setState(() { - onRefresh(); - }); + child: (articles == null || articles.length == 0) + ? NoDataView( + src: "assets/image/guan_zhu.webp", + isShowBtn: false, + text: "目前暂无添加关注,可在推荐中关注自己喜欢的人哦~", + fontSize: 16.sp, + margin: EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w), + ) + : ListView.builder( + physics: NeverScrollableScrollPhysics(), + itemBuilder: (context, position) { + return InkWell( + child: CommunityDynamic( + articles[position], + 0, + userId: userId, + isList: true, + exitFull: () { + setState(() { + onRefresh(); + }); + }, + ), + onTap: () { + Navigator.of(context).pushNamed( + '/router/community_details', + arguments: { + "businessId": articles[position].id, + "userId": userId, + }, + ).then((value) { + onRefresh(); + setState(() {}); + }); + setState(() {}); + }, + ); }, + itemCount: articles.length, ), - onTap: () { - Navigator.of(context).pushNamed( - '/router/community_details', - arguments: { - "businessId": articles[position].id, - "userId": userId, - }, - ).then((value) { - onRefresh(); - setState(() {}); - }); - setState(() {}); - }, - ); - }, - itemCount: articles.length, - ), ); }, );