通讯录完成
BIN
assets/chats/chat_bubble_img_broken.png
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
assets/chats/default_avatar.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
assets/chats/delete_emoji.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
BIN
assets/chats/file_msg.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/chats/index_bar.png
Normal file
|
After Width: | Height: | Size: 4.9 KiB |
BIN
assets/chats/play_voice_receive.gif
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
assets/chats/play_voice_send.gif
Normal file
|
After Width: | Height: | Size: 2.6 KiB |
BIN
assets/chats/voice_volume_1.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/chats/voice_volume_2.png
Normal file
|
After Width: | Height: | Size: 2.1 KiB |
BIN
assets/chats/voice_volume_3.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
assets/chats/voice_volume_4.png
Normal file
|
After Width: | Height: | Size: 2.2 KiB |
BIN
assets/chats/voice_volume_5.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/chats/voice_volume_6.png
Normal file
|
After Width: | Height: | Size: 2.3 KiB |
BIN
assets/chats/voice_volume_7.png
Normal file
|
After Width: | Height: | Size: 2.4 KiB |
@@ -1,4 +1,5 @@
|
||||
import 'package:azlistview/azlistview.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_friend_info.dart';
|
||||
|
||||
class ContactInfoModel extends ISuspensionBean {
|
||||
@@ -7,6 +8,8 @@ class ContactInfoModel extends ISuspensionBean {
|
||||
String? tagIndex;
|
||||
String? namePinyin;
|
||||
V2TimFriendInfo? friendInfo;
|
||||
IconData? icon;
|
||||
Color? color;
|
||||
|
||||
ContactInfoModel({
|
||||
required this.name,
|
||||
@@ -14,6 +17,8 @@ class ContactInfoModel extends ISuspensionBean {
|
||||
this.tagIndex,
|
||||
this.namePinyin,
|
||||
this.friendInfo,
|
||||
this.icon,
|
||||
this.color,
|
||||
});
|
||||
|
||||
@override
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:chat/services/tim_service.dart';
|
||||
import 'package:chat/utils/im_tools.dart';
|
||||
import 'package:chat/utils/network/http.dart';
|
||||
import 'package:chat/utils/ui_tools.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:lpinyin/lpinyin.dart';
|
||||
import 'package:tencent_im_sdk_plugin/enum/friend_type_enum.dart';
|
||||
@@ -27,6 +28,30 @@ class TimFriendService extends GetxService {
|
||||
/// 格式化后的联系人信息
|
||||
var contacts = List<ContactInfoModel>.empty(growable: true).obs;
|
||||
|
||||
final List<ContactInfoModel> _topList = [
|
||||
ContactInfoModel(
|
||||
name: '新的朋友',
|
||||
userID: '',
|
||||
tagIndex: '@',
|
||||
icon: Icons.person_add_alt,
|
||||
color: Colors.amber,
|
||||
),
|
||||
ContactInfoModel(
|
||||
name: '群聊',
|
||||
userID: '',
|
||||
tagIndex: '@',
|
||||
icon: Icons.group,
|
||||
color: Colors.green,
|
||||
),
|
||||
ContactInfoModel(
|
||||
name: '订阅消息',
|
||||
userID: '',
|
||||
tagIndex: '@',
|
||||
icon: Icons.mark_email_read,
|
||||
color: Colors.blue,
|
||||
),
|
||||
];
|
||||
|
||||
Future<void> fetchList() async {
|
||||
var result = await friendshipManager.getFriendList();
|
||||
if (result.code == 0) {
|
||||
@@ -52,6 +77,7 @@ class TimFriendService extends GetxService {
|
||||
|
||||
SuspensionUtil.sortListBySuspensionTag(contacts);
|
||||
SuspensionUtil.setShowSuspensionStatus(contacts);
|
||||
contacts.insertAll(0, _topList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ class ImTools {
|
||||
static Widget susItem(
|
||||
BuildContext context,
|
||||
String tag, {
|
||||
double susHeight = 40,
|
||||
double susHeight = 32,
|
||||
}) {
|
||||
return Container(
|
||||
height: susHeight,
|
||||
@@ -201,6 +201,10 @@ class ImTools {
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
tag,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -25,11 +25,9 @@ class _ContactPageState extends State<ContactPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetX<TimFriendService>(
|
||||
builder: (_) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('我的好友(${_.friends.length})'),
|
||||
title: const Text('通讯录'),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
@@ -39,12 +37,41 @@ class _ContactPageState extends State<ContactPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
body: AzListView(
|
||||
physics: const ClampingScrollPhysics(),
|
||||
body: GetX<TimFriendService>(builder: (_) {
|
||||
return AzListView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
data: _.contacts,
|
||||
itemCount: _.contacts.length,
|
||||
itemBuilder: (__, index) {
|
||||
ContactInfoModel info = _.contacts[index];
|
||||
if (info.tagIndex == '@') {
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
onTap: () async {},
|
||||
leading: Container(
|
||||
width: 40,
|
||||
height: 40,
|
||||
decoration: BoxDecoration(
|
||||
color: info.color!,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Icon(
|
||||
info.icon,
|
||||
size: 26,
|
||||
color: AppColors.white,
|
||||
),
|
||||
),
|
||||
tileColor: AppColors.white,
|
||||
title: Text(info.name),
|
||||
),
|
||||
const Divider(
|
||||
height: 0,
|
||||
indent: 72,
|
||||
),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return Column(
|
||||
children: [
|
||||
ListTile(
|
||||
@@ -69,19 +96,22 @@ class _ContactPageState extends State<ContactPage> {
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
susItemBuilder: (__, index) {
|
||||
ContactInfoModel model = _.contacts[index];
|
||||
if ('↑' == model.getSuspensionTag()) {
|
||||
if ('@' == model.getSuspensionTag()) {
|
||||
return Container();
|
||||
}
|
||||
return ImTools.susItem(context, model.getSuspensionTag());
|
||||
return ImTools.susItem(
|
||||
context,
|
||||
model.getSuspensionTag(),
|
||||
);
|
||||
},
|
||||
indexBarData: SuspensionUtil.getTagIndexList(_.contacts).toList(),
|
||||
indexBarOptions: ImTools.indexBarOptions,
|
||||
),
|
||||
);
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ dev_dependencies:
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
assets:
|
||||
- assets/chats/
|
||||
- assets/icons/
|
||||
- assets/images/
|
||||
- assets/images/empty/
|
||||
|
||||