88 lines
2.8 KiB
Dart
88 lines
2.8 KiB
Dart
import 'package:azlistview/azlistview.dart';
|
|
import 'package:chat/configs/app_colors.dart';
|
|
import 'package:chat/controllers/private_controller.dart';
|
|
import 'package:chat/models/im/contact_info_model.dart';
|
|
import 'package:chat/routes/contact_routes.dart';
|
|
import 'package:chat/services/tim/friend_service.dart';
|
|
import 'package:chat/utils/im_tools.dart';
|
|
import 'package:chat/widgets/custom_avatar.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
class ContactPage extends StatefulWidget {
|
|
const ContactPage({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
State<ContactPage> createState() => _ContactPageState();
|
|
}
|
|
|
|
class _ContactPageState extends State<ContactPage> {
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
TimFriendService.to.fetchList();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GetX<TimFriendService>(
|
|
builder: (_) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text('我的好友(${_.friends.length})'),
|
|
actions: [
|
|
IconButton(
|
|
onPressed: () {
|
|
// Get.toNamed(ImRoutes.friendSearch);
|
|
},
|
|
icon: const Icon(Icons.search_outlined),
|
|
),
|
|
],
|
|
),
|
|
body: AzListView(
|
|
physics: const ClampingScrollPhysics(),
|
|
data: _.contacts,
|
|
itemCount: _.contacts.length,
|
|
itemBuilder: (__, index) {
|
|
ContactInfoModel info = _.contacts[index];
|
|
return Column(
|
|
children: [
|
|
ListTile(
|
|
onTap: () async {
|
|
await PrivateController.to.setCurrentFriend(
|
|
info.userID,
|
|
);
|
|
Get.toNamed(
|
|
ContactRoutes.friendProfile,
|
|
);
|
|
},
|
|
tileColor: AppColors.white,
|
|
leading: CustomAvatar(
|
|
info.friendInfo!.userProfile!.faceUrl,
|
|
size: 40,
|
|
),
|
|
title: Text(info.name),
|
|
),
|
|
const Divider(
|
|
height: 0,
|
|
indent: 72,
|
|
),
|
|
],
|
|
);
|
|
},
|
|
susItemBuilder: (__, index) {
|
|
ContactInfoModel model = _.contacts[index];
|
|
if ('↑' == model.getSuspensionTag()) {
|
|
return Container();
|
|
}
|
|
return ImTools.susItem(context, model.getSuspensionTag());
|
|
},
|
|
indexBarData: SuspensionUtil.getTagIndexList(_.contacts).toList(),
|
|
indexBarOptions: ImTools.indexBarOptions,
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|