|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/rendering.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:huixiang/retrofit/retrofit_api.dart';
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import '../../generated/l10n.dart';
|
|
|
|
import '../../utils/font_weight.dart';
|
|
|
|
import '../main.dart';
|
|
|
|
import '../retrofit/data/base_data.dart';
|
|
|
|
import '../retrofit/data/social_info.dart';
|
|
|
|
import '../utils/event_type.dart';
|
|
|
|
import '../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;
|
|
|
|
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 {
|
|
|
|
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 != null && baseData.isSuccess) {
|
|
|
|
setState(() {
|
|
|
|
infoNumber = baseData.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
EasyLoading.dismiss();
|
|
|
|
}
|
|
|
|
|
|
|
|
@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),
|
|
|
|
action: GestureDetector(
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
onTap: () {
|
|
|
|
Navigator.of(context).pushNamed('/router/add_friend');
|
|
|
|
},
|
|
|
|
child: Container(
|
|
|
|
padding: EdgeInsets.all(12),
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Color(0xFFFFFFFF),
|
|
|
|
borderRadius: BorderRadius.circular(20.r),
|
|
|
|
boxShadow: [
|
|
|
|
BoxShadow(
|
|
|
|
color: Color(0xFF000000).withAlpha(25),
|
|
|
|
offset: Offset(0, 0),
|
|
|
|
blurRadius: 4,
|
|
|
|
spreadRadius: 0,
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
child: Image.asset(
|
|
|
|
"assets/image/add_friend.webp",
|
|
|
|
fit: BoxFit.fill,
|
|
|
|
height: 14.h,width: 14.h,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
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,
|
|
|
|
),
|
|
|
|
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","粉丝"),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|