|
|
@ -36,7 +36,6 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe |
|
|
|
bool isRefresh = true; |
|
|
|
bool isRefresh = true; |
|
|
|
bool isLoadingData = false; |
|
|
|
bool isLoadingData = false; |
|
|
|
ScrollController sc = ScrollController(); |
|
|
|
ScrollController sc = ScrollController(); |
|
|
|
|
|
|
|
|
|
|
|
List<Article> articles = []; |
|
|
|
List<Article> articles = []; |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
@ -53,7 +52,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///动态列表 |
|
|
|
///动态列表 |
|
|
|
queryCommunity() async { |
|
|
|
queryCommunity(String searchKey) async { |
|
|
|
if(!isRefresh){ |
|
|
|
if(!isRefresh){ |
|
|
|
isRefresh = true; |
|
|
|
isRefresh = true; |
|
|
|
return; |
|
|
|
return; |
|
|
@ -76,45 +75,70 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe |
|
|
|
pageNum += 1; |
|
|
|
pageNum += 1; |
|
|
|
isLoadMore = false; |
|
|
|
isLoadMore = false; |
|
|
|
} |
|
|
|
} |
|
|
|
else pageNum = 1; |
|
|
|
else if(searchKey == null)pageNum = 1; |
|
|
|
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({ |
|
|
|
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({ |
|
|
|
"mid":"", |
|
|
|
"mid":"", |
|
|
|
"onlyFollow": widget.typeStr == "关注" ? true : false, |
|
|
|
"onlyFollow": widget.typeStr == "关注" ? true : false, |
|
|
|
"onlyMe": false, |
|
|
|
"onlyMe": false, |
|
|
|
"pageNum": pageNum, |
|
|
|
"pageNum": searchKey == null?pageNum:1, |
|
|
|
"pageSize": 10, |
|
|
|
"pageSize": 10, |
|
|
|
"searchKey": "" |
|
|
|
"searchKey": searchKey??"" |
|
|
|
}).catchError((error) { |
|
|
|
}).catchError((error) { |
|
|
|
refreshController.refreshFailed(); |
|
|
|
if(searchKey == null) { |
|
|
|
refreshController.loadFailed(); |
|
|
|
refreshController.refreshFailed(); |
|
|
|
|
|
|
|
refreshController.loadFailed(); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
if(searchKey == null) { |
|
|
|
refreshController.refreshCompleted(); |
|
|
|
refreshController.refreshCompleted(); |
|
|
|
refreshController.loadComplete(); |
|
|
|
refreshController.loadComplete(); |
|
|
|
|
|
|
|
} |
|
|
|
if (baseData.isSuccess) { |
|
|
|
if (baseData.isSuccess) { |
|
|
|
if (pageNum == 1) { |
|
|
|
if(searchKey != null){ |
|
|
|
articles.clear(); |
|
|
|
if(baseData?.data?.list != null && baseData.data.list.isNotEmpty) |
|
|
|
} |
|
|
|
articles.forEach((element) { |
|
|
|
baseData.data.list.forEach((element) { |
|
|
|
if(element.id == searchKey){ |
|
|
|
var article = Article(); |
|
|
|
element.content = jsonEncode(baseData.data.list[0].subjectInfo); |
|
|
|
article.id = element.id; |
|
|
|
element.mainTitle =baseData.data.list[0].subject; |
|
|
|
article.content = jsonEncode(element.subjectInfo); |
|
|
|
element.followed = baseData.data.list[0].selfFollow; |
|
|
|
article.mainTitle =element.subject; |
|
|
|
element.authorHeadImg = baseData.data.list[0].memberInfo?.avatar; |
|
|
|
article.followed = element.selfFollow; |
|
|
|
element.authorName = baseData.data.list[0].memberInfo?.nickname; |
|
|
|
article.authorHeadImg = element.memberInfo?.avatar; |
|
|
|
element.location = baseData.data.list[0].location; |
|
|
|
article.authorName = element.memberInfo?.nickname; |
|
|
|
element.createTime = baseData.data.list[0].createTime; |
|
|
|
article.location = element.location; |
|
|
|
element.author = baseData.data.list[0].memberInfo?.mid; |
|
|
|
article.createTime = element.createTime; |
|
|
|
element.viewers = baseData.data.list[0]?.viewers; |
|
|
|
article.author = element.memberInfo?.mid; |
|
|
|
element.likes = baseData.data.list[0]?.likes; |
|
|
|
article.viewers = element?.viewers; |
|
|
|
element.comments = baseData.data.list[0]?.comments; |
|
|
|
article.likes = element?.likes; |
|
|
|
this.isRefresh = false; |
|
|
|
article.comments = element?.comments; |
|
|
|
setState(() { |
|
|
|
articles.add(article); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
// comments.sort((a,b)=>b.createTime.compareTo(a.createTime)); |
|
|
|
}); |
|
|
|
// print("comments: ${comments.length}"); |
|
|
|
}else{ |
|
|
|
if (int.tryParse(baseData.data.total) < (pageNum * 10)) { |
|
|
|
if (pageNum == 1) { |
|
|
|
refreshController.loadNoData(); |
|
|
|
articles.clear(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
baseData.data.list.forEach((element) { |
|
|
|
|
|
|
|
var article = Article(); |
|
|
|
|
|
|
|
article.id = element.id; |
|
|
|
|
|
|
|
article.content = jsonEncode(element.subjectInfo); |
|
|
|
|
|
|
|
article.mainTitle =element.subject; |
|
|
|
|
|
|
|
article.followed = element.selfFollow; |
|
|
|
|
|
|
|
article.authorHeadImg = element.memberInfo?.avatar; |
|
|
|
|
|
|
|
article.authorName = element.memberInfo?.nickname; |
|
|
|
|
|
|
|
article.location = element.location; |
|
|
|
|
|
|
|
article.createTime = element.createTime; |
|
|
|
|
|
|
|
article.author = element.memberInfo?.mid; |
|
|
|
|
|
|
|
article.viewers = element?.viewers; |
|
|
|
|
|
|
|
article.likes = element?.likes; |
|
|
|
|
|
|
|
article.comments = element?.comments; |
|
|
|
|
|
|
|
articles.add(article); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
// comments.sort((a,b)=>b.createTime.compareTo(a.createTime)); |
|
|
|
|
|
|
|
// print("comments: ${comments.length}"); |
|
|
|
|
|
|
|
if (int.tryParse(baseData.data.total) < (pageNum * 10)) { |
|
|
|
|
|
|
|
refreshController.loadNoData(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -125,7 +149,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe |
|
|
|
Widget build(BuildContext context) { |
|
|
|
Widget build(BuildContext context) { |
|
|
|
super.build(context); |
|
|
|
super.build(context); |
|
|
|
return FutureBuilder( |
|
|
|
return FutureBuilder( |
|
|
|
future: queryCommunity(), |
|
|
|
future: queryCommunity(null), |
|
|
|
builder: (context, position) { |
|
|
|
builder: (context, position) { |
|
|
|
return SmartRefresher( |
|
|
|
return SmartRefresher( |
|
|
|
controller: refreshController, |
|
|
|
controller: refreshController, |
|
|
@ -172,7 +196,7 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe |
|
|
|
"userId": userId, |
|
|
|
"userId": userId, |
|
|
|
}, |
|
|
|
}, |
|
|
|
).then((value) { |
|
|
|
).then((value) { |
|
|
|
queryDetails(articles[position].id); |
|
|
|
queryCommunity(articles[position].id); |
|
|
|
// onRefresh(); |
|
|
|
// onRefresh(); |
|
|
|
// setState(() {}); |
|
|
|
// setState(() {}); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -187,32 +211,6 @@ class CommunityChildPageState extends State<CommunityChildPage> with AutomaticKe |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///详情接口 |
|
|
|
|
|
|
|
queryDetails(id) async { |
|
|
|
|
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
|
|
|
|
if (apiService == null) |
|
|
|
|
|
|
|
apiService = ApiService( |
|
|
|
|
|
|
|
Dio(), |
|
|
|
|
|
|
|
context: context, |
|
|
|
|
|
|
|
token: value.getString("token"), |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
BaseData<Article> baseData = await apiService.informationInfo(id) |
|
|
|
|
|
|
|
.catchError((onError) { |
|
|
|
|
|
|
|
debugPrint(onError.toString()); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
|
|
|
this.articles.forEach((element) { |
|
|
|
|
|
|
|
if(element.id == id){ |
|
|
|
|
|
|
|
isRefresh = false; |
|
|
|
|
|
|
|
setState(() { |
|
|
|
|
|
|
|
element.likes = baseData.data.likes; |
|
|
|
|
|
|
|
element.viewers = baseData.data.viewers; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
bool get wantKeepAlive => true; |
|
|
|
bool get wantKeepAlive => true; |
|
|
|
} |
|
|
|
} |
|
|
|