|
|
@ -3,7 +3,6 @@ import 'dart:convert'; |
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:huixiang/community/community_list.dart'; |
|
|
|
|
|
|
|
import 'package:huixiang/community/community_view/community_dynamic.dart'; |
|
|
|
import 'package:huixiang/community/community_view/community_dynamic.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/article.dart'; |
|
|
|
import 'package:huixiang/retrofit/data/article.dart'; |
|
|
@ -26,25 +25,24 @@ class ReleasePage extends StatefulWidget { |
|
|
|
|
|
|
|
|
|
|
|
class _ReleasePage extends State<ReleasePage> { |
|
|
|
class _ReleasePage extends State<ReleasePage> { |
|
|
|
RefreshController refreshController = RefreshController(); |
|
|
|
RefreshController refreshController = RefreshController(); |
|
|
|
final ScrollController scrollController = ScrollController(); |
|
|
|
|
|
|
|
ApiService apiService; |
|
|
|
ApiService apiService; |
|
|
|
int pageNum = 0; |
|
|
|
int pageNum = 0; |
|
|
|
String userId; |
|
|
|
String userId; |
|
|
|
bool isLoadMore = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ComunityComment> comments = []; |
|
|
|
List<Article> articles = []; |
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
void initState() { |
|
|
|
void initState() { |
|
|
|
super.initState(); |
|
|
|
super.initState(); |
|
|
|
|
|
|
|
|
|
|
|
_onRefresh(); |
|
|
|
_onRefresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_onRefresh() async { |
|
|
|
_onRefresh() async { |
|
|
|
queryCommunity(); |
|
|
|
pageNum = 0; |
|
|
|
|
|
|
|
setState(() {}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///动态列表 |
|
|
|
|
|
|
|
queryCommunity() async { |
|
|
|
queryCommunity() async { |
|
|
|
if (apiService == null) { |
|
|
|
if (apiService == null) { |
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
|
@ -55,10 +53,7 @@ class _ReleasePage extends State<ReleasePage> { |
|
|
|
token: value.getString("token"), |
|
|
|
token: value.getString("token"), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
if(isLoadMore){ |
|
|
|
|
|
|
|
pageNum += 1; |
|
|
|
pageNum += 1; |
|
|
|
isLoadMore = false; |
|
|
|
|
|
|
|
}else pageNum = 1; |
|
|
|
|
|
|
|
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({ |
|
|
|
BaseData<PageInfo<ComunityComment>> baseData = await apiService.trendList({ |
|
|
|
"onlyFollow": false, |
|
|
|
"onlyFollow": false, |
|
|
|
"onlyMe": true, |
|
|
|
"onlyMe": true, |
|
|
@ -74,9 +69,23 @@ class _ReleasePage extends State<ReleasePage> { |
|
|
|
refreshController.loadComplete(); |
|
|
|
refreshController.loadComplete(); |
|
|
|
if (baseData.isSuccess) { |
|
|
|
if (baseData.isSuccess) { |
|
|
|
if (pageNum == 1) { |
|
|
|
if (pageNum == 1) { |
|
|
|
comments.clear(); |
|
|
|
articles.clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
comments.addAll(baseData.data.list); |
|
|
|
baseData.data.list.forEach((element) { |
|
|
|
|
|
|
|
var article = Article(); |
|
|
|
|
|
|
|
article.id = element.id; |
|
|
|
|
|
|
|
article.content = jsonEncode(element.subjectInfo); |
|
|
|
|
|
|
|
article.mainTitle =element.subject; |
|
|
|
|
|
|
|
article.liked = element.selfFollow; |
|
|
|
|
|
|
|
article.authorHeadImg = element.memberInfo?.avatar; |
|
|
|
|
|
|
|
article.authorName = element.memberInfo?.nickname; |
|
|
|
|
|
|
|
article.createTime = element.createTime; |
|
|
|
|
|
|
|
article.updateUser = element.memberInfo?.mid; |
|
|
|
|
|
|
|
article.viewers = element?.viewers; |
|
|
|
|
|
|
|
article.likes = element?.likes; |
|
|
|
|
|
|
|
article.comments = element?.comments; |
|
|
|
|
|
|
|
articles.add(article); |
|
|
|
|
|
|
|
}); |
|
|
|
// print("comments: ${comments.length}"); |
|
|
|
// print("comments: ${comments.length}"); |
|
|
|
if (int.tryParse(baseData.data.total) < (pageNum * 10)) { |
|
|
|
if (int.tryParse(baseData.data.total) < (pageNum * 10)) { |
|
|
|
refreshController.loadNoData(); |
|
|
|
refreshController.loadNoData(); |
|
|
@ -110,35 +119,34 @@ class _ReleasePage extends State<ReleasePage> { |
|
|
|
), |
|
|
|
), |
|
|
|
onRefresh: _onRefresh, |
|
|
|
onRefresh: _onRefresh, |
|
|
|
onLoading: () { |
|
|
|
onLoading: () { |
|
|
|
isLoadMore = true; |
|
|
|
setState(() {}); |
|
|
|
_onRefresh(); |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
scrollController: scrollController, |
|
|
|
child: ListView.builder( |
|
|
|
child: Container( |
|
|
|
physics: NeverScrollableScrollPhysics(), |
|
|
|
child: SingleChildScrollView( |
|
|
|
itemBuilder: (context, position) { |
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
return InkWell( |
|
|
|
child: Container( |
|
|
|
child: CommunityDynamic( |
|
|
|
// color: Color(0xFFF7F7F7), |
|
|
|
articles[position], |
|
|
|
// margin: EdgeInsets.only(top: 16.h), |
|
|
|
|
|
|
|
child: Column( |
|
|
|
|
|
|
|
children: [ |
|
|
|
|
|
|
|
CommunityList( |
|
|
|
|
|
|
|
comments, |
|
|
|
|
|
|
|
userId, |
|
|
|
|
|
|
|
1, |
|
|
|
1, |
|
|
|
isList: true, |
|
|
|
exitFull: (){setState(() { |
|
|
|
exitFull: () { |
|
|
|
|
|
|
|
_onRefresh(); |
|
|
|
_onRefresh(); |
|
|
|
}, |
|
|
|
});}, |
|
|
|
removalDynamic: () { |
|
|
|
removalDynamic: () { |
|
|
|
_onRefresh(); |
|
|
|
_onRefresh(); |
|
|
|
}, |
|
|
|
}, |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
onTap: () { |
|
|
|
), |
|
|
|
Navigator.of(context).pushNamed( |
|
|
|
), |
|
|
|
'/router/community_details', |
|
|
|
), |
|
|
|
arguments: { |
|
|
|
),), |
|
|
|
"businessId": articles[position].id,"userId":userId, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
itemCount: articles.length, |
|
|
|
|
|
|
|
)), |
|
|
|
); |
|
|
|
); |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|