From 72807d72333eefbc3615aabdea41849940145aab Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 26 Oct 2022 14:09:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/controllers/private_controller.dart | 1 - lib/models/im/private_conversation_model.dart | 2 - lib/views/conversation/index_page.dart | 62 +++++++++++++++++++ 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/lib/controllers/private_controller.dart b/lib/controllers/private_controller.dart index 4a8806c..4374c42 100644 --- a/lib/controllers/private_controller.dart +++ b/lib/controllers/private_controller.dart @@ -38,7 +38,6 @@ class PrivateController extends GetxController { true) { currentFriend.value.shopId = info.friendInfo!.userProfile?.customInfo!['Staffer']; - currentFriend.value.isStaffer = true; } /// 通过用户自定义字段,判断是否允许陌生人消息 diff --git a/lib/models/im/private_conversation_model.dart b/lib/models/im/private_conversation_model.dart index e73fbdc..3f406bb 100644 --- a/lib/models/im/private_conversation_model.dart +++ b/lib/models/im/private_conversation_model.dart @@ -9,7 +9,6 @@ class PrivateConversationModel { String friendRemark; V2TimConversation? conversation; V2TimUserFullInfo? userProfile; - bool isStaffer; bool allowStranger; // 允许陌生人消息 String? shopId; // 他是哪个店铺的客服 @@ -19,7 +18,6 @@ class PrivateConversationModel { this.isFriend = false, this.conversation, this.userProfile, - this.isStaffer = false, this.allowStranger = true, this.shopId, }); diff --git a/lib/views/conversation/index_page.dart b/lib/views/conversation/index_page.dart index f3b43a6..d4dd17f 100644 --- a/lib/views/conversation/index_page.dart +++ b/lib/views/conversation/index_page.dart @@ -1,7 +1,11 @@ +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/routes/conversation_routes.dart'; import 'package:chat/services/tim/conversation_service.dart'; +import 'package:chat/views/conversation/widgets/message_field.dart'; +import 'package:chat/views/conversation/widgets/message_list.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:tencent_im_sdk_plugin/enum/conversation_type.dart'; @@ -61,10 +65,68 @@ class _ConversationPageState extends State { _topRightAction(), ], ), + body: Column( + children: [ + if (conversation.type == ConversationType.V2TIM_C2C) + _isFriendWidget(), + Expanded( + child: MessageList(conversation), + ), + ], + ), + bottomNavigationBar: MessageField( + conversation, + key: inputextField, + ), ), ); } + Widget _isFriendWidget() { + return GetX( + builder: (_) { + if (!_.currentFriend.value.isFriend) { + return Container( + color: AppColors.warning.withOpacity(0.2), + width: Get.width, + padding: const EdgeInsets.all(8), + child: Row( + children: [ + const Text( + '你们还不是好友,请先', + style: TextStyle( + color: AppColors.unactive, + fontSize: 12, + ), + ), + const SizedBox(width: 4), + InkWell( + onTap: () { + Get.toNamed( + ContactRoutes.friendRequestApply, + arguments: { + 'userID': conversation.userID!, + }, + ); + }, + child: const Text( + '添加好友', + style: TextStyle( + color: AppColors.primary, + fontSize: 12, + ), + ), + ), + ], + ), + ); + } else { + return Container(); + } + }, + ); + } + Widget _topRightAction() { return IconButton( icon: const Icon(Icons.more_horiz),