基础页面
This commit is contained in:
15
lib/views/contact/group/create/index_page.dart
Normal file
15
lib/views/contact/group/create/index_page.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ContactGroupCreatePage extends StatefulWidget {
|
||||
const ContactGroupCreatePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ContactGroupCreatePageState createState() => _ContactGroupCreatePageState();
|
||||
}
|
||||
|
||||
class _ContactGroupCreatePageState extends State<ContactGroupCreatePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
15
lib/views/contact/group/manage/index_page.dart
Normal file
15
lib/views/contact/group/manage/index_page.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ContactGroupManagePage extends StatefulWidget {
|
||||
const ContactGroupManagePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ContactGroupManagePage> createState() => _ContactGroupManagePageState();
|
||||
}
|
||||
|
||||
class _ContactGroupManagePageState extends State<ContactGroupManagePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
17
lib/views/contact/group/notification/index_page.dart
Normal file
17
lib/views/contact/group/notification/index_page.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ContactGroupNotificationPage extends StatefulWidget {
|
||||
const ContactGroupNotificationPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ContactGroupNotificationPageState createState() =>
|
||||
_ContactGroupNotificationPageState();
|
||||
}
|
||||
|
||||
class _ContactGroupNotificationPageState
|
||||
extends State<ContactGroupNotificationPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
82
lib/views/conversation/index_page.dart
Normal file
82
lib/views/conversation/index_page.dart
Normal file
@@ -0,0 +1,82 @@
|
||||
import 'package:chat/controllers/group_controller.dart';
|
||||
import 'package:chat/controllers/private_controller.dart';
|
||||
import 'package:chat/routes/conversation_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tencent_im_sdk_plugin/enum/conversation_type.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_conversation.dart';
|
||||
|
||||
class ConversationPage extends StatefulWidget {
|
||||
const ConversationPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ConversationPageState createState() => _ConversationPageState();
|
||||
}
|
||||
|
||||
class _ConversationPageState extends State<ConversationPage> {
|
||||
late final V2TimConversation conversation;
|
||||
final _scaffoldKey = GlobalKey<ScaffoldState>();
|
||||
final GlobalKey<dynamic> inputextField = GlobalKey();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
conversation = Get.arguments['conversation'];
|
||||
|
||||
/// 标记会话内消息已读
|
||||
TimConversationService.to.markAsRead(conversation);
|
||||
if (conversation.type == ConversationType.V2TIM_GROUP) {
|
||||
GroupController.to.setCurrentGroup(conversation.groupID!);
|
||||
} else {
|
||||
PrivateController.to.setCurrentFriend(conversation.userID!);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
inputextField.currentState.hideAllPanel();
|
||||
},
|
||||
child: Scaffold(
|
||||
key: _scaffoldKey,
|
||||
appBar: AppBar(
|
||||
title: conversation.type == ConversationType.V2TIM_GROUP
|
||||
? GetX<GroupController>(
|
||||
builder: (_) {
|
||||
return Text(
|
||||
_.currentGroup.value.conversation?.showName ?? '',
|
||||
);
|
||||
},
|
||||
)
|
||||
: GetX<PrivateController>(
|
||||
builder: (_) {
|
||||
return Text(
|
||||
_.currentFriend.value.conversation?.showName ?? '',
|
||||
);
|
||||
},
|
||||
),
|
||||
actions: [
|
||||
_topRightAction(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _topRightAction() {
|
||||
return IconButton(
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
onPressed: () {
|
||||
conversation.type == ConversationType.V2TIM_GROUP
|
||||
? Get.toNamed(
|
||||
ConversationRoutes.infoGroup,
|
||||
)
|
||||
: Get.toNamed(
|
||||
ConversationRoutes.infoPrivate,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
235
lib/views/conversation/info/group_page.dart
Normal file
235
lib/views/conversation/info/group_page.dart
Normal file
@@ -0,0 +1,235 @@
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/controllers/group_controller.dart';
|
||||
import 'package:chat/routes/contact_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:chat/services/tim/group_service.dart';
|
||||
import 'package:chat/views/conversation/info/widgets/group_member_preview.dart';
|
||||
import 'package:chat/views/home/widgets/action_button.dart';
|
||||
import 'package:chat/views/home/widgets/action_item.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ConversationInfoGroupPage extends StatelessWidget {
|
||||
const ConversationInfoGroupPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
GroupController.to.fetchGroupMemberList();
|
||||
|
||||
return GetX<GroupController>(builder: (_) {
|
||||
var currentGroup = _.currentGroup.value;
|
||||
var group = _.currentGroup.value.group;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('聊天信息(${group?.memberCount})'),
|
||||
centerTitle: true,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
const GroupMemberPreview(),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
color: AppColors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
ActionItem(
|
||||
'群聊名称',
|
||||
extend: group?.groupName,
|
||||
onTap: () {
|
||||
if (currentGroup.isAdmin || currentGroup.isOwner) {
|
||||
// Get.toNamed(
|
||||
// ImRoutes.groupName,
|
||||
// );
|
||||
}
|
||||
},
|
||||
),
|
||||
const Divider(height: 0, indent: 16),
|
||||
ActionItem(
|
||||
'群二维码',
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
ContactRoutes.groupQrCode,
|
||||
);
|
||||
},
|
||||
),
|
||||
const Divider(height: 0, indent: 16),
|
||||
ActionItem(
|
||||
'群公告',
|
||||
bottom: group?.notification,
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
ContactRoutes.groupNotification,
|
||||
);
|
||||
},
|
||||
),
|
||||
Visibility(
|
||||
visible: currentGroup.isAdmin || currentGroup.isOwner,
|
||||
child: const Divider(
|
||||
height: 0,
|
||||
indent: 16,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: currentGroup.isAdmin || currentGroup.isOwner,
|
||||
child: ActionItem(
|
||||
'群管理',
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
ContactRoutes.groupManage,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: currentGroup.isAdmin || currentGroup.isOwner,
|
||||
child: const Divider(
|
||||
height: 0,
|
||||
indent: 16,
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: currentGroup.isAdmin || currentGroup.isOwner,
|
||||
child: ActionItem(
|
||||
'加群申请',
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
ContactRoutes.groupApprove,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
color: AppColors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
ActionItem(
|
||||
'查找聊天记录',
|
||||
onTap: () {
|
||||
// Get.toNamed(
|
||||
// ImRoutes.conversationSearch,
|
||||
// );
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
color: AppColors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
ActionItem(
|
||||
'消息免打扰',
|
||||
rightWidget: SizedBox(
|
||||
height: 24,
|
||||
child: Switch(
|
||||
value:
|
||||
_.currentGroup.value.conversation!.recvOpt == 1,
|
||||
onChanged: (e) async {
|
||||
_.toggleReceiveOpt();
|
||||
},
|
||||
materialTapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
height: 0,
|
||||
indent: 16,
|
||||
),
|
||||
ActionItem(
|
||||
'置顶聊天',
|
||||
rightWidget: SizedBox(
|
||||
height: 24,
|
||||
child: Switch(
|
||||
value: _.currentGroup.value.conversation!.isPinned!,
|
||||
onChanged: (e) async {
|
||||
_.togglePinned();
|
||||
},
|
||||
materialTapTargetSize:
|
||||
MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Container(
|
||||
color: AppColors.white,
|
||||
child: Column(
|
||||
children: [
|
||||
ActionItem(
|
||||
'我在群里的昵称',
|
||||
extend: _.currentGroup.value.selfInfo?.nameCard ?? '',
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
ContactRoutes.groupNickname,
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Column(
|
||||
children: [
|
||||
ActionButton(
|
||||
'清空聊天记录',
|
||||
onTap: () async {
|
||||
OkCancelResult result = await showOkCancelAlertDialog(
|
||||
style: AdaptiveStyle.iOS,
|
||||
context: Get.context!,
|
||||
title: '系统提示',
|
||||
message: '将删除该聊天记录,是否继续?',
|
||||
okLabel: '确定',
|
||||
cancelLabel: '取消',
|
||||
defaultType: OkCancelAlertDefaultType.ok,
|
||||
);
|
||||
|
||||
if (result == OkCancelResult.ok) {
|
||||
TimConversationService.to.clearHistoryMessage(
|
||||
_.currentGroup.value.conversation!,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (!currentGroup.isOwner) const Divider(height: 0),
|
||||
ActionButton(
|
||||
'删除并退出',
|
||||
onTap: () async {
|
||||
OkCancelResult result = await showOkCancelAlertDialog(
|
||||
style: AdaptiveStyle.iOS,
|
||||
context: Get.context!,
|
||||
title: '系统提示',
|
||||
message: '将删除并退出该群组,是否继续?',
|
||||
okLabel: '确定',
|
||||
cancelLabel: '取消',
|
||||
defaultType: OkCancelAlertDefaultType.ok,
|
||||
);
|
||||
|
||||
if (result == OkCancelResult.ok) {
|
||||
TimGroupService.to.quit(
|
||||
group!,
|
||||
);
|
||||
Navigator.popUntil(context, (route) => route.isFirst);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
157
lib/views/conversation/info/private_page.dart
Normal file
157
lib/views/conversation/info/private_page.dart
Normal file
@@ -0,0 +1,157 @@
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/controllers/private_controller.dart';
|
||||
import 'package:chat/routes/contact_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:chat/views/home/widgets/action_item.dart';
|
||||
import 'package:chat/widgets/custom_avatar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class ConversationInfoPrivatePage extends StatelessWidget {
|
||||
const ConversationInfoPrivatePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetX<PrivateController>(builder: (_) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('聊天信息'),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: const BoxDecoration(color: AppColors.white),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
ContactRoutes.friendProfile,
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
CustomAvatar(
|
||||
_.currentFriend.value.userProfile?.faceUrl,
|
||||
size: 54,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
_.currentFriend.value.conversation!.showName!,
|
||||
style: const TextStyle(
|
||||
color: AppColors.unactive,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
ContactRoutes.groupCreate,
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
width: 54,
|
||||
height: 54,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.unactive.withOpacity(0.1),
|
||||
border: Border.all(
|
||||
color: AppColors.unactive.withOpacity(0.3),
|
||||
width: 0.4,
|
||||
style: BorderStyle.solid,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(height: 0),
|
||||
const SizedBox(height: 8),
|
||||
const Divider(height: 0),
|
||||
ActionItem(
|
||||
'查找聊天记录',
|
||||
onTap: () {
|
||||
// Get.toNamed(
|
||||
// ImRoutes.conversationSearch,
|
||||
// );
|
||||
},
|
||||
),
|
||||
const Divider(height: 0),
|
||||
const SizedBox(height: 8),
|
||||
const Divider(height: 0),
|
||||
ActionItem(
|
||||
'消息免打扰',
|
||||
rightWidget: SizedBox(
|
||||
height: 24,
|
||||
child: Switch(
|
||||
value: _.currentFriend.value.conversation!.recvOpt == 1,
|
||||
onChanged: (e) async {
|
||||
_.changeReceiveOpt();
|
||||
},
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
height: 0,
|
||||
indent: 16,
|
||||
),
|
||||
ActionItem(
|
||||
'置顶聊天',
|
||||
rightWidget: SizedBox(
|
||||
height: 24,
|
||||
child: Switch(
|
||||
value: _.currentFriend.value.conversation!.isPinned!,
|
||||
onChanged: (e) async {
|
||||
_.togglePinned();
|
||||
},
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(height: 0),
|
||||
const SizedBox(height: 8),
|
||||
const Divider(height: 0),
|
||||
ActionItem(
|
||||
'清空聊天记录',
|
||||
onTap: () async {
|
||||
OkCancelResult result = await showOkCancelAlertDialog(
|
||||
style: AdaptiveStyle.iOS,
|
||||
context: Get.context!,
|
||||
title: '系统提示',
|
||||
message: '将删除该聊天记录,是否继续?',
|
||||
okLabel: '确定',
|
||||
cancelLabel: '取消',
|
||||
defaultType: OkCancelAlertDefaultType.ok,
|
||||
);
|
||||
|
||||
if (result == OkCancelResult.ok) {
|
||||
TimConversationService.to.clearHistoryMessage(
|
||||
_.currentFriend.value.conversation!,
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
const Divider(height: 0),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
209
lib/views/conversation/info/widgets/group_member_preview.dart
Normal file
209
lib/views/conversation/info/widgets/group_member_preview.dart
Normal file
@@ -0,0 +1,209 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:adaptive_dialog/adaptive_dialog.dart';
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/controllers/group_controller.dart';
|
||||
import 'package:chat/controllers/private_controller.dart';
|
||||
import 'package:chat/routes/contact_routes.dart';
|
||||
import 'package:chat/widgets/custom_avatar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tencent_im_sdk_plugin/enum/group_member_role.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_group_member_full_info.dart';
|
||||
|
||||
class GroupMemberPreview extends StatelessWidget {
|
||||
const GroupMemberPreview({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetX<GroupController>(builder: (_) {
|
||||
List<Widget> items = List<Widget>.empty(growable: true);
|
||||
|
||||
if (_.currentGroup.value.memberList != null) {
|
||||
var members = _.currentGroup.value.memberList!;
|
||||
|
||||
if (members.length > 13) {
|
||||
members = members.sublist(0, 13);
|
||||
}
|
||||
|
||||
for (var item in members) {
|
||||
items.add(_memberItem(item!));
|
||||
}
|
||||
}
|
||||
|
||||
/// 因为 Public 类型的群,不支持邀请功能,用户只能主动申请加群
|
||||
items.add(
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
OkCancelResult result = await showOkCancelAlertDialog(
|
||||
style: AdaptiveStyle.iOS,
|
||||
context: Get.context!,
|
||||
title: '系统提示',
|
||||
message: '当前群聊不支持邀请用户,请分享群二维码至您要邀请的好友。',
|
||||
okLabel: '去分享',
|
||||
cancelLabel: '取消',
|
||||
defaultType: OkCancelAlertDefaultType.ok,
|
||||
);
|
||||
|
||||
if (result == OkCancelResult.ok) {
|
||||
Get.toNamed(ContactRoutes.groupQrCode);
|
||||
}
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.unactive.withOpacity(0.1),
|
||||
border: Border.all(
|
||||
color: AppColors.unactive.withOpacity(0.3),
|
||||
width: 0.4,
|
||||
style: BorderStyle.solid,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.add,
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
'邀请',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (_.currentGroup.value.isAdmin || _.currentGroup.value.isOwner) {
|
||||
items.add(
|
||||
InkWell(
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
ContactRoutes.groupKick,
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
width: 44,
|
||||
height: 44,
|
||||
decoration: BoxDecoration(
|
||||
color: AppColors.unactive.withOpacity(0.1),
|
||||
border: Border.all(
|
||||
color: AppColors.unactive.withOpacity(0.3),
|
||||
width: 0.4,
|
||||
style: BorderStyle.solid,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Center(
|
||||
child: Icon(
|
||||
Icons.remove,
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
),
|
||||
),
|
||||
const Text(
|
||||
'移除',
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Container(
|
||||
color: AppColors.white,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: GridView.count(
|
||||
shrinkWrap: true,
|
||||
physics: const NeverScrollableScrollPhysics(),
|
||||
crossAxisCount: 5,
|
||||
childAspectRatio: 1 / 1.1,
|
||||
crossAxisSpacing: 12,
|
||||
mainAxisSpacing: 12,
|
||||
children: items,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
Widget _memberItem(V2TimGroupMemberFullInfo member) {
|
||||
double w = 40;
|
||||
double h = 12;
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
await PrivateController.to.setCurrentFriend(member.userID);
|
||||
Get.toNamed(
|
||||
ContactRoutes.friendProfile,
|
||||
);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
ClipRRect(
|
||||
child: Stack(
|
||||
children: [
|
||||
CustomAvatar(member.faceUrl),
|
||||
if (member.role ==
|
||||
GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN ||
|
||||
member.role ==
|
||||
GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER)
|
||||
Positioned(
|
||||
left: 0,
|
||||
top: sqrt(w * w / 2 - sqrt2 * w * h + h * h),
|
||||
child: Transform.rotate(
|
||||
angle: -0.25 * pi,
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Container(
|
||||
color: member.role ==
|
||||
GroupMemberRoleType
|
||||
.V2TIM_GROUP_MEMBER_ROLE_OWNER
|
||||
? AppColors.red
|
||||
: AppColors.golden,
|
||||
width: w,
|
||||
height: h,
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
member.role ==
|
||||
GroupMemberRoleType
|
||||
.V2TIM_GROUP_MEMBER_ROLE_OWNER
|
||||
? '群主'
|
||||
: '管理员',
|
||||
style: const TextStyle(
|
||||
color: AppColors.white,
|
||||
fontSize: 8,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
member.nameCard!.isNotEmpty ? member.nameCard! : member.nickName!,
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,219 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/routes/app_routes.dart';
|
||||
import 'package:chat/routes/contact_routes.dart';
|
||||
import 'package:chat/routes/user_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:chat/views/home/widgets/conversation_item.dart';
|
||||
import 'package:chat/widgets/custom_easy_refresh.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
class HomePage extends StatelessWidget {
|
||||
const HomePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_HomePageState createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends State<HomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text('消息'),
|
||||
backgroundColor: AppColors.white,
|
||||
appBar: _appBar(),
|
||||
body: EasyRefresh(
|
||||
header: CustomEasyRefresh.header,
|
||||
// firstRefresh: true,
|
||||
onRefresh: () async {
|
||||
await TimConversationService.to.fetchList();
|
||||
},
|
||||
child: GetX<TimConversationService>(
|
||||
builder: (_) {
|
||||
return _.conversationList.isEmpty
|
||||
? CustomEasyRefresh.empty()
|
||||
: ListView.separated(
|
||||
shrinkWrap: true,
|
||||
physics: const ClampingScrollPhysics(),
|
||||
itemCount: _.conversationList.length,
|
||||
itemBuilder: (context, index) {
|
||||
return ConversationItem(_.conversationList[index]!);
|
||||
},
|
||||
separatorBuilder: (context, index) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
indent: 72,
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
PreferredSizeWidget _appBar() {
|
||||
return AppBar(
|
||||
title: const Text('聊聊'),
|
||||
actions: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
Get.toNamed(AppRoutes.search);
|
||||
},
|
||||
icon: const Icon(Icons.search_outlined),
|
||||
),
|
||||
PopupMenuButton<String>(
|
||||
onSelected: (String value) {
|
||||
switch (value) {
|
||||
case 'A':
|
||||
Get.toNamed(UserRoutes.qrCode);
|
||||
break;
|
||||
case 'B':
|
||||
Get.toNamed(ContactRoutes.groupCreate);
|
||||
break;
|
||||
case 'C':
|
||||
Get.toNamed(ContactRoutes.friendSearch);
|
||||
break;
|
||||
case 'D':
|
||||
Permission.camera.request().isGranted.then((value) {
|
||||
if (value) {
|
||||
Get.toNamed(AppRoutes.scan);
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
tooltip: '',
|
||||
offset: const Offset(0, 56),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
icon: const Icon(
|
||||
Icons.add,
|
||||
),
|
||||
itemBuilder: (_) {
|
||||
return [
|
||||
_popupMenuItem('我的二维码', 'A', Icons.qr_code_outlined),
|
||||
_popupMenuItem('发起群聊', 'B', Icons.textsms),
|
||||
_popupMenuItem('添加朋友', 'C', Icons.person_add_alt),
|
||||
_popupMenuItem('扫一扫', 'D', Icons.photo_camera),
|
||||
];
|
||||
},
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
/// 右上角弹出菜单
|
||||
PopupMenuItem<String> _popupMenuItem(
|
||||
String text,
|
||||
String value,
|
||||
IconData icon,
|
||||
) {
|
||||
return PopupMenuItem(
|
||||
value: value,
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
icon,
|
||||
color: AppColors.primary,
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// /// 左侧抽题
|
||||
// Widget _drawer() {
|
||||
// return Drawer(
|
||||
// child: ListView(
|
||||
// children: [
|
||||
// GetX<UserController>(builder: (_) {
|
||||
// return DrawerHeader(
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// CustomCircleAvatar(
|
||||
// _.userInfo.value!.avatar,
|
||||
// size: 72,
|
||||
// ),
|
||||
// const SizedBox(height: 8),
|
||||
// Text(
|
||||
// _.userInfo.value!.nickname,
|
||||
// style: const TextStyle(
|
||||
// fontSize: 24,
|
||||
// fontWeight: FontWeight.bold,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }),
|
||||
// ListTile(
|
||||
// onTap: () {
|
||||
// Get.back();
|
||||
// Get.toNamed(UserRoutes.info);
|
||||
// },
|
||||
// leading: const Icon(Icons.info_outlined),
|
||||
// title: const Text('修改资料'),
|
||||
// ),
|
||||
// const Divider(height: 0),
|
||||
// ListTile(
|
||||
// onTap: () {
|
||||
// Get.back();
|
||||
// Get.toNamed(
|
||||
// ImRoutes.friend,
|
||||
// arguments: {
|
||||
// 'name_card': false,
|
||||
// },
|
||||
// );
|
||||
// },
|
||||
// leading: const Icon(Icons.person_outlined),
|
||||
// title: const Text('我的好友'),
|
||||
// ),
|
||||
// const Divider(height: 0),
|
||||
// ListTile(
|
||||
// onTap: () {
|
||||
// Get.back();
|
||||
// Get.toNamed(ImRoutes.group);
|
||||
// },
|
||||
// leading: const Icon(Icons.group_outlined),
|
||||
// title: const Text('我的群组'),
|
||||
// ),
|
||||
// const Divider(height: 0),
|
||||
// ListTile(
|
||||
// onTap: () {
|
||||
// Get.back();
|
||||
// Get.toNamed(ImRoutes.blcok);
|
||||
// },
|
||||
// leading: const Icon(Icons.block_flipped),
|
||||
// title: const Text('黑名单'),
|
||||
// ),
|
||||
// const Divider(height: 0),
|
||||
// ListTile(
|
||||
// onTap: () {
|
||||
// Get.back();
|
||||
// Get.toNamed(ImRoutes.friendRequest);
|
||||
// },
|
||||
// leading: const Icon(Icons.person_add_alt_outlined),
|
||||
// title: const Text('好友申请'),
|
||||
// ),
|
||||
// const Divider(height: 0),
|
||||
// ListTile(
|
||||
// onTap: () {
|
||||
// Get.back();
|
||||
// Get.toNamed(ImRoutes.setting);
|
||||
// },
|
||||
// leading: const Icon(Icons.settings_outlined),
|
||||
// title: const Text('消息设置'),
|
||||
// ),
|
||||
// const Divider(height: 0),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
}
|
||||
|
||||
39
lib/views/home/widgets/action_button.dart
Normal file
39
lib/views/home/widgets/action_button.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ActionButton extends StatelessWidget {
|
||||
final String text;
|
||||
final Color color;
|
||||
final VoidCallback? onTap;
|
||||
const ActionButton(
|
||||
this.text, {
|
||||
this.color = AppColors.red,
|
||||
this.onTap,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
onTap?.call();
|
||||
},
|
||||
child: Container(
|
||||
color: AppColors.white,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Center(
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.w500,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
76
lib/views/home/widgets/action_item.dart
Normal file
76
lib/views/home/widgets/action_item.dart
Normal file
@@ -0,0 +1,76 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ActionItem extends StatelessWidget {
|
||||
final String title;
|
||||
final String? extend;
|
||||
final Widget? rightWidget;
|
||||
final String? bottom;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const ActionItem(
|
||||
this.title, {
|
||||
this.extend,
|
||||
this.rightWidget,
|
||||
this.bottom,
|
||||
this.onTap,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
onTap?.call();
|
||||
},
|
||||
child: Container(
|
||||
color: AppColors.white,
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
Expanded(child: Container()),
|
||||
if (extend != null)
|
||||
Text(
|
||||
extend!,
|
||||
style: const TextStyle(
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
),
|
||||
rightWidget ??
|
||||
const Icon(
|
||||
Icons.arrow_forward_ios,
|
||||
size: 16,
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (bottom != null && bottom!.isNotEmpty)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: Text(
|
||||
bottom!,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.unactive,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
212
lib/views/home/widgets/conversation_item.dart
Normal file
212
lib/views/home/widgets/conversation_item.dart
Normal file
@@ -0,0 +1,212 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/routes/conversation_routes.dart';
|
||||
import 'package:chat/services/tim/conversation_service.dart';
|
||||
import 'package:chat/utils/convert.dart';
|
||||
import 'package:chat/views/home/widgets/group_avatar.dart';
|
||||
import 'package:chat/views/home/widgets/message_preview_widget.dart';
|
||||
import 'package:chat/views/home/widgets/pop_menu_item.dart';
|
||||
import 'package:chat/widgets/custom_avatar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:tencent_im_sdk_plugin/enum/conversation_type.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_conversation.dart';
|
||||
|
||||
class ConversationItem extends StatelessWidget {
|
||||
final V2TimConversation conversation;
|
||||
const ConversationItem(this.conversation, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 68,
|
||||
decoration: BoxDecoration(
|
||||
color: conversation.isPinned! ? AppColors.page : null,
|
||||
),
|
||||
padding: const EdgeInsets.only(
|
||||
left: 16,
|
||||
right: 16,
|
||||
top: 12,
|
||||
bottom: 12,
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
Get.toNamed(
|
||||
ConversationRoutes.index,
|
||||
arguments: {
|
||||
'conversation': conversation,
|
||||
},
|
||||
);
|
||||
},
|
||||
onLongPress: () async {
|
||||
await _showLongPressMenu();
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
conversation.type == ConversationType.V2TIM_C2C
|
||||
? CustomAvatar(
|
||||
conversation.faceUrl,
|
||||
)
|
||||
: GroupAvatar(conversation.groupID!),
|
||||
Visibility(
|
||||
visible: conversation.recvOpt == 0 &&
|
||||
conversation.unreadCount! > 0,
|
||||
child: Positioned(
|
||||
right: -5,
|
||||
top: -5,
|
||||
child: Container(
|
||||
width: 18,
|
||||
height: 18,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(18),
|
||||
color: AppColors.red,
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Center(
|
||||
child: Text(
|
||||
conversation.unreadCount! > 99
|
||||
? '99+'
|
||||
: conversation.unreadCount.toString(),
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: AppColors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Visibility(
|
||||
visible: conversation.recvOpt == 1 &&
|
||||
conversation.unreadCount! > 0,
|
||||
child: const Positioned(
|
||||
right: -3,
|
||||
top: -3,
|
||||
child: Icon(
|
||||
Icons.circle_rounded,
|
||||
color: AppColors.red,
|
||||
size: 8,
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
conversation.showName!,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
MessagePreviewWidget(conversation.lastMessage),
|
||||
],
|
||||
),
|
||||
),
|
||||
Column(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
conversation.lastMessage == null
|
||||
? ''
|
||||
: Convert.timeFormat(
|
||||
conversation.lastMessage!.timestamp!,
|
||||
format: 'MM/dd HH:mm',
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.grey,
|
||||
),
|
||||
),
|
||||
if (conversation.recvOpt == 1)
|
||||
const Icon(
|
||||
Icons.notifications_off_outlined,
|
||||
size: 14,
|
||||
color: AppColors.unactive,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showLongPressMenu() async {
|
||||
showModalBottomSheet(
|
||||
context: Get.context!,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: AppColors.white,
|
||||
shape: const RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.vertical(top: Radius.circular(8)),
|
||||
),
|
||||
builder: (context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
PopMenuItem(
|
||||
conversation.isPinned! ? '取消置顶' : '聊天置顶',
|
||||
onTap: () {
|
||||
TimConversationService.to.setOnTop(conversation);
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
const Divider(height: 0),
|
||||
PopMenuItem(
|
||||
conversation.recvOpt == 1 ? '取消免打扰' : '消息免打扰',
|
||||
onTap: () {
|
||||
TimConversationService.to.setReceiveOpt(conversation);
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
const Divider(height: 0),
|
||||
PopMenuItem(
|
||||
'清空聊天记录',
|
||||
onTap: () {
|
||||
TimConversationService.to.clearHistoryMessage(conversation);
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
const Divider(height: 0),
|
||||
PopMenuItem(
|
||||
'标为已读',
|
||||
onTap: () {
|
||||
TimConversationService.to.markAsRead(conversation);
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
const Divider(height: 0),
|
||||
PopMenuItem(
|
||||
'删除该聊天',
|
||||
onTap: () {
|
||||
TimConversationService.to.delete(conversation);
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
const Divider(height: 0.4),
|
||||
Container(
|
||||
color: AppColors.page,
|
||||
height: 8,
|
||||
),
|
||||
const Divider(height: 0.4),
|
||||
PopMenuItem(
|
||||
'取消',
|
||||
onTap: () {
|
||||
Get.back();
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
140
lib/views/home/widgets/friend_selector.dart
Normal file
140
lib/views/home/widgets/friend_selector.dart
Normal file
@@ -0,0 +1,140 @@
|
||||
import 'package:azlistview/azlistview.dart';
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/models/im/contact_info_model.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';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_friend_info.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_group_member_full_info.dart';
|
||||
|
||||
class FriendSelector extends StatefulWidget {
|
||||
final Function(List<V2TimFriendInfo>) onChanged;
|
||||
final List<V2TimGroupMemberFullInfo?>? lockedUsers;
|
||||
const FriendSelector({
|
||||
required this.onChanged,
|
||||
this.lockedUsers,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<FriendSelector> createState() => _FriendSelectorState();
|
||||
}
|
||||
|
||||
class _FriendSelectorState extends State<FriendSelector> {
|
||||
/// 选中的好友列表
|
||||
List<V2TimFriendInfo> selectList =
|
||||
List<V2TimFriendInfo>.empty(growable: true);
|
||||
|
||||
/// 选择列表改变的事件,更新选中列表
|
||||
_selectListChange(id) {
|
||||
setState(() {
|
||||
if (selectList.contains(id)) {
|
||||
selectList.remove(id);
|
||||
} else {
|
||||
selectList.add(id);
|
||||
}
|
||||
});
|
||||
widget.onChanged(selectList);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GetX<TimFriendService>(
|
||||
builder: (_) {
|
||||
return AzListView(
|
||||
data: _.contacts,
|
||||
itemCount: _.contacts.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
ContactInfoModel info = _.contacts[index];
|
||||
return _contactItem(info);
|
||||
},
|
||||
susItemBuilder: (BuildContext context, int index) {
|
||||
ContactInfoModel model = _.contacts[index];
|
||||
return ImTools.susItem(
|
||||
context,
|
||||
model.getSuspensionTag(),
|
||||
susHeight: 32,
|
||||
);
|
||||
},
|
||||
indexBarData: SuspensionUtil.getTagIndexList(_.contacts).toList(),
|
||||
indexBarOptions: ImTools.indexBarOptions,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _contactItem(
|
||||
ContactInfoModel info,
|
||||
) {
|
||||
bool isDisable = widget.lockedUsers == null
|
||||
? false
|
||||
: widget.lockedUsers!
|
||||
.where(
|
||||
(e) => e!.userID == info.friendInfo!.userID,
|
||||
)
|
||||
.isNotEmpty;
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
color: AppColors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: isDisable
|
||||
? null
|
||||
: () {
|
||||
setState(() {
|
||||
_selectListChange(info.friendInfo);
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Radio<V2TimFriendInfo>(
|
||||
groupValue:
|
||||
selectList.contains(info.friendInfo) || isDisable
|
||||
? info.friendInfo
|
||||
: null,
|
||||
onChanged: isDisable
|
||||
? null
|
||||
: (value) {
|
||||
setState(() {
|
||||
_selectListChange(info.friendInfo);
|
||||
});
|
||||
},
|
||||
value: info.friendInfo!,
|
||||
toggleable: true,
|
||||
),
|
||||
CustomAvatar(
|
||||
info.friendInfo!.userProfile!.faceUrl,
|
||||
size: 32,
|
||||
radius: 2,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
info.name,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
height: 0,
|
||||
indent: 92,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
68
lib/views/home/widgets/group_avatar.dart
Normal file
68
lib/views/home/widgets/group_avatar.dart
Normal file
@@ -0,0 +1,68 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/services/tim/group_service.dart';
|
||||
import 'package:chat/widgets/custom_avatar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_group_member_full_info.dart';
|
||||
|
||||
class GroupAvatar extends StatefulWidget {
|
||||
final String groupID;
|
||||
final double size;
|
||||
const GroupAvatar(
|
||||
this.groupID, {
|
||||
this.size = 44,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<GroupAvatar> createState() => _GroupAvatarState();
|
||||
}
|
||||
|
||||
class _GroupAvatarState extends State<GroupAvatar> {
|
||||
List<V2TimGroupMemberFullInfo?>? members;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
TimGroupService.to.members(widget.groupID, count: 9).then((value) {
|
||||
setState(() {
|
||||
members = value;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
width: widget.size,
|
||||
height: widget.size,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: AppColors.border,
|
||||
width: 0.4,
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: members == null
|
||||
? CustomAvatar('')
|
||||
: GridView.builder(
|
||||
padding: const EdgeInsets.all(1),
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount:
|
||||
(members != null && members!.length > 4) ? 3 : 2,
|
||||
childAspectRatio: 1,
|
||||
crossAxisSpacing: 1,
|
||||
mainAxisSpacing: 1,
|
||||
),
|
||||
itemCount: members!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return CustomAvatar(
|
||||
members![index]?.faceUrl,
|
||||
size: widget.size / 3,
|
||||
radius: 2,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
111
lib/views/home/widgets/group_user_selector.dart
Normal file
111
lib/views/home/widgets/group_user_selector.dart
Normal file
@@ -0,0 +1,111 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/widgets/custom_avatar.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_group_member_full_info.dart';
|
||||
|
||||
class GroupUserSelector extends StatefulWidget {
|
||||
final Function(List<V2TimGroupMemberFullInfo>) onChanged;
|
||||
final List<V2TimGroupMemberFullInfo> selectedList;
|
||||
final List<V2TimGroupMemberFullInfo?> originalList;
|
||||
|
||||
const GroupUserSelector({
|
||||
required this.onChanged,
|
||||
required this.selectedList,
|
||||
required this.originalList,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<GroupUserSelector> createState() => _GroupUserSelectorState();
|
||||
}
|
||||
|
||||
class _GroupUserSelectorState extends State<GroupUserSelector> {
|
||||
/// 选中的好友列表
|
||||
List<V2TimGroupMemberFullInfo> selectList =
|
||||
List<V2TimGroupMemberFullInfo>.empty(growable: true);
|
||||
|
||||
/// 选择列表改变的事件,更新选中列表
|
||||
_selectListChange(id) {
|
||||
setState(() {
|
||||
if (selectList.contains(id)) {
|
||||
selectList.remove(id);
|
||||
} else {
|
||||
selectList.add(id);
|
||||
}
|
||||
});
|
||||
widget.onChanged(selectList);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListView.separated(
|
||||
itemBuilder: (_, index) {
|
||||
return _contactItem(widget.originalList[index]!);
|
||||
},
|
||||
separatorBuilder: (_, index) {
|
||||
return const Divider(
|
||||
height: 0,
|
||||
);
|
||||
},
|
||||
itemCount: widget.originalList.length,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _contactItem(
|
||||
V2TimGroupMemberFullInfo info,
|
||||
) {
|
||||
return Column(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {},
|
||||
child: Container(
|
||||
color: AppColors.white,
|
||||
padding: const EdgeInsets.symmetric(vertical: 4),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectListChange(info);
|
||||
});
|
||||
},
|
||||
child: Row(
|
||||
children: [
|
||||
Radio<V2TimGroupMemberFullInfo>(
|
||||
groupValue: selectList.contains(info) ? info : null,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_selectListChange(info);
|
||||
});
|
||||
},
|
||||
value: info,
|
||||
toggleable: true,
|
||||
),
|
||||
CustomAvatar(
|
||||
info.faceUrl,
|
||||
size: 32,
|
||||
radius: 2,
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16,
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
info.nickName!,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const Divider(
|
||||
height: 0,
|
||||
indent: 92,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
26
lib/views/home/widgets/message_preview_widget.dart
Normal file
26
lib/views/home/widgets/message_preview_widget.dart
Normal file
@@ -0,0 +1,26 @@
|
||||
import 'package:chat/configs/app_colors.dart';
|
||||
import 'package:chat/utils/im_tools.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:tencent_im_sdk_plugin/models/v2_tim_message.dart';
|
||||
|
||||
class MessagePreviewWidget extends StatelessWidget {
|
||||
final V2TimMessage? message;
|
||||
const MessagePreviewWidget(this.message, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (message == null) {
|
||||
return const Text('');
|
||||
}
|
||||
|
||||
return Text(
|
||||
ImTools.parseMessage(message),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: const TextStyle(
|
||||
color: AppColors.unactive,
|
||||
fontSize: 14,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
29
lib/views/home/widgets/pop_menu_item.dart
Normal file
29
lib/views/home/widgets/pop_menu_item.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class PopMenuItem extends StatelessWidget {
|
||||
final String text;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const PopMenuItem(
|
||||
this.text, {
|
||||
this.onTap,
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () {
|
||||
onTap?.call();
|
||||
},
|
||||
child: Container(
|
||||
height: 52,
|
||||
width: Get.width,
|
||||
alignment: Alignment.center,
|
||||
child: Text(text),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -20,19 +20,23 @@ class AppPage extends StatelessWidget {
|
||||
|
||||
final List<Map> _tabBarList = [
|
||||
{
|
||||
'icon': 'tabBar_03.png',
|
||||
'icon': Icons.message_outlined,
|
||||
'active_icon': Icons.message,
|
||||
'label': '消息',
|
||||
},
|
||||
{
|
||||
'icon': 'tabBar_03.png',
|
||||
'icon': Icons.contact_page_outlined,
|
||||
'active_icon': Icons.contact_page,
|
||||
'label': '通讯录',
|
||||
},
|
||||
{
|
||||
'icon': 'tabBar_03.png',
|
||||
'icon': Icons.explore_outlined,
|
||||
'active_icon': Icons.explore,
|
||||
'label': '发现',
|
||||
},
|
||||
{
|
||||
'icon': 'tabBar_03.png',
|
||||
'icon': Icons.person_outline,
|
||||
'active_icon': Icons.person,
|
||||
'label': '我的',
|
||||
},
|
||||
];
|
||||
@@ -47,16 +51,14 @@ class AppPage extends StatelessWidget {
|
||||
},
|
||||
items: _tabBarList.map((item) {
|
||||
return BottomNavigationBarItem(
|
||||
icon: Image.asset(
|
||||
'assets/icons/${item['icon']}',
|
||||
width: 20,
|
||||
height: 20,
|
||||
icon: Icon(
|
||||
item['icon'],
|
||||
size: 24,
|
||||
),
|
||||
activeIcon: Image.asset(
|
||||
'assets/icons/${item['icon']}',
|
||||
activeIcon: Icon(
|
||||
item['active_icon'],
|
||||
size: 24,
|
||||
color: AppColors.primary,
|
||||
width: 20,
|
||||
height: 20,
|
||||
),
|
||||
label: item['label'],
|
||||
tooltip: '',
|
||||
|
||||
15
lib/views/user/qr_code/index_page.dart
Normal file
15
lib/views/user/qr_code/index_page.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class UserQrCodePage extends StatefulWidget {
|
||||
const UserQrCodePage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_UserQrCodePageState createState() => _UserQrCodePageState();
|
||||
}
|
||||
|
||||
class _UserQrCodePageState extends State<UserQrCodePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user