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.
 
 
 
 
 
 

145 lines
4.7 KiB

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:huixiang/data/base_data.dart';
import 'package:huixiang/data/social_info.dart';
import 'package:huixiang/generated/l10n.dart';
import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:huixiang/view_widget/my_tab.dart';
import 'im_view/custom_underline_tabIndicator.dart';
import 'im_view/friend_groip_list.dart';
class ChatFriendGroup extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _ChatFriendGroup();
}
}
class _ChatFriendGroup extends State<ChatFriendGroup>
with SingleTickerProviderStateMixin {
ApiService? apiService;
late TabController tabController;
List<GlobalKey> _allKey = [];
SocialInfo? infoNumber;
@override
void initState() {
super.initState();
tabController = TabController(length: 3, vsync: this, initialIndex: 0);
tabController.addListener(() {
if(!(tabController.indexIsChanging))
setState(() {});
});
loadFinish();
querySocialInfo();
}
@override
void dispose() {
super.dispose();
tabController.dispose();
}
loadFinish() {
_allKey = [GlobalKey(), GlobalKey(), GlobalKey()];
setState(() {});
}
///个人社交信息(粉丝/关注数量/成就数量/好友数量)
querySocialInfo() async {
apiService = ApiService(Dio(),
context: context, token: SharedInstance.instance.token, showLoading: false,
);
BaseData<SocialInfo>? baseData = await apiService?.socialInfo().catchError((onError) {
return BaseData<SocialInfo>()..isSuccess = false;
});
if (baseData?.isSuccess ?? false) {
setState(() {
infoNumber = baseData!.data;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFFFFFFF),
appBar: MyAppBar(
title: tabController.index == 0 ? "${S.of(context).haoyou} (${infoNumber?.mutualFollowCount ?? "0"})" :
(tabController.index == 1 ? "${S.of(context).guanzhu} (${infoNumber?.follow ?? "0"})" : "${S.of(context).fensi} (${infoNumber?.fans ?? "0"})"),
titleColor: Color(0xFF0D0D0D),
titleSize: 17.sp,
leading: true,
leadingColor: Colors.black,
background: Color(0xFFFFFFFF),
),
body: Container(
child: Column(
children: [
Align(
alignment: Alignment.centerLeft,
child: Theme(
data: ThemeData(
splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明
highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明
),
child: TabBar(
controller: tabController,
isScrollable: true,
//可滚动
labelColor: Color(0xFF060606),
labelStyle: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.bold,
),
tabAlignment: TabAlignment.start,
dividerColor: Colors.transparent,
dividerHeight: 0,
unselectedLabelStyle: TextStyle(
fontSize: 15.sp,
fontWeight: FontWeight.normal,
),
//未选中文字颜色
unselectedLabelColor: Color(0XFFA29E9E),
indicator: CustomUnderlineTabIndicator(
insets: EdgeInsets.only(
top: 10.w,
bottom: 2.w,
),
borderSide: BorderSide(
width: 5.w,
color: Color(0XFF32A060),
),
),
indicatorSize: TabBarIndicatorSize.label,
//指示器与文字等宽
tabs: <Widget>[
MyTab(text: S.of(context).haoyou),
MyTab(text: S.of(context).guanzhu),
MyTab(text: S.of(context).fensi),
],
),
),
),
Expanded(
child: TabBarView(
controller: tabController,
children: [
FriendGroupList(_allKey[0],"","好友"),
FriendGroupList(_allKey[1],"false", "关注"),
FriendGroupList(_allKey[2],"true","粉丝"),
],
),
),
],
),
),
);
}
}