You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
3.1 KiB
111 lines
3.1 KiB
import 'package:dio/dio.dart'; |
|
import 'package:flutter/material.dart'; |
|
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
|
import 'package:huixiang/mine/follow_page.dart'; |
|
import 'package:huixiang/data/base_data.dart'; |
|
import 'package:huixiang/data/social_info.dart'; |
|
import 'package:huixiang/retrofit/retrofit_api.dart'; |
|
import 'package:huixiang/utils/font_weight.dart'; |
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
import 'package:huixiang/view_widget/my_tab.dart'; |
|
import 'package:shared_preferences/shared_preferences.dart'; |
|
import '../fans_page.dart'; |
|
|
|
class CommunityFollow extends StatefulWidget { |
|
|
|
final Map<String, dynamic>? arguments; |
|
|
|
CommunityFollow({this.arguments}); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _CommunityFollow(); |
|
} |
|
} |
|
|
|
class _CommunityFollow extends State<CommunityFollow> |
|
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { |
|
ApiService? apiService; |
|
SocialInfo? infoNumber; |
|
late int status; |
|
|
|
@override |
|
void initState() { |
|
super.initState(); |
|
status = widget.arguments?["status"] ?? 0; |
|
querySocialInfo(); |
|
} |
|
|
|
///个人社交信息(粉丝/关注数量/成就数量) |
|
querySocialInfo() async { |
|
SharedPreferences value = await SharedPreferences.getInstance(); |
|
apiService = ApiService(Dio(), |
|
context: context, |
|
token: value.getString("token"), |
|
showLoading: true |
|
); |
|
|
|
BaseData<SocialInfo>? baseData = await apiService?.socialInfo().catchError((onError) {}); |
|
if (baseData?.isSuccess ?? false) { |
|
setState(() { |
|
infoNumber = baseData?.data; |
|
}); |
|
} |
|
EasyLoading.dismiss(); |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
super.build(context); |
|
return DefaultTabController( |
|
length: 2, |
|
initialIndex: status, |
|
child: Scaffold( |
|
appBar: MyAppBar( |
|
title: "", |
|
titleColor: Colors.black, |
|
background: Colors.white, |
|
leadingColor: Colors.black, |
|
bottom: TabBar( |
|
// isScrollable: true, //可滚动 |
|
indicatorColor: Color(0xff39B54A), |
|
labelColor: Colors.black, |
|
labelStyle: TextStyle( |
|
fontSize: 17.sp, |
|
fontWeight: FontWeight.bold, |
|
), |
|
unselectedLabelStyle: TextStyle( |
|
fontSize: 16.sp, |
|
fontWeight: MyFontWeight.medium, |
|
), |
|
// controller: tabController, |
|
//未选中文字颜色 |
|
unselectedLabelColor: Color(0xffA29E9E), |
|
indicatorSize: TabBarIndicatorSize.label, |
|
//指示器与文字等宽 |
|
tabs: <Widget>[ |
|
MyTab( |
|
text: "关注${infoNumber?.follow ?? "0"}", |
|
), |
|
MyTab(text: "粉丝${infoNumber?.fans ?? "0"}"), |
|
], |
|
), |
|
), |
|
body: TabBarView( |
|
children: [ |
|
FollowPage(() { |
|
querySocialInfo(); |
|
}), |
|
FansPage(() { |
|
querySocialInfo(); |
|
}) |
|
], |
|
), |
|
), |
|
); |
|
} |
|
|
|
@override |
|
bool get wantKeepAlive => true; |
|
}
|
|
|