Browse Source

布局更改;

zyh
w-R 3 years ago
parent
commit
b901995bd3
  1. 69
      lib/community/community_child_page.dart

69
lib/community/community_child_page.dart

@ -20,7 +20,8 @@ class CommunityChildPage extends StatefulWidget {
final Function onScroll;
final Function toRelease;
CommunityChildPage(Key key, this.typeStr,this.onScroll,this.toRelease): super(key: key);
CommunityChildPage(Key key, this.typeStr, this.onScroll, this.toRelease)
: super(key: key);
@override
State<StatefulWidget> createState() {
@ -28,7 +29,8 @@ class CommunityChildPage extends StatefulWidget {
}
}
class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKeepAliveClientMixin {
class CommunityChildPageState extends State<CommunityChildPage>
with AutomaticKeepAliveClientMixin {
RefreshController refreshController = RefreshController();
ApiService apiService;
int pageNum = 1;
@ -54,53 +56,50 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
///
queryCommunity(String searchKey) async {
if(!isRefresh){
if (!isRefresh) {
isRefresh = true;
return;
}
if(isLoadingData){
if (isLoadingData) {
return;
}
isLoadingData = true;
if (apiService == null) {
SharedPreferences value = await SharedPreferences.getInstance();
userId = value.getString('userId');
apiService = ApiService(
Dio(),
apiService = ApiService(Dio(),
context: context,
token: value.getString("token"),
showLoading: false
);
showLoading: false);
}
if(isLoadMore){
if (isLoadMore) {
pageNum += 1;
isLoadMore = false;
}
else if(searchKey == null)pageNum = 1;
} else if (searchKey == null) pageNum = 1;
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({
"mid":"",
"mid": "",
"onlyFollow": widget.typeStr == "关注" ? true : false,
"onlyMe": false,
"pageNum": searchKey == null?pageNum:1,
"pageNum": searchKey == null ? pageNum : 1,
"pageSize": 10,
"searchKey": searchKey??""
"searchKey": searchKey ?? ""
}).catchError((error) {
if(searchKey == null) {
if (searchKey == null) {
refreshController.refreshFailed();
refreshController.loadFailed();
}
});
if(searchKey == null) {
if (searchKey == null) {
refreshController.refreshCompleted();
refreshController.loadComplete();
}
if (baseData.isSuccess) {
if(searchKey != null){
if(baseData?.data?.list != null && baseData.data.list.isNotEmpty)
if (searchKey != null) {
if (baseData?.data?.list != null && baseData.data.list.isNotEmpty)
articles.forEach((element) {
if(element.id == searchKey){
if (element.id == searchKey) {
element.content = jsonEncode(baseData.data.list[0].subjectInfo);
element.mainTitle =baseData.data.list[0].subject;
element.mainTitle = baseData.data.list[0].subject;
element.followed = baseData.data.list[0].selfFollow;
element.authorHeadImg = baseData.data.list[0].memberInfo?.avatar;
element.authorName = baseData.data.list[0].memberInfo?.nickname;
@ -111,11 +110,10 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
element.likes = baseData.data.list[0]?.likes;
element.comments = baseData.data.list[0]?.comments;
this.isRefresh = false;
setState(() {
});
setState(() {});
}
});
}else{
} else {
if (pageNum == 1) {
articles.clear();
}
@ -123,7 +121,7 @@ class CommunityChildPageState extends State<CommunityChildPage> 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;
@ -152,7 +150,10 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
return FutureBuilder(
future: queryCommunity(null),
builder: (context, position) {
return SmartRefresher(
return Stack(
alignment: Alignment.bottomRight,
children: [
SmartRefresher(
controller: refreshController,
enablePullDown: true,
enablePullUp: true,
@ -168,18 +169,16 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
isLoadMore = true;
setState(() {});
},
child: Stack(
alignment: Alignment.bottomRight,
children: [
(articles == null || articles.length == 0)? NoDataView(
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),
margin:
EdgeInsets.only(top: 120.h, left: 60.w, right: 60.w),
)
:
ListView.builder(
: ListView.builder(
controller: sc,
shrinkWrap: true,
itemBuilder: (context, position) {
@ -212,12 +211,13 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
},
itemCount: articles.length,
),
),
GestureDetector(
onTap: (){
onTap: () {
widget.toRelease();
},
child: Container(
margin: EdgeInsets.only(bottom:31,right: 14),
margin: EdgeInsets.only(bottom: 31, right: 14),
child: Image.asset(
"assets/image/fa_bu.webp",
width: 55,
@ -226,7 +226,6 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe
),
)
],
),
);
},
);

Loading…
Cancel
Save