|
|
|
@ -1,12 +1,24 @@
|
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flutter/cupertino.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
|
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
|
|
|
import '../../retrofit/data/base_data.dart'; |
|
|
|
|
import '../../retrofit/data/follow_list.dart'; |
|
|
|
|
import '../../retrofit/data/page.dart'; |
|
|
|
|
import '../../retrofit/retrofit_api.dart'; |
|
|
|
|
import 'package:huixiang/im/database/message.dart'; |
|
|
|
|
|
|
|
|
|
import '../../view_widget/custom_image.dart'; |
|
|
|
|
import '../../view_widget/no_data_view.dart'; |
|
|
|
|
|
|
|
|
|
class FriendGroupList extends StatefulWidget { |
|
|
|
|
final String isMyFans; |
|
|
|
|
final String title; |
|
|
|
|
|
|
|
|
|
FriendGroupList( |
|
|
|
|
Key key, |
|
|
|
|
Key key,this.isMyFans,this.title |
|
|
|
|
) : super(key: key); |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@ -18,11 +30,22 @@ class FriendGroupList extends StatefulWidget {
|
|
|
|
|
class _FriendGroupList extends State<FriendGroupList> { |
|
|
|
|
ApiService apiService; |
|
|
|
|
final TextEditingController editingController = TextEditingController(); |
|
|
|
|
RefreshController _refreshController; |
|
|
|
|
FocusNode _focusNode = FocusNode(); |
|
|
|
|
List<String> userIds = []; |
|
|
|
|
List<Message> messages = []; |
|
|
|
|
int pageNum = 1; |
|
|
|
|
List<ListData> list = []; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
|
super.initState(); |
|
|
|
|
// loadMessageList(); |
|
|
|
|
if( widget.isMyFans == ""){ |
|
|
|
|
queryMutualFollowList(); |
|
|
|
|
} else{ |
|
|
|
|
queryFollowList(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///离开页面记着销毁和清除 |
|
|
|
@ -32,6 +55,86 @@ class _FriendGroupList extends State<FriendGroupList> {
|
|
|
|
|
super.dispose(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// loadMessageList() async { |
|
|
|
|
// SharedPreferences shared = await SharedPreferences.getInstance(); |
|
|
|
|
// String userId = shared.getString("userId"); |
|
|
|
|
// messages = await hxDatabase.queryList(userId); |
|
|
|
|
// messages.forEach((element) { |
|
|
|
|
// debugPrint("messages: ${element.toJson()}"); |
|
|
|
|
// }); |
|
|
|
|
// userIds = messages |
|
|
|
|
// .map((e) => e.toId != userId ? e.toId : e.fromId) |
|
|
|
|
// .toSet().where((element) => element != userId) |
|
|
|
|
// .toList(); |
|
|
|
|
// if (mounted) { |
|
|
|
|
// setState(() {}); |
|
|
|
|
// } |
|
|
|
|
// |
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
///关注、粉丝列表 |
|
|
|
|
queryFollowList() async { |
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|
if (apiService == null) |
|
|
|
|
apiService = ApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: sharedPreferences.getString("token"), |
|
|
|
|
showLoading: false, |
|
|
|
|
); |
|
|
|
|
BaseData<PageInfo<ListData>> baseData = await apiService.followList({ |
|
|
|
|
"isMyFans": widget.isMyFans, |
|
|
|
|
"pageNum": pageNum, |
|
|
|
|
"pageSize": 100, |
|
|
|
|
}).catchError((error) { |
|
|
|
|
_refreshController.refreshFailed(); |
|
|
|
|
_refreshController.loadFailed(); |
|
|
|
|
}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
if (pageNum == 1) { |
|
|
|
|
list.clear(); |
|
|
|
|
} |
|
|
|
|
list.addAll(baseData.data.list); |
|
|
|
|
setState(() {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///好友列表 |
|
|
|
|
queryMutualFollowList() async { |
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance(); |
|
|
|
|
if (apiService == null) |
|
|
|
|
apiService = ApiService( |
|
|
|
|
Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: sharedPreferences.getString("token"), |
|
|
|
|
showLoading: false, |
|
|
|
|
); |
|
|
|
|
BaseData<PageInfo<ListData>> baseData = await apiService.mutualFollowList({ |
|
|
|
|
"isMyFans": widget.isMyFans, |
|
|
|
|
"pageNum": 1, |
|
|
|
|
"pageSize": 100, |
|
|
|
|
}).catchError((error) { |
|
|
|
|
_refreshController.refreshFailed(); |
|
|
|
|
_refreshController.loadFailed(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
_refreshController.refreshCompleted(); |
|
|
|
|
_refreshController.loadComplete(); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
if (pageNum == 1) { |
|
|
|
|
list.clear(); |
|
|
|
|
} |
|
|
|
|
list.addAll(baseData.data.list); |
|
|
|
|
print("list: ${list.length}"); |
|
|
|
|
if (int.tryParse(baseData.data.total) < (pageNum * 10)) { |
|
|
|
|
_refreshController.loadNoData(); |
|
|
|
|
} |
|
|
|
|
setState(() {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Container( |
|
|
|
@ -39,13 +142,30 @@ class _FriendGroupList extends State<FriendGroupList> {
|
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
friendGroupSearch(), |
|
|
|
|
Expanded( |
|
|
|
|
(list == null || list.length == 0) |
|
|
|
|
? NoDataView( |
|
|
|
|
src: "assets/image/guan_zhu.webp", |
|
|
|
|
isShowBtn: false, |
|
|
|
|
text: "目前暂无${widget?.title ?? ""},听说多发动态可以涨粉哦~", |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
margin: EdgeInsets.only(top: 120.h,left: 60.w,right: 60.w), |
|
|
|
|
):Expanded( |
|
|
|
|
child: ListView.builder( |
|
|
|
|
itemCount: 10, |
|
|
|
|
itemCount: list.length ?? 0, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
shrinkWrap: true, |
|
|
|
|
itemBuilder: (context, position) { |
|
|
|
|
return friendGroupItem(); |
|
|
|
|
return GestureDetector( |
|
|
|
|
onTap:(){ |
|
|
|
|
Navigator.of(context).pushNamed( |
|
|
|
|
'/router/chat_details_page', |
|
|
|
|
arguments: { |
|
|
|
|
"toId":list[position].mid, |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
child:friendGroupItem(list[position]), |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
)), |
|
|
|
|
], |
|
|
|
@ -53,7 +173,7 @@ class _FriendGroupList extends State<FriendGroupList> {
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget friendGroupItem() { |
|
|
|
|
Widget friendGroupItem(ListData list) { |
|
|
|
|
return Container( |
|
|
|
|
margin: EdgeInsets.only(left:16.w,right:16.w,bottom: 24.h), |
|
|
|
|
child: Row(children: [ |
|
|
|
@ -61,17 +181,20 @@ class _FriendGroupList extends State<FriendGroupList> {
|
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(26.5.r), |
|
|
|
|
), |
|
|
|
|
child: Image.asset( |
|
|
|
|
"assets/image/bs_mine_heading.webp", |
|
|
|
|
width: 54.h, |
|
|
|
|
height: 54.h, |
|
|
|
|
fit: BoxFit.fill, |
|
|
|
|
child: MImage( |
|
|
|
|
list?.avatar ?? "", |
|
|
|
|
isCircle: true, |
|
|
|
|
width: 66, |
|
|
|
|
height: 66, |
|
|
|
|
fit: BoxFit.cover, |
|
|
|
|
errorSrc: "assets/image/default_user.webp", |
|
|
|
|
fadeSrc: "assets/image/default_user.webp", |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
Padding( |
|
|
|
|
padding: EdgeInsets.only(left: 4.w), |
|
|
|
|
child: Text( |
|
|
|
|
"哈喽喽哈", |
|
|
|
|
list?.nickname ?? "", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontSize: 16.sp, |
|
|
|
|
color: Color(0xFF060606), |
|
|
|
|