|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/base_data.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/comunity_comment.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/follow_list.dart';
|
|
|
|
import 'package:huixiang/retrofit/data/page.dart';
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart';
|
|
|
|
import 'package:huixiang/utils/font_weight.dart';
|
|
|
|
import 'package:huixiang/view_widget/classic_header.dart';
|
|
|
|
import 'package:huixiang/view_widget/custom_image.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_footer.dart';
|
|
|
|
import 'package:huixiang/view_widget/round_button.dart';
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
|
|
|
|
class FansPage extends StatefulWidget {
|
|
|
|
final Function refresh;
|
|
|
|
|
|
|
|
FansPage(
|
|
|
|
this.refresh
|
|
|
|
);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<StatefulWidget> createState() {
|
|
|
|
return _FansPage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class _FansPage extends State<FansPage> {
|
|
|
|
RefreshController _refreshController;
|
|
|
|
int pageNum = 1;
|
|
|
|
List<ListData> list = [];
|
|
|
|
ApiService apiService;
|
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
_refreshController = RefreshController();
|
|
|
|
|
|
|
|
SharedPreferences.getInstance().then((value) {
|
|
|
|
apiService =
|
|
|
|
ApiService(Dio(), context: context, token: value.getString("token"));
|
|
|
|
_queryFollowList();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
///我的关注列表
|
|
|
|
_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": true,
|
|
|
|
"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(() {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//关注/取关会员
|
|
|
|
_vipFollow(followId) async {
|
|
|
|
BaseData baseData = await apiService.follow(followId);
|
|
|
|
if (baseData != null && baseData.isSuccess) {
|
|
|
|
widget.refresh();
|
|
|
|
SmartDialog.showToast("关注成功", alignment: Alignment.center);
|
|
|
|
} else {
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
body: Container(
|
|
|
|
margin: EdgeInsets.only(top: 2),
|
|
|
|
color: Colors.white,
|
|
|
|
child: SmartRefresher(
|
|
|
|
enablePullDown: true,
|
|
|
|
enablePullUp: false,
|
|
|
|
header: MyHeader(),
|
|
|
|
footer: CustomFooter(
|
|
|
|
builder: (context, mode) {
|
|
|
|
return MyFooter(mode);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
controller: _refreshController,
|
|
|
|
// onRefresh: ,
|
|
|
|
physics: BouncingScrollPhysics(),
|
|
|
|
child: ListView.builder(
|
|
|
|
itemCount: list == null ? 0 : list.length,
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 8.h),
|
|
|
|
shrinkWrap: true,
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
itemBuilder: (context, position) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: () {},
|
|
|
|
child: fansItem(list[position]),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
// NoDataView(
|
|
|
|
// isShowBtn: false,
|
|
|
|
// text: "共关注0人",
|
|
|
|
// fontSize: 16.sp,
|
|
|
|
// margin: EdgeInsets.only(top: 120.h),
|
|
|
|
// ),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget fansItem(ListData list) {
|
|
|
|
return Container(
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 16.w, vertical: 16.h),
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
MImage(
|
|
|
|
list != null ? (list.avatar ?? "") : "",
|
|
|
|
width: 44,
|
|
|
|
height: 44,
|
|
|
|
isCircle: true,
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
errorSrc: "assets/image/default_1.png",
|
|
|
|
fadeSrc: "assets/image/default_1.png",
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width: 8,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
flex: 1,
|
|
|
|
child: Text(
|
|
|
|
list != null ? (list.nickname ?? "") : "",
|
|
|
|
style: TextStyle(
|
|
|
|
color: Color(0xFF1A1A1A),
|
|
|
|
fontSize: 14.sp,
|
|
|
|
fontWeight: MyFontWeight.medium,
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
Container(
|
|
|
|
width: 56.w,
|
|
|
|
height: 21.h,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(11.w),
|
|
|
|
color: Color(0xFF32A060),
|
|
|
|
),
|
|
|
|
child:
|
|
|
|
// GestureDetector(
|
|
|
|
// onTap: () {
|
|
|
|
// setState(() {
|
|
|
|
// if (widget.commentType == 0) {
|
|
|
|
// comment?.selfFollow =
|
|
|
|
// !(comment?.selfFollow ?? false);
|
|
|
|
// _vipFollow(list.mid);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// },
|
|
|
|
// child: (widget.commentType == 0)
|
|
|
|
// ? RoundButton(
|
|
|
|
// padding: EdgeInsets.symmetric(
|
|
|
|
// horizontal: 8,
|
|
|
|
// vertical: 3,
|
|
|
|
// ),
|
|
|
|
// backgroup: (comment?.selfFollow ?? false)
|
|
|
|
// ? Color(0xFFE6E6E6)
|
|
|
|
// : Color(0xFF32A060),
|
|
|
|
// textColor: (comment?.selfFollow ?? false)
|
|
|
|
// ? Color(0xFF808080)
|
|
|
|
// : Colors.white,
|
|
|
|
// text: (comment?.selfFollow ?? false) ? "已关注" : "关注",
|
|
|
|
// radius: 20,
|
|
|
|
// icons: Icon(
|
|
|
|
// (comment?.selfFollow ?? false)
|
|
|
|
// ? Icons.check
|
|
|
|
// : Icons.add,
|
|
|
|
// color: (comment?.selfFollow ?? false)
|
|
|
|
// ? Color(0xFF808080)
|
|
|
|
// : Colors.white,
|
|
|
|
// size: 14,
|
|
|
|
// ),
|
|
|
|
// )
|
|
|
|
// : Icon(
|
|
|
|
// Icons.close,
|
|
|
|
// color: Colors.black,
|
|
|
|
// size: 16,
|
|
|
|
// ),
|
|
|
|
// ),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
crossAxisAlignment:CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Icon(
|
|
|
|
Icons.add,
|
|
|
|
color: Colors.white,
|
|
|
|
size: 14,
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
width:4,
|
|
|
|
),
|
|
|
|
Text(
|
|
|
|
"关注",
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white,
|
|
|
|
fontSize: 12.sp,
|
|
|
|
fontWeight: MyFontWeight.regular,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|