import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:huixiang/mine/follow_page.dart'; import 'package:huixiang/retrofit/data/base_data.dart'; import 'package:huixiang/retrofit/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 { @override State createState() { return _CommunityFollow(); } } class _CommunityFollow extends State with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { ApiService apiService; SocialInfo infoNumber; @override void initState() { super.initState(); querySocialInfo(); } ///个人社交信息(粉丝/关注数量/成就数量) querySocialInfo() async { SharedPreferences value = await SharedPreferences.getInstance(); apiService = ApiService(Dio(), context: context, token: value.getString("token"), showLoading: true); BaseData baseData = await apiService.socialInfo().catchError((onError) {}); if (baseData != null && baseData.isSuccess) { setState(() { infoNumber = baseData.data; }); } EasyLoading.dismiss(); } @override Widget build(BuildContext context) { return DefaultTabController( length: 2, child: Scaffold( appBar: MyAppBar( title: "", titleColor: Colors.black, background: Colors.white, leadingColor: Colors.black, toolbarHeight: kToolbarHeight + MediaQuery.of(context).padding.top, 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: [ MyTab( text: "关注${infoNumber?.follow ?? "0"}", ), MyTab(text: "粉丝${infoNumber?.fans ?? "0"}"), ], ), ), body: TabBarView( children: [ FollowPage(() { querySocialInfo(); }), FansPage(() { querySocialInfo(); }) ], ), ), ); } @override bool get wantKeepAlive => true; }