tencent_cloud_chat_uikit source code update to version 4.0.8
This commit is contained in:
parent
744204bb3a
commit
8ada938397
|
|
@ -1,3 +1,10 @@
|
||||||
|
# 4.0.8
|
||||||
|
* Use the OfflinePushInfo constructor, not the fromJson function.
|
||||||
|
|
||||||
|
# 4.0.7
|
||||||
|
* Fixed the issue that modifying your own adding friend permissions does not take effect.
|
||||||
|
* Fixed the setGroupInfo exception problem.
|
||||||
|
|
||||||
# 4.0.6
|
# 4.0.6
|
||||||
* Solve the updateSelfInfo exception problem.
|
* Solve the updateSelfInfo exception problem.
|
||||||
* The success of calling the initSDK interface is determined by the code of the return value. Avoid inaccurate judgment when calling the interface multiple times.
|
* The success of calling the initSDK interface is determined by the code of the return value. Avoid inaccurate judgment when calling the interface multiple times.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
|
|
||||||
enum TIMCallbackType { API_ERROR, FLUTTER_ERROR, INFO }
|
enum TIMCallbackType { API_ERROR, FLUTTER_ERROR, INFO }
|
||||||
|
|
||||||
class TIMCallback {
|
class TIMCallback {
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,8 @@ abstract class TIMState<T extends StatefulWidget> extends State<T> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final onFlutterError = FlutterError.onError;
|
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
FlutterError.presentError(details);
|
FlutterError.presentError(details);
|
||||||
// onFlutterError?.call(details);
|
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(
|
||||||
type: TIMCallbackType.FLUTTER_ERROR,
|
type: TIMCallbackType.FLUTTER_ERROR,
|
||||||
stackTrace: details.stack,
|
stackTrace: details.stack,
|
||||||
|
|
|
||||||
|
|
@ -27,9 +27,7 @@ abstract class TIMStatelessWidget extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final onFlutterError = FlutterError.onError;
|
|
||||||
FlutterError.onError = (FlutterErrorDetails details) {
|
FlutterError.onError = (FlutterErrorDetails details) {
|
||||||
// onFlutterError?.call(details);
|
|
||||||
FlutterError.presentError(details);
|
FlutterError.presentError(details);
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(
|
||||||
type: TIMCallbackType.FLUTTER_ERROR,
|
type: TIMCallbackType.FLUTTER_ERROR,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_class.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_class.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
||||||
|
|
||||||
|
|
@ -63,7 +67,8 @@ abstract class DefaultLifeCycle {
|
||||||
|
|
||||||
static defaultNullCallbackSolution(dynamic) {}
|
static defaultNullCallbackSolution(dynamic) {}
|
||||||
|
|
||||||
static Future<bool> defaultAddFriend(String userID, String? remark, String? friendGroup, String? addWording, [BuildContext? context]) async {
|
static Future<bool> defaultAddFriend(String userID, String? remark, String? friendGroup, String? addWording,
|
||||||
|
[BuildContext? context]) async {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,7 +82,8 @@ abstract class DefaultLifeCycle {
|
||||||
|
|
||||||
static Future<void> defaultPopBackRemind() async {
|
static Future<void> defaultPopBackRemind() async {
|
||||||
// You have to implement the exact life cycle hook in this case.
|
// You have to implement the exact life cycle hook in this case.
|
||||||
TIMUIKitClass.onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("请传入离开群组生命周期函数,提供返回首页或其他页面的导航方法。"), infoCode: 6661402));
|
TIMUIKitClass.onTIMCallback(TIMCallback(
|
||||||
|
type: TIMCallbackType.INFO, infoRecommendText: TIM_t("请传入离开群组生命周期函数,提供返回首页或其他页面的导航方法。"), infoCode: 6661402));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,18 @@ import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/V2TimGroupListener.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/V2TimGroupListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_change_info_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_change_info_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/manager/v2_tim_manager.dart';
|
import 'package:tencent_cloud_chat_sdk/manager/v2_tim_manager.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_change_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_change_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_change_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_topic_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_topic_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_topic_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart';
|
||||||
|
|
@ -48,51 +54,42 @@ class TUIGroupListenerModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
TUIGroupListenerModel() {
|
TUIGroupListenerModel() {
|
||||||
_groupListener = V2TimGroupListener(
|
_groupListener = V2TimGroupListener(onMemberInvited: (groupID, opUser, memberList) {
|
||||||
onMemberInvited: (groupID, opUser, memberList) {
|
_needUpdate = NeedUpdate(groupID, UpdateType.memberList, "");
|
||||||
_needUpdate = NeedUpdate(groupID, UpdateType.memberList, "");
|
notifyListeners();
|
||||||
notifyListeners();
|
}, onMemberKicked: (groupID, opUser, memberList) async {
|
||||||
},
|
if (_isLoginUserKickedFromGroup(groupID, memberList)) {
|
||||||
onMemberKicked: (groupID, opUser, memberList) async {
|
|
||||||
if (_isLoginUserKickedFromGroup(groupID, memberList)) {
|
|
||||||
_deleteGroupConversation(groupID);
|
|
||||||
|
|
||||||
final groupName = await _getGroupName(groupID);
|
|
||||||
_needUpdate = NeedUpdate(groupID, UpdateType.kickedFromGroup, groupName);
|
|
||||||
notifyListeners();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMemberEnter: (String groupID, List<V2TimGroupMemberInfo> memberList) {
|
|
||||||
_needUpdate = NeedUpdate(groupID, UpdateType.memberList, "");
|
|
||||||
notifyListeners();
|
|
||||||
},
|
|
||||||
onMemberLeave: (String groupID, V2TimGroupMemberInfo member) {
|
|
||||||
_needUpdate = NeedUpdate(groupID, UpdateType.memberList, "");
|
|
||||||
notifyListeners();
|
|
||||||
},
|
|
||||||
onGroupInfoChanged: (groupID, changeInfos) {
|
|
||||||
_needUpdate = NeedUpdate(groupID, UpdateType.groupInfo, "");
|
|
||||||
for (V2TimGroupChangeInfo info in changeInfos) {
|
|
||||||
if (info.type == GroupChangeInfoType.V2TIM_GROUP_INFO_CHANGE_TYPE_OWNER) {
|
|
||||||
_needUpdate!.groupInfoSubType = GroupChangeInfoType.V2TIM_GROUP_INFO_CHANGE_TYPE_OWNER;
|
|
||||||
_needUpdate!.ownerID = info.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
notifyListeners();
|
|
||||||
},
|
|
||||||
onReceiveJoinApplication:
|
|
||||||
(String groupID, V2TimGroupMemberInfo member, String opReason) async {
|
|
||||||
_onReceiveJoinApplication(groupID, member, opReason);
|
|
||||||
chatViewModel.refreshGroupApplicationList();
|
|
||||||
notifyListeners();
|
|
||||||
},
|
|
||||||
onGroupDismissed: (String groupID, V2TimGroupMemberInfo opUser) async {
|
|
||||||
_deleteGroupConversation(groupID);
|
_deleteGroupConversation(groupID);
|
||||||
|
|
||||||
final groupName = await _getGroupName(groupID);
|
final groupName = await _getGroupName(groupID);
|
||||||
_needUpdate = NeedUpdate(groupID, UpdateType.groupDismissed, groupName);
|
_needUpdate = NeedUpdate(groupID, UpdateType.kickedFromGroup, groupName);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
);
|
}, onMemberEnter: (String groupID, List<V2TimGroupMemberInfo> memberList) {
|
||||||
|
_needUpdate = NeedUpdate(groupID, UpdateType.memberList, "");
|
||||||
|
notifyListeners();
|
||||||
|
}, onMemberLeave: (String groupID, V2TimGroupMemberInfo member) {
|
||||||
|
_needUpdate = NeedUpdate(groupID, UpdateType.memberList, "");
|
||||||
|
notifyListeners();
|
||||||
|
}, onGroupInfoChanged: (groupID, changeInfos) {
|
||||||
|
_needUpdate = NeedUpdate(groupID, UpdateType.groupInfo, "");
|
||||||
|
for (V2TimGroupChangeInfo info in changeInfos) {
|
||||||
|
if (info.type == GroupChangeInfoType.V2TIM_GROUP_INFO_CHANGE_TYPE_OWNER) {
|
||||||
|
_needUpdate!.groupInfoSubType = GroupChangeInfoType.V2TIM_GROUP_INFO_CHANGE_TYPE_OWNER;
|
||||||
|
_needUpdate!.ownerID = info.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
notifyListeners();
|
||||||
|
}, onReceiveJoinApplication: (String groupID, V2TimGroupMemberInfo member, String opReason) async {
|
||||||
|
_onReceiveJoinApplication(groupID, member, opReason);
|
||||||
|
chatViewModel.refreshGroupApplicationList();
|
||||||
|
notifyListeners();
|
||||||
|
}, onGroupDismissed: (String groupID, V2TimGroupMemberInfo opUser) async {
|
||||||
|
_deleteGroupConversation(groupID);
|
||||||
|
final groupName = await _getGroupName(groupID);
|
||||||
|
_needUpdate = NeedUpdate(groupID, UpdateType.groupDismissed, groupName);
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setGroupListener() {
|
setGroupListener() {
|
||||||
|
|
@ -104,8 +101,7 @@ class TUIGroupListenerModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
getCommunityCategoryList(String groupID) async {
|
getCommunityCategoryList(String groupID) async {
|
||||||
final Map<String, String>? customInfo =
|
final Map<String, String>? customInfo = await getCommunityCustomInfo(groupID);
|
||||||
await getCommunityCustomInfo(groupID);
|
|
||||||
if (customInfo != null) {
|
if (customInfo != null) {
|
||||||
final String? categoryListString = customInfo["categoryList"];
|
final String? categoryListString = customInfo["categoryList"];
|
||||||
if (categoryListString != null && categoryListString.isNotEmpty) {
|
if (categoryListString != null && categoryListString.isNotEmpty) {
|
||||||
|
|
@ -116,9 +112,7 @@ class TUIGroupListenerModel extends ChangeNotifier {
|
||||||
|
|
||||||
Future<Map<String, String>?> getCommunityCustomInfo(String groupID) async {
|
Future<Map<String, String>?> getCommunityCustomInfo(String groupID) async {
|
||||||
V2TimValueCallback<List<V2TimGroupInfoResult>> res =
|
V2TimValueCallback<List<V2TimGroupInfoResult>> res =
|
||||||
await TencentImSDKPlugin.v2TIMManager
|
await TencentImSDKPlugin.v2TIMManager.getGroupManager().getGroupsInfo(groupIDList: [groupID]);
|
||||||
.getGroupManager()
|
|
||||||
.getGroupsInfo(groupIDList: [groupID]);
|
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
final V2TimGroupInfoResult? groupInfo = res.data?[0];
|
final V2TimGroupInfoResult? groupInfo = res.data?[0];
|
||||||
if (groupInfo != null) {
|
if (groupInfo != null) {
|
||||||
|
|
@ -129,10 +123,8 @@ class TUIGroupListenerModel extends ChangeNotifier {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setCommunityCategoryList(
|
setCommunityCategoryList(String groupID, String groupType, List<String> newCategoryList) async {
|
||||||
String groupID, String groupType, List<String> newCategoryList) async {
|
final Map<String, String>? customInfo = await getCommunityCustomInfo(groupID);
|
||||||
final Map<String, String>? customInfo =
|
|
||||||
await getCommunityCustomInfo(groupID);
|
|
||||||
customInfo?["categoryList"] = jsonEncode(newCategoryList);
|
customInfo?["categoryList"] = jsonEncode(newCategoryList);
|
||||||
TencentImSDKPlugin.v2TIMManager.getGroupManager().setGroupInfo(
|
TencentImSDKPlugin.v2TIMManager.getGroupManager().setGroupInfo(
|
||||||
info: V2TimGroupInfo(
|
info: V2TimGroupInfo(
|
||||||
|
|
@ -149,10 +141,8 @@ class TUIGroupListenerModel extends ChangeNotifier {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onReceiveJoinApplication(
|
_onReceiveJoinApplication(String groupID, V2TimGroupMemberInfo member, String opReason) {
|
||||||
String groupID, V2TimGroupMemberInfo member, String opReason) {
|
Future.delayed(const Duration(milliseconds: 500), () => chatViewModel.refreshGroupApplicationList());
|
||||||
Future.delayed(const Duration(milliseconds: 500),
|
|
||||||
() => chatViewModel.refreshGroupApplicationList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> _getGroupName(String groupID) async {
|
Future<String> _getGroupName(String groupID) async {
|
||||||
|
|
@ -177,6 +167,3 @@ class TUIGroupListenerModel extends ChangeNotifier {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
|
|
||||||
class UserProfile {
|
class UserProfile {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ import 'dart:io';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/tim_uikit_cloud_custom_data.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/tim_uikit_cloud_custom_data.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/core_services_implements.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/core_services_implements.dart';
|
||||||
|
|
@ -14,15 +15,13 @@ class TUIChatModelTools {
|
||||||
final TUIChatGlobalModel globalModel = serviceLocator<TUIChatGlobalModel>();
|
final TUIChatGlobalModel globalModel = serviceLocator<TUIChatGlobalModel>();
|
||||||
final CoreServicesImpl _coreServices = serviceLocator<CoreServicesImpl>();
|
final CoreServicesImpl _coreServices = serviceLocator<CoreServicesImpl>();
|
||||||
|
|
||||||
OfflinePushInfo buildMessagePushInfo(
|
OfflinePushInfo buildMessagePushInfo(V2TimMessage message, String convID, ConvType convType) {
|
||||||
V2TimMessage message, String convID, ConvType convType) {
|
|
||||||
String createJSON(String convID) {
|
String createJSON(String convID) {
|
||||||
return "{\"conversationID\": \"$convID\"}";
|
return "{\"conversationID\": \"$convID\"}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globalModel.chatConfig.offlinePushInfo != null) {
|
if (globalModel.chatConfig.offlinePushInfo != null) {
|
||||||
final customData =
|
final customData = globalModel.chatConfig.offlinePushInfo!(message, convID, convType);
|
||||||
globalModel.chatConfig.offlinePushInfo!(message, convID, convType);
|
|
||||||
if (customData != null) {
|
if (customData != null) {
|
||||||
return customData;
|
return customData;
|
||||||
}
|
}
|
||||||
|
|
@ -33,12 +32,8 @@ class TUIChatModelTools {
|
||||||
// If user provides null, use default ext.
|
// If user provides null, use default ext.
|
||||||
String ext = globalModel.chatConfig.notificationExt != null
|
String ext = globalModel.chatConfig.notificationExt != null
|
||||||
? globalModel.chatConfig.notificationExt!(message, convID, convType) ??
|
? globalModel.chatConfig.notificationExt!(message, convID, convType) ??
|
||||||
(convType == ConvType.c2c
|
(convType == ConvType.c2c ? createJSON("c2c_${message.sender}") : createJSON("group_$convID"))
|
||||||
? createJSON("c2c_${message.sender}")
|
: (convType == ConvType.c2c ? createJSON("c2c_${message.sender}") : createJSON("group_$convID"));
|
||||||
: createJSON("group_$convID"))
|
|
||||||
: (convType == ConvType.c2c
|
|
||||||
? createJSON("c2c_${message.sender}")
|
|
||||||
: createJSON("group_$convID"));
|
|
||||||
|
|
||||||
String desc = message.userID ?? message.groupID ?? "";
|
String desc = message.userID ?? message.groupID ?? "";
|
||||||
String messageSummary = "";
|
String messageSummary = "";
|
||||||
|
|
@ -76,23 +71,22 @@ class TUIChatModelTools {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globalModel.chatConfig.notificationBody != null) {
|
if (globalModel.chatConfig.notificationBody != null) {
|
||||||
desc =
|
desc = globalModel.chatConfig.notificationBody!(message, convID, convType) ?? messageSummary;
|
||||||
globalModel.chatConfig.notificationBody!(message, convID, convType) ??
|
|
||||||
messageSummary;
|
|
||||||
} else {
|
} else {
|
||||||
desc = messageSummary;
|
desc = messageSummary;
|
||||||
}
|
}
|
||||||
|
|
||||||
return OfflinePushInfo.fromJson({
|
return OfflinePushInfo(
|
||||||
"title": title,
|
title: title,
|
||||||
"desc": desc,
|
desc: desc,
|
||||||
"disablePush": false,
|
disablePush: false,
|
||||||
"ext": ext,
|
ext: ext,
|
||||||
"iOSSound": globalModel.chatConfig.notificationIOSSound,
|
iOSSound: globalModel.chatConfig.notificationIOSSound,
|
||||||
"androidSound": globalModel.chatConfig.notificationAndroidSound,
|
androidSound: globalModel.chatConfig.notificationAndroidSound,
|
||||||
"ignoreIOSBadge": false,
|
ignoreIOSBadge: false,
|
||||||
"androidOPPOChannelID": globalModel.chatConfig.notificationOPPOChannelID,
|
androidOPPOChannelID: globalModel.chatConfig.notificationOPPOChannelID,
|
||||||
});
|
androidVIVOClassification: 1,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
V2TimMessage setUserInfoForMessage(V2TimMessage messageInfo, String? id) {
|
V2TimMessage setUserInfoForMessage(V2TimMessage messageInfo, String? id) {
|
||||||
|
|
@ -102,18 +96,15 @@ class TUIChatModelTools {
|
||||||
messageInfo.nickName = loginUserInfo.nickName;
|
messageInfo.nickName = loginUserInfo.nickName;
|
||||||
messageInfo.sender = loginUserInfo.userID;
|
messageInfo.sender = loginUserInfo.userID;
|
||||||
}
|
}
|
||||||
messageInfo.timestamp =
|
messageInfo.timestamp = (DateTime.now().millisecondsSinceEpoch / 1000).ceil();
|
||||||
(DateTime.now().millisecondsSinceEpoch / 1000).ceil();
|
|
||||||
messageInfo.isSelf = true;
|
messageInfo.isSelf = true;
|
||||||
messageInfo.id = id;
|
messageInfo.id = id;
|
||||||
|
|
||||||
return messageInfo;
|
return messageInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getMessageSummary(V2TimMessage message,
|
String getMessageSummary(V2TimMessage message, String? Function(V2TimMessage message)? abstractMessageBuilder) {
|
||||||
String? Function(V2TimMessage message)? abstractMessageBuilder) {
|
final String? customAbstractMessage = abstractMessageBuilder != null ? abstractMessageBuilder(message) : null;
|
||||||
final String? customAbstractMessage =
|
|
||||||
abstractMessageBuilder != null ? abstractMessageBuilder(message) : null;
|
|
||||||
if (customAbstractMessage != null) {
|
if (customAbstractMessage != null) {
|
||||||
return customAbstractMessage;
|
return customAbstractMessage;
|
||||||
}
|
}
|
||||||
|
|
@ -147,8 +138,7 @@ class TUIChatModelTools {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getMessageAbstract(V2TimMessage message,
|
String getMessageAbstract(V2TimMessage message, String? Function(V2TimMessage message)? abstractMessageBuilder) {
|
||||||
String? Function(V2TimMessage message)? abstractMessageBuilder) {
|
|
||||||
final messageAbstract = RepliedMessageAbstract(
|
final messageAbstract = RepliedMessageAbstract(
|
||||||
summary: TIM_t(getMessageSummary(message, abstractMessageBuilder)),
|
summary: TIM_t(getMessageSummary(message, abstractMessageBuilder)),
|
||||||
elemType: message.elemType,
|
elemType: message.elemType,
|
||||||
|
|
@ -159,18 +149,13 @@ class TUIChatModelTools {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimMessage?> getExistingMessageByID(
|
Future<V2TimMessage?> getExistingMessageByID(
|
||||||
{required String msgID,
|
{required String msgID, required String conversationID, required ConvType conversationType}) async {
|
||||||
required String conversationID,
|
final currentHistoryMsgList = globalModel.messageListMap[conversationID] ?? [];
|
||||||
required ConvType conversationType}) async {
|
|
||||||
final currentHistoryMsgList =
|
|
||||||
globalModel.messageListMap[conversationID] ?? [];
|
|
||||||
final int? targetIndex = currentHistoryMsgList.indexWhere((item) {
|
final int? targetIndex = currentHistoryMsgList.indexWhere((item) {
|
||||||
return item.msgID == msgID;
|
return item.msgID == msgID;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (targetIndex != null &&
|
if (targetIndex != null && targetIndex > -1 && currentHistoryMsgList.isNotEmpty) {
|
||||||
targetIndex > -1 &&
|
|
||||||
currentHistoryMsgList.isNotEmpty) {
|
|
||||||
return currentHistoryMsgList[targetIndex];
|
return currentHistoryMsgList[targetIndex];
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -6,15 +6,24 @@ import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_role_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_role_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/receive_message_opt_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/receive_message_opt_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_operation_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_operation_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_operation_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/group_profile_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/group_profile_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/conversation/conversation_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/conversation/conversation_services.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/core_services_implements.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/core_services_implements.dart';
|
||||||
|
|
@ -108,12 +117,17 @@ class TUIGroupProfileModel extends ChangeNotifier {
|
||||||
if (seq == null || seq == "" || seq == "0") {
|
if (seq == null || seq == "" || seq == "0") {
|
||||||
_groupMemberList?.clear();
|
_groupMemberList?.clear();
|
||||||
}
|
}
|
||||||
final res = await _groupServices.getGroupMemberList(groupID: groupID, filter: GroupMemberFilterTypeEnum.V2TIM_GROUP_MEMBER_FILTER_ALL, count: count, nextSeq: seq ?? _groupMemberListSeq);
|
final res = await _groupServices.getGroupMemberList(
|
||||||
|
groupID: groupID,
|
||||||
|
filter: GroupMemberFilterTypeEnum.V2TIM_GROUP_MEMBER_FILTER_ALL,
|
||||||
|
count: count,
|
||||||
|
nextSeq: seq ?? _groupMemberListSeq);
|
||||||
final groupMemberListRes = res.data;
|
final groupMemberListRes = res.data;
|
||||||
if (res.code == 0 && groupMemberListRes != null) {
|
if (res.code == 0 && groupMemberListRes != null) {
|
||||||
final groupMemberListTemp = groupMemberListRes.memberInfoList ?? [];
|
final groupMemberListTemp = groupMemberListRes.memberInfoList ?? [];
|
||||||
// TODO
|
// TODO
|
||||||
outputLogger.i("loadGroupMemberListfinish,groupMemberListTemp, ${groupMemberListRes.nextSeq}, ${groupMemberListTemp.length}");
|
outputLogger.i(
|
||||||
|
"loadGroupMemberListfinish,groupMemberListTemp, ${groupMemberListRes.nextSeq}, ${groupMemberListTemp.length}");
|
||||||
_groupMemberList = [...?_groupMemberList, ...groupMemberListTemp];
|
_groupMemberList = [...?_groupMemberList, ...groupMemberListTemp];
|
||||||
_groupMemberListSeq = groupMemberListRes.nextSeq ?? "0";
|
_groupMemberListSeq = groupMemberListRes.nextSeq ?? "0";
|
||||||
}
|
}
|
||||||
|
|
@ -136,14 +150,18 @@ class TUIGroupProfileModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
setMessageDisturb(bool value) async {
|
setMessageDisturb(bool value) async {
|
||||||
final res = await _messageService.setGroupReceiveMessageOpt(groupID: _groupID, opt: value ? ReceiveMsgOptEnum.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE : ReceiveMsgOptEnum.V2TIM_RECEIVE_MESSAGE);
|
final res = await _messageService.setGroupReceiveMessageOpt(
|
||||||
|
groupID: _groupID,
|
||||||
|
opt: value ? ReceiveMsgOptEnum.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE : ReceiveMsgOptEnum.V2TIM_RECEIVE_MESSAGE);
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
conversation?.recvOpt = (value ? ReceiveMsgOptEnum.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE : ReceiveMsgOptEnum.V2TIM_RECEIVE_MESSAGE).index;
|
conversation?.recvOpt =
|
||||||
|
(value ? ReceiveMsgOptEnum.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE : ReceiveMsgOptEnum.V2TIM_RECEIVE_MESSAGE).index;
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMember(V2TimGroupMemberSearchParam searchParam) async {
|
Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMember(
|
||||||
|
V2TimGroupMemberSearchParam searchParam) async {
|
||||||
final res = await _groupServices.searchGroupMembers(searchParam: searchParam);
|
final res = await _groupServices.searchGroupMembers(searchParam: searchParam);
|
||||||
|
|
||||||
if (res.code == 0) {}
|
if (res.code == 0) {}
|
||||||
|
|
@ -154,7 +172,9 @@ class TUIGroupProfileModel extends ChangeNotifier {
|
||||||
if (_groupInfo != null) {
|
if (_groupInfo != null) {
|
||||||
String? originalGroupName = _groupInfo?.groupName;
|
String? originalGroupName = _groupInfo?.groupName;
|
||||||
_groupInfo?.groupName = groupName;
|
_groupInfo?.groupName = groupName;
|
||||||
final response = await _groupServices.setGroupInfo(info: V2TimGroupInfo.fromJson({"groupID": _groupID, "groupType": _groupInfo!.groupType, "groupName": groupName}));
|
V2TimGroupInfo v2timGroupInfo = V2TimGroupInfo(groupID: _groupID, groupType: _groupInfo!.groupType);
|
||||||
|
v2timGroupInfo.groupName = groupName;
|
||||||
|
final response = await _groupServices.setGroupInfo(info: v2timGroupInfo);
|
||||||
if (response.code != 0) {
|
if (response.code != 0) {
|
||||||
_groupInfo?.groupName = originalGroupName;
|
_groupInfo?.groupName = originalGroupName;
|
||||||
}
|
}
|
||||||
|
|
@ -166,7 +186,9 @@ class TUIGroupProfileModel extends ChangeNotifier {
|
||||||
|
|
||||||
setGroupNotification(String notification) async {
|
setGroupNotification(String notification) async {
|
||||||
if (_groupInfo != null) {
|
if (_groupInfo != null) {
|
||||||
final response = await _groupServices.setGroupInfo(info: V2TimGroupInfo.fromJson({"groupID": _groupID, "groupType": _groupInfo!.groupType, "notification": notification}));
|
V2TimGroupInfo v2timGroupInfo = V2TimGroupInfo(groupID: _groupID, groupType: _groupInfo!.groupType);
|
||||||
|
v2timGroupInfo.notification = notification;
|
||||||
|
final response = await _groupServices.setGroupInfo(info: v2timGroupInfo);
|
||||||
if (response.code == 0) {
|
if (response.code == 0) {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
_groupInfo?.notification = notification;
|
_groupInfo?.notification = notification;
|
||||||
|
|
@ -208,7 +230,9 @@ class TUIGroupProfileModel extends ChangeNotifier {
|
||||||
if (_groupInfo != null) {
|
if (_groupInfo != null) {
|
||||||
int? originalAddopt = _groupInfo?.groupAddOpt;
|
int? originalAddopt = _groupInfo?.groupAddOpt;
|
||||||
_groupInfo?.groupAddOpt = addOpt;
|
_groupInfo?.groupAddOpt = addOpt;
|
||||||
final response = await _groupServices.setGroupInfo(info: V2TimGroupInfo.fromJson({"groupID": _groupID, "groupType": _groupInfo!.groupType, "groupAddOpt": addOpt}));
|
V2TimGroupInfo v2timGroupInfo = V2TimGroupInfo(groupID: _groupID, groupType: _groupInfo!.groupType);
|
||||||
|
v2timGroupInfo.groupAddOpt = addOpt;
|
||||||
|
final response = await _groupServices.setGroupInfo(info: v2timGroupInfo);
|
||||||
if (response.code != 0) {
|
if (response.code != 0) {
|
||||||
_groupInfo?.groupAddOpt = originalAddopt;
|
_groupInfo?.groupAddOpt = originalAddopt;
|
||||||
}
|
}
|
||||||
|
|
@ -219,7 +243,8 @@ class TUIGroupProfileModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimCallback> setMemberToNormal(String userID) async {
|
Future<V2TimCallback> setMemberToNormal(String userID) async {
|
||||||
final res = await _groupServices.setGroupMemberRole(groupID: _groupID, userID: userID, role: GroupMemberRoleTypeEnum.V2TIM_GROUP_MEMBER_ROLE_MEMBER);
|
final res = await _groupServices.setGroupMemberRole(
|
||||||
|
groupID: _groupID, userID: userID, role: GroupMemberRoleTypeEnum.V2TIM_GROUP_MEMBER_ROLE_MEMBER);
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
final targetIndex = _groupMemberList!.indexWhere((e) => e!.userID == userID);
|
final targetIndex = _groupMemberList!.indexWhere((e) => e!.userID == userID);
|
||||||
if (targetIndex != -1) {
|
if (targetIndex != -1) {
|
||||||
|
|
@ -233,7 +258,8 @@ class TUIGroupProfileModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimCallback> setMemberToAdmin(String userID) async {
|
Future<V2TimCallback> setMemberToAdmin(String userID) async {
|
||||||
final res = await _groupServices.setGroupMemberRole(groupID: _groupID, userID: userID, role: GroupMemberRoleTypeEnum.V2TIM_GROUP_MEMBER_ROLE_ADMIN);
|
final res = await _groupServices.setGroupMemberRole(
|
||||||
|
groupID: _groupID, userID: userID, role: GroupMemberRoleTypeEnum.V2TIM_GROUP_MEMBER_ROLE_ADMIN);
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
final targetIndex = _groupMemberList!.indexWhere((e) => e!.userID == userID);
|
final targetIndex = _groupMemberList!.indexWhere((e) => e!.userID == userID);
|
||||||
if (targetIndex != -1) {
|
if (targetIndex != -1) {
|
||||||
|
|
@ -252,7 +278,8 @@ class TUIGroupProfileModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 把之前的群主更新为普通成员
|
// 把之前的群主更新为普通成员
|
||||||
final preOwnerIndex = _groupMemberList!.indexWhere((e) => e!.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER);
|
final preOwnerIndex =
|
||||||
|
_groupMemberList!.indexWhere((e) => e!.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER);
|
||||||
if (preOwnerIndex != -1) {
|
if (preOwnerIndex != -1) {
|
||||||
final preOwnerElem = _groupMemberList![preOwnerIndex];
|
final preOwnerElem = _groupMemberList![preOwnerIndex];
|
||||||
preOwnerElem?.role = GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER;
|
preOwnerElem?.role = GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER;
|
||||||
|
|
@ -297,7 +324,9 @@ class TUIGroupProfileModel extends ChangeNotifier {
|
||||||
Future<V2TimCallback?> setMuteAll(bool muteAll) async {
|
Future<V2TimCallback?> setMuteAll(bool muteAll) async {
|
||||||
if (_groupInfo != null) {
|
if (_groupInfo != null) {
|
||||||
_groupInfo?.isAllMuted = muteAll;
|
_groupInfo?.isAllMuted = muteAll;
|
||||||
final response = await _groupServices.setGroupInfo(info: V2TimGroupInfo.fromJson({"groupID": _groupInfo!.groupID, "groupType": _groupInfo!.groupType, "isAllMuted": muteAll}));
|
V2TimGroupInfo v2timGroupInfo = V2TimGroupInfo(groupID: _groupID, groupType: _groupInfo!.groupType);
|
||||||
|
v2timGroupInfo.isAllMuted = muteAll;
|
||||||
|
final response = await _groupServices.setGroupInfo(info: v2timGroupInfo);
|
||||||
if (response.code != 0) {
|
if (response.code != 0) {
|
||||||
_groupInfo?.isAllMuted = muteAll;
|
_groupInfo?.isAllMuted = muteAll;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,16 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/receive_message_opt_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/receive_message_opt_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_operation_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/profile_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/profile_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/model/profile_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/model/profile_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_friendship_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_friendship_view_model.dart';
|
||||||
|
|
@ -18,12 +23,9 @@ import 'package:tencent_cloud_chat_uikit/data_services/message/message_services.
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
||||||
|
|
||||||
class TUIProfileViewModel extends ChangeNotifier {
|
class TUIProfileViewModel extends ChangeNotifier {
|
||||||
final ConversationService _conversationService =
|
final ConversationService _conversationService = serviceLocator<ConversationService>();
|
||||||
serviceLocator<ConversationService>();
|
final FriendshipServices _friendshipServices = serviceLocator<FriendshipServices>();
|
||||||
final FriendshipServices _friendshipServices =
|
final TUIFriendShipViewModel _friendShipViewModel = serviceLocator<TUIFriendShipViewModel>();
|
||||||
serviceLocator<FriendshipServices>();
|
|
||||||
final TUIFriendShipViewModel _friendShipViewModel =
|
|
||||||
serviceLocator<TUIFriendShipViewModel>();
|
|
||||||
final CoreServicesImpl _coreServices = serviceLocator<CoreServicesImpl>();
|
final CoreServicesImpl _coreServices = serviceLocator<CoreServicesImpl>();
|
||||||
final MessageService _messageService = serviceLocator<MessageService>();
|
final MessageService _messageService = serviceLocator<MessageService>();
|
||||||
|
|
||||||
|
|
@ -59,16 +61,14 @@ class TUIProfileViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadData({required String userID, bool isNeedConversation = true}) async {
|
loadData({required String userID, bool isNeedConversation = true}) async {
|
||||||
if(userID.isEmpty){
|
if (userID.isEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
V2TimFriendInfo? friendUserInfo;
|
V2TimFriendInfo? friendUserInfo;
|
||||||
V2TimConversation? conversation;
|
V2TimConversation? conversation;
|
||||||
final userInfoList =
|
final userInfoList = await _friendshipServices.getFriendsInfo(userIDList: [userID]);
|
||||||
await _friendshipServices.getFriendsInfo(userIDList: [userID]);
|
final checkFriend =
|
||||||
final checkFriend = await _friendshipServices.checkFriend(
|
await _friendshipServices.checkFriend(userIDList: [userID], checkType: FriendTypeEnum.V2TIM_FRIEND_TYPE_SINGLE);
|
||||||
userIDList: [userID],
|
|
||||||
checkType: FriendTypeEnum.V2TIM_FRIEND_TYPE_SINGLE);
|
|
||||||
|
|
||||||
if (checkFriend != null) {
|
if (checkFriend != null) {
|
||||||
final res = checkFriend.first;
|
final res = checkFriend.first;
|
||||||
|
|
@ -82,42 +82,33 @@ class TUIProfileViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNeedConversation) {
|
if (isNeedConversation) {
|
||||||
conversation = await _conversationService.getConversation(
|
conversation = await _conversationService.getConversation(conversationID: "c2c_$userID");
|
||||||
conversationID: "c2c_$userID");
|
|
||||||
_isDisturb = conversation?.recvOpt == 2;
|
_isDisturb = conversation?.recvOpt == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
final friendInfo =
|
final friendInfo = await _lifeCycle?.didGetFriendInfo(friendUserInfo) ?? friendUserInfo;
|
||||||
await _lifeCycle?.didGetFriendInfo(friendUserInfo) ?? friendUserInfo;
|
|
||||||
|
|
||||||
_isDisturb = conversation?.recvOpt == 2;
|
_isDisturb = conversation?.recvOpt == 2;
|
||||||
_userProfile =
|
_userProfile = UserProfile(friendInfo: friendInfo, conversation: conversation);
|
||||||
UserProfile(friendInfo: friendInfo, conversation: conversation);
|
|
||||||
|
|
||||||
_shouldAddToBlackList = _friendShipViewModel.blockList
|
_shouldAddToBlackList = _friendShipViewModel.blockList.indexWhere((element) => element.userID == userID) > -1;
|
||||||
.indexWhere((element) => element.userID == userID) >
|
|
||||||
-1;
|
|
||||||
|
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimCallback> pinedConversation(bool isPined, String convID) async {
|
Future<V2TimCallback> pinedConversation(bool isPined, String convID) async {
|
||||||
final res = await _conversationService.pinConversation(
|
final res = await _conversationService.pinConversation(conversationID: convID, isPinned: isPined);
|
||||||
conversationID: convID, isPinned: isPined);
|
|
||||||
_userProfile?.conversation!.isPinned = isPined;
|
_userProfile?.conversation!.isPinned = isPined;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<V2TimFriendOperationResult>?> addToBlackList(
|
Future<List<V2TimFriendOperationResult>?> addToBlackList(bool shouldAdd, String userID) async {
|
||||||
bool shouldAdd, String userID) async {
|
if (_lifeCycle?.shouldAddToBlockList != null && await _lifeCycle!.shouldAddToBlockList(userID) == false) {
|
||||||
if (_lifeCycle?.shouldAddToBlockList != null &&
|
|
||||||
await _lifeCycle!.shouldAddToBlockList(userID) == false) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (shouldAdd) {
|
if (shouldAdd) {
|
||||||
final res =
|
final res = await _friendshipServices.addToBlackList(userIDList: [userID]);
|
||||||
await _friendshipServices.addToBlackList(userIDList: [userID]);
|
|
||||||
if (res != null && res.isNotEmpty) {
|
if (res != null && res.isNotEmpty) {
|
||||||
final result = res.first;
|
final result = res.first;
|
||||||
if (result.resultCode == 0) {
|
if (result.resultCode == 0) {
|
||||||
|
|
@ -128,15 +119,13 @@ class TUIProfileViewModel extends ChangeNotifier {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return res;
|
return res;
|
||||||
} else {
|
} else {
|
||||||
final res =
|
final res = await _friendshipServices.deleteFromBlackList(userIDList: [userID]);
|
||||||
await _friendshipServices.deleteFromBlackList(userIDList: [userID]);
|
|
||||||
if (res != null && res.isNotEmpty) {
|
if (res != null && res.isNotEmpty) {
|
||||||
final result = res.first;
|
final result = res.first;
|
||||||
if (result.resultCode == 0) {
|
if (result.resultCode == 0) {
|
||||||
_shouldAddToBlackList = false;
|
_shouldAddToBlackList = false;
|
||||||
final checkFriend = await _friendshipServices.checkFriend(
|
final checkFriend = await _friendshipServices
|
||||||
userIDList: [userID],
|
.checkFriend(userIDList: [userID], checkType: FriendTypeEnum.V2TIM_FRIEND_TYPE_SINGLE);
|
||||||
checkType: FriendTypeEnum.V2TIM_FRIEND_TYPE_SINGLE);
|
|
||||||
if (checkFriend != null) {
|
if (checkFriend != null) {
|
||||||
final res = checkFriend.first;
|
final res = checkFriend.first;
|
||||||
_friendType = res.resultType;
|
_friendType = res.resultType;
|
||||||
|
|
@ -150,13 +139,11 @@ class TUIProfileViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimFriendOperationResult?> deleteFriend(String userID, {bool needUpdateData = true}) async {
|
Future<V2TimFriendOperationResult?> deleteFriend(String userID, {bool needUpdateData = true}) async {
|
||||||
if (_lifeCycle?.shouldDeleteFriend != null &&
|
if (_lifeCycle?.shouldDeleteFriend != null && await _lifeCycle!.shouldDeleteFriend(userID) == false) {
|
||||||
await _lifeCycle!.shouldDeleteFriend(userID) == false) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final res = await _friendshipServices.deleteFromFriendList(
|
final res = await _friendshipServices
|
||||||
userIDList: [userID],
|
.deleteFromFriendList(userIDList: [userID], deleteType: FriendTypeEnum.V2TIM_FRIEND_TYPE_BOTH);
|
||||||
deleteType: FriendTypeEnum.V2TIM_FRIEND_TYPE_BOTH);
|
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
_conversationService.deleteConversation(conversationID: "c2c_$userID");
|
_conversationService.deleteConversation(conversationID: "c2c_$userID");
|
||||||
if (needUpdateData) {
|
if (needUpdateData) {
|
||||||
|
|
@ -169,11 +156,9 @@ class TUIProfileViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimCallback> changeFriendVerificationMethod(int allowType) async {
|
Future<V2TimCallback> changeFriendVerificationMethod(int allowType) async {
|
||||||
final res = await _coreServices.setSelfInfo(
|
V2TimUserFullInfo userFullInfo = V2TimUserFullInfo();
|
||||||
userFullInfo: V2TimUserFullInfo.fromJson(
|
userFullInfo.allowType = allowType;
|
||||||
{"allowType": allowType},
|
final res = await _coreServices.setSelfInfo(userFullInfo: userFullInfo);
|
||||||
),
|
|
||||||
);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
_userProfile?.friendInfo!.userProfile!.allowType = allowType;
|
_userProfile?.friendInfo!.userProfile!.allowType = allowType;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
@ -182,12 +167,10 @@ class TUIProfileViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimFriendOperationResult?> addFriend(String userID) async {
|
Future<V2TimFriendOperationResult?> addFriend(String userID) async {
|
||||||
if (_lifeCycle?.shouldAddFriend != null &&
|
if (_lifeCycle?.shouldAddFriend != null && await _lifeCycle!.shouldAddFriend(userID) == false) {
|
||||||
await _lifeCycle!.shouldAddFriend(userID) == false) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final res = await _friendshipServices.addFriend(
|
final res = await _friendshipServices.addFriend(userID: userID, addType: FriendTypeEnum.V2TIM_FRIEND_TYPE_BOTH);
|
||||||
userID: userID, addType: FriendTypeEnum.V2TIM_FRIEND_TYPE_BOTH);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
loadData(userID: userID);
|
loadData(userID: userID);
|
||||||
return res.data;
|
return res.data;
|
||||||
|
|
@ -197,8 +180,7 @@ class TUIProfileViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimCallback> updateRemarks(String userID, String remark) async {
|
Future<V2TimCallback> updateRemarks(String userID, String remark) async {
|
||||||
final res = await _friendshipServices.setFriendInfo(
|
final res = await _friendshipServices.setFriendInfo(userID: userID, friendRemark: remark);
|
||||||
userID: userID, friendRemark: remark);
|
|
||||||
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
_userProfile?.friendInfo!.friendRemark = remark;
|
_userProfile?.friendInfo!.friendRemark = remark;
|
||||||
|
|
@ -210,9 +192,7 @@ class TUIProfileViewModel extends ChangeNotifier {
|
||||||
Future<V2TimCallback> setMessageDisturb(String userID, bool isDisturb) async {
|
Future<V2TimCallback> setMessageDisturb(String userID, bool isDisturb) async {
|
||||||
final res = await _messageService.setC2CReceiveMessageOpt(
|
final res = await _messageService.setC2CReceiveMessageOpt(
|
||||||
userIDList: [userID],
|
userIDList: [userID],
|
||||||
opt: isDisturb
|
opt: isDisturb ? ReceiveMsgOptEnum.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE : ReceiveMsgOptEnum.V2TIM_RECEIVE_MESSAGE);
|
||||||
? ReceiveMsgOptEnum.V2TIM_RECEIVE_NOT_NOTIFY_MESSAGE
|
|
||||||
: ReceiveMsgOptEnum.V2TIM_RECEIVE_MESSAGE);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
_isDisturb = isDisturb;
|
_isDisturb = isDisturb;
|
||||||
}
|
}
|
||||||
|
|
@ -221,7 +201,7 @@ class TUIProfileViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateUserInfo(V2TimUserFullInfo userFullInfo) {
|
updateUserInfo(V2TimUserFullInfo userFullInfo) {
|
||||||
if (userFullInfo.nickName != null) {
|
if (userFullInfo.nickName != null) {
|
||||||
_userProfile?.friendInfo!.userProfile?.nickName = userFullInfo.nickName;
|
_userProfile?.friendInfo!.userProfile?.nickName = userFullInfo.nickName;
|
||||||
}
|
}
|
||||||
if (userFullInfo.faceUrl != null) {
|
if (userFullInfo.faceUrl != null) {
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,24 @@ import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_priority_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_priority_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_custom_elem.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_custom_elem.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_image.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_custom_elem.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_download_progress.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_application.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_receipt.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_image.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_msg_create_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_image.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_download_progress.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_download_progress.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_receipt.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_receipt.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_msg_create_info_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_msg_create_info_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_class.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_class.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/chat_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/chat_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_model_tools.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_model_tools.dart';
|
||||||
|
|
@ -58,7 +67,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
|
|
||||||
ChatLifeCycle? _lifeCycle;
|
ChatLifeCycle? _lifeCycle;
|
||||||
bool _isDownloading = false;
|
bool _isDownloading = false;
|
||||||
final List<Map<String, String>> _waitingDownloadList = List.empty(growable: true); // example {"savePath":"","url":"",msgId:""}
|
final List<Map<String, String>> _waitingDownloadList =
|
||||||
|
List.empty(growable: true); // example {"savePath":"","url":"",msgId:""}
|
||||||
int _totalUnreadCount = 0;
|
int _totalUnreadCount = 0;
|
||||||
String localKeyPrefix = "TUIKit_conversation_stored_";
|
String localKeyPrefix = "TUIKit_conversation_stored_";
|
||||||
String localMsgIDListKey = "TUIKit_conversation_list";
|
String localMsgIDListKey = "TUIKit_conversation_list";
|
||||||
|
|
@ -210,9 +220,13 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
|
|
||||||
Map<String, V2TimMessageReceipt> get messageReadReceiptMap => _messageReadReceiptMap;
|
Map<String, V2TimMessageReceipt> get messageReadReceiptMap => _messageReadReceiptMap;
|
||||||
|
|
||||||
String get currentSelectedConv => _currentConversationList.isNotEmpty ? _currentConversationList[_currentConversationList.length - 1].conversationID : "";
|
String get currentSelectedConv => _currentConversationList.isNotEmpty
|
||||||
|
? _currentConversationList[_currentConversationList.length - 1].conversationID
|
||||||
|
: "";
|
||||||
|
|
||||||
ConvType? get currentSelectedConvType => _currentConversationList.isNotEmpty ? _currentConversationList[_currentConversationList.length - 1].conversationType : null;
|
ConvType? get currentSelectedConvType => _currentConversationList.isNotEmpty
|
||||||
|
? _currentConversationList[_currentConversationList.length - 1].conversationType
|
||||||
|
: null;
|
||||||
|
|
||||||
setCurrentConversation(CurrentConversation value) {
|
setCurrentConversation(CurrentConversation value) {
|
||||||
_currentConversationList.add(value);
|
_currentConversationList.add(value);
|
||||||
|
|
@ -221,7 +235,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
|
|
||||||
clearCurrentConversation() {
|
clearCurrentConversation() {
|
||||||
// Only keep the last 20 messages when existing a chat.
|
// Only keep the last 20 messages when existing a chat.
|
||||||
_messageListMap[currentSelectedConv] = (_messageListMap[currentSelectedConv] ?? []).sublist(0, max(0, min(10, ((_messageListMap[currentSelectedConv] ?? []).length - 1))));
|
_messageListMap[currentSelectedConv] = (_messageListMap[currentSelectedConv] ?? [])
|
||||||
|
.sublist(0, max(0, min(10, ((_messageListMap[currentSelectedConv] ?? []).length - 1))));
|
||||||
if (_currentConversationList.isNotEmpty) {
|
if (_currentConversationList.isNotEmpty) {
|
||||||
_currentConversationList.removeLast();
|
_currentConversationList.removeLast();
|
||||||
}
|
}
|
||||||
|
|
@ -290,11 +305,14 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
if (conversationItem == null || conversationItem.type == null) {
|
if (conversationItem == null || conversationItem.type == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final conversationID = TencentUtils.checkString(conversationItem.userID) ?? TencentUtils.checkString(conversationItem.groupID) ?? conversationItem.conversationID;
|
final conversationID = TencentUtils.checkString(conversationItem.userID) ??
|
||||||
|
TencentUtils.checkString(conversationItem.groupID) ??
|
||||||
|
conversationItem.conversationID;
|
||||||
if (messageListMap[conversationID] == null || messageListMap[conversationID]!.isEmpty) {
|
if (messageListMap[conversationID] == null || messageListMap[conversationID]!.isEmpty) {
|
||||||
index++;
|
index++;
|
||||||
Future.delayed(Duration(milliseconds: 500 * index), () {
|
Future.delayed(Duration(milliseconds: 500 * index), () {
|
||||||
preloadMessageForConversation(conversationID: conversationID, conversationType: ConvType.values[conversationItem.type!]);
|
preloadMessageForConversation(
|
||||||
|
conversationID: conversationID, conversationType: ConvType.values[conversationItem.type!]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -305,7 +323,10 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
required String conversationID,
|
required String conversationID,
|
||||||
}) async {
|
}) async {
|
||||||
final response = await _messageService.getHistoryMessageList(
|
final response = await _messageService.getHistoryMessageList(
|
||||||
count: 10, getType: HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG, userID: conversationType == ConvType.c2c ? conversationID : null, groupID: conversationType == ConvType.group ? conversationID : null);
|
count: 10,
|
||||||
|
getType: HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
||||||
|
userID: conversationType == ConvType.c2c ? conversationID : null,
|
||||||
|
groupID: conversationType == ConvType.group ? conversationID : null);
|
||||||
if (_messageListMap[conversationID] == null || _messageListMap[conversationID]!.isEmpty) {
|
if (_messageListMap[conversationID] == null || _messageListMap[conversationID]!.isEmpty) {
|
||||||
_messageListMap[conversationID] = response;
|
_messageListMap[conversationID] = response;
|
||||||
}
|
}
|
||||||
|
|
@ -324,9 +345,11 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
prefs.remove(localMsgIDListKey);
|
prefs.remove(localMsgIDListKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> updateMessageFromController({required String msgID, required String conversationID, required ConvType conversationType}) async {
|
Future<void> updateMessageFromController(
|
||||||
|
{required String msgID, required String conversationID, required ConvType conversationType}) async {
|
||||||
final TUIChatModelTools tools = serviceLocator<TUIChatModelTools>();
|
final TUIChatModelTools tools = serviceLocator<TUIChatModelTools>();
|
||||||
V2TimMessage? newMessage = await tools.getExistingMessageByID(msgID: msgID, conversationID: conversationID, conversationType: conversationType);
|
V2TimMessage? newMessage = await tools.getExistingMessageByID(
|
||||||
|
msgID: msgID, conversationID: conversationID, conversationType: conversationType);
|
||||||
if (newMessage != null) {
|
if (newMessage != null) {
|
||||||
onMessageModified(newMessage, currentSelectedConv);
|
onMessageModified(newMessage, currentSelectedConv);
|
||||||
}
|
}
|
||||||
|
|
@ -352,7 +375,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
List<V2TimMessage> needPreViewList = msgList.sublist(0, max(0, min(5, msgList.length - 1)));
|
List<V2TimMessage> needPreViewList = msgList.sublist(0, max(0, min(5, msgList.length - 1)));
|
||||||
for (var msgItem in needPreViewList) {
|
for (var msgItem in needPreViewList) {
|
||||||
V2TimImage? getImageFromList(V2TimImageTypesEnum imgType) {
|
V2TimImage? getImageFromList(V2TimImageTypesEnum imgType) {
|
||||||
V2TimImage? img = MessageUtils.getImageFromImgList(msgItem.imageElem?.imageList, HistoryMessageDartConstant.imgPriorMap[imgType] ?? HistoryMessageDartConstant.oriImgPrior);
|
V2TimImage? img = MessageUtils.getImageFromImgList(msgItem.imageElem?.imageList,
|
||||||
|
HistoryMessageDartConstant.imgPriorMap[imgType] ?? HistoryMessageDartConstant.oriImgPrior);
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -487,7 +511,13 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
V2TimMsgCreateInfoResult? res = await _messageService.createCustomMessage(
|
V2TimMsgCreateInfoResult? res = await _messageService.createCustomMessage(
|
||||||
data: json.encode({"businessID": "user_typing_status", "typingStatus": isEditing == true ? 1 : 0, "userAction": 14, "version": 0, "actionParam": isEditing == true ? "EIMAMSG_InputStatus_Ing" : "EIMAMSG_InputStatus_End"}));
|
data: json.encode({
|
||||||
|
"businessID": "user_typing_status",
|
||||||
|
"typingStatus": isEditing == true ? 1 : 0,
|
||||||
|
"userAction": 14,
|
||||||
|
"version": 0,
|
||||||
|
"actionParam": isEditing == true ? "EIMAMSG_InputStatus_Ing" : "EIMAMSG_InputStatus_End"
|
||||||
|
}));
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
_sendMessage(
|
_sendMessage(
|
||||||
id: res.id!,
|
id: res.id!,
|
||||||
|
|
@ -524,11 +554,12 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
|
|
||||||
_onReceiveNewMsg(V2TimMessage msgComing) async {
|
_onReceiveNewMsg(V2TimMessage msgComing) async {
|
||||||
final convID = TencentUtils.checkString(msgComing.userID) ?? msgComing.groupID;
|
final convID = TencentUtils.checkString(msgComing.userID) ?? msgComing.groupID;
|
||||||
if(convID != currentSelectedConv){
|
if (convID != currentSelectedConv) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final V2TimMessage? newMsg = _lifeCycle?.newMessageWillMount != null ? await _lifeCycle?.newMessageWillMount(msgComing) : msgComing;
|
final V2TimMessage? newMsg =
|
||||||
|
_lifeCycle?.newMessageWillMount != null ? await _lifeCycle?.newMessageWillMount(msgComing) : msgComing;
|
||||||
if (newMsg == null) {
|
if (newMsg == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -583,27 +614,24 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
onMessageRevoked(String msgID, [String? convID]) {
|
onMessageRevoked(String msgID, [String? convID]) {
|
||||||
final activeMessageList = _messageListMap[convID ?? currentSelectedConv];
|
final activeMessageList = _messageListMap[convID ?? currentSelectedConv];
|
||||||
if (activeMessageList != null) {
|
if (activeMessageList != null) {
|
||||||
final findeIndex = activeMessageList.indexWhere((element) => element.msgID == msgID);
|
final findIndex = activeMessageList.indexWhere((element) => element.msgID == msgID);
|
||||||
if (findeIndex != -1) {
|
if (findIndex != -1) {
|
||||||
final findeIndex = activeMessageList.indexWhere((element) => element.msgID == msgID);
|
final targetItem = activeMessageList[findIndex];
|
||||||
if (findeIndex != -1) {
|
targetItem.status = MessageStatus.V2TIM_MSG_STATUS_LOCAL_REVOKED;
|
||||||
final targetItem = activeMessageList[findeIndex];
|
targetItem.id = DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
targetItem.status = MessageStatus.V2TIM_MSG_STATUS_LOCAL_REVOKED;
|
activeMessageList[findIndex] = targetItem;
|
||||||
targetItem.id = DateTime.now().millisecondsSinceEpoch.toString();
|
|
||||||
activeMessageList[findeIndex] = targetItem;
|
|
||||||
|
|
||||||
bool isUnreadMessage = _receivedUnreadMessageList.any((element) => element.msgID == msgID);
|
bool isUnreadMessage = _receivedUnreadMessageList.any((element) => element.msgID == msgID);
|
||||||
if (!(targetItem.isSelf ?? true) && isUnreadMessage) {
|
if (!(targetItem.isSelf ?? true) && isUnreadMessage) {
|
||||||
|
if (_unreadCountForTongue > 0) {
|
||||||
if (_unreadCountForTongue > 0) {
|
if (_unreadCountForTongue > 0) {
|
||||||
if (_unreadCountForTongue > 0) {
|
_unreadCountForTongue--;
|
||||||
_unreadCountForTongue--;
|
|
||||||
}
|
|
||||||
if (_receivedNewMessageCount > 0) {
|
|
||||||
_receivedNewMessageCount--;
|
|
||||||
}
|
|
||||||
|
|
||||||
_receivedUnreadMessageList.removeWhere((element) => element.msgID == targetItem.msgID);
|
|
||||||
}
|
}
|
||||||
|
if (_receivedNewMessageCount > 0) {
|
||||||
|
_receivedNewMessageCount--;
|
||||||
|
}
|
||||||
|
|
||||||
|
_receivedUnreadMessageList.removeWhere((element) => element.msgID == targetItem.msgID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -615,7 +643,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
|
|
||||||
onMessageModified(V2TimMessage modifiedMessage, [String? convID]) async {
|
onMessageModified(V2TimMessage modifiedMessage, [String? convID]) async {
|
||||||
modifiedMessage.id = DateTime.now().millisecondsSinceEpoch.toString();
|
modifiedMessage.id = DateTime.now().millisecondsSinceEpoch.toString();
|
||||||
final String? exactId = TencentUtils.checkString(modifiedMessage.userID) ?? TencentUtils.checkString(modifiedMessage.groupID);
|
final String? exactId =
|
||||||
|
TencentUtils.checkString(modifiedMessage.userID) ?? TencentUtils.checkString(modifiedMessage.groupID);
|
||||||
final activeMessageList = _messageListMap[convID ?? exactId];
|
final activeMessageList = _messageListMap[convID ?? exactId];
|
||||||
if (activeMessageList == null || activeMessageList.isEmpty) {
|
if (activeMessageList == null || activeMessageList.isEmpty) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -668,7 +697,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
|
|
||||||
Future<void> onMessageDownloadProgressCallback(V2TimMessageDownloadProgress messageProgress) async {
|
Future<void> onMessageDownloadProgressCallback(V2TimMessageDownloadProgress messageProgress) async {
|
||||||
final currentProgress = getMessageProgress(messageProgress.msgID);
|
final currentProgress = getMessageProgress(messageProgress.msgID);
|
||||||
print("onMessageDownloadProgressCallback, ${messageProgress.type} - ${messageProgress.isFinish} - ${messageProgress.currentSize} - $currentProgress - ");
|
print(
|
||||||
|
"onMessageDownloadProgressCallback, ${messageProgress.type} - ${messageProgress.isFinish} - ${messageProgress.currentSize} - $currentProgress - ");
|
||||||
|
|
||||||
if (messageProgress.isError || messageProgress.errorCode != 0) {
|
if (messageProgress.isError || messageProgress.errorCode != 0) {
|
||||||
V2TimMessage? message = await _findAndRetrieveMessage(messageProgress.msgID);
|
V2TimMessage? message = await _findAndRetrieveMessage(messageProgress.msgID);
|
||||||
|
|
@ -697,7 +727,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
const originalImageType = 0;
|
const originalImageType = 0;
|
||||||
if (!isImageType && !isVideoType) {
|
if (!isImageType && !isVideoType) {
|
||||||
_updateMessageLocationAndDownloadFile(messageProgress);
|
_updateMessageLocationAndDownloadFile(messageProgress);
|
||||||
} else if ((isImageType && messageProgress.type == originalImageType) || (isVideoType && !messageProgress.isSnapshot)) {
|
} else if ((isImageType && messageProgress.type == originalImageType) ||
|
||||||
|
(isVideoType && !messageProgress.isSnapshot)) {
|
||||||
Future.delayed(const Duration(seconds: 1), () => _updateMessageAndDownloadFile(message, messageProgress));
|
Future.delayed(const Duration(seconds: 1), () => _updateMessageAndDownloadFile(message, messageProgress));
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
|
@ -713,7 +744,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _updateMessageAndDownloadFile(V2TimMessage message, V2TimMessageDownloadProgress messageProgress) {
|
void _updateMessageAndDownloadFile(V2TimMessage message, V2TimMessageDownloadProgress messageProgress) {
|
||||||
updateAsyncMessage(message, TencentUtils.checkString(message.userID) ?? TencentUtils.checkString(message.groupID) ?? "");
|
updateAsyncMessage(
|
||||||
|
message, TencentUtils.checkString(message.userID) ?? TencentUtils.checkString(message.groupID) ?? "");
|
||||||
|
|
||||||
_updateMessageLocationAndDownloadFile(messageProgress);
|
_updateMessageLocationAndDownloadFile(messageProgress);
|
||||||
}
|
}
|
||||||
|
|
@ -771,7 +803,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
final TUIChatModelTools tools = serviceLocator<TUIChatModelTools>();
|
final TUIChatModelTools tools = serviceLocator<TUIChatModelTools>();
|
||||||
List<V2TimMessage> currentHistoryMsgList = _messageListMap[convID] ?? [];
|
List<V2TimMessage> currentHistoryMsgList = _messageListMap[convID] ?? [];
|
||||||
if (messageInfo != null) {
|
if (messageInfo != null) {
|
||||||
final messageInfoWithSender = messageInfo.sender == null ? tools.setUserInfoForMessage(messageInfo, messageInfo.id!) : messageInfo;
|
final messageInfoWithSender =
|
||||||
|
messageInfo.sender == null ? tools.setUserInfoForMessage(messageInfo, messageInfo.id!) : messageInfo;
|
||||||
messageInfoWithSender.status = MessageStatus.V2TIM_MSG_STATUS_SENDING;
|
messageInfoWithSender.status = MessageStatus.V2TIM_MSG_STATUS_SENDING;
|
||||||
currentHistoryMsgList = [messageInfoWithSender, ...currentHistoryMsgList];
|
currentHistoryMsgList = [messageInfoWithSender, ...currentHistoryMsgList];
|
||||||
setMessageList(convID, currentHistoryMsgList);
|
setMessageList(convID, currentHistoryMsgList);
|
||||||
|
|
@ -792,7 +825,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
setInputField: setInputField,
|
setInputField: setInputField,
|
||||||
id: messageInfo.id as String,
|
id: messageInfo.id as String,
|
||||||
convType: ConvType.values[convType.index],
|
convType: ConvType.values[convType.index],
|
||||||
offlinePushInfo: offlinePushInfo ?? tools.buildMessagePushInfo(messageInfo, convID, ConvType.values[convType.index]),
|
offlinePushInfo:
|
||||||
|
offlinePushInfo ?? tools.buildMessagePushInfo(messageInfo, convID, ConvType.values[convType.index]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -819,13 +853,20 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
V2TimMsgCreateInfoResult? textMessageInfo = await _messageService.createTextMessage(text: text);
|
V2TimMsgCreateInfoResult? textMessageInfo = await _messageService.createTextMessage(text: text);
|
||||||
|
|
||||||
textMessageInfo = await _messageService.createTextAtMessage(
|
textMessageInfo = await _messageService.createTextAtMessage(
|
||||||
text: text + "\n@${TencentUtils.checkString(messageBeenReplied.nickName) ?? TencentUtils.checkString(messageBeenReplied.sender) ?? TencentUtils.checkString(messageBeenReplied.userID)}",
|
text: text +
|
||||||
atUserList: [TencentUtils.checkString(messageBeenReplied.sender) ?? TencentUtils.checkString(messageBeenReplied.userID) ?? ""]);
|
"\n@${TencentUtils.checkString(messageBeenReplied.nickName) ?? TencentUtils.checkString(messageBeenReplied.sender) ?? TencentUtils.checkString(messageBeenReplied.userID)}",
|
||||||
|
atUserList: [
|
||||||
|
TencentUtils.checkString(messageBeenReplied.sender) ??
|
||||||
|
TencentUtils.checkString(messageBeenReplied.userID) ??
|
||||||
|
""
|
||||||
|
]);
|
||||||
|
|
||||||
final V2TimMessage? messageInfo = textMessageInfo!.messageInfo;
|
final V2TimMessage? messageInfo = textMessageInfo!.messageInfo;
|
||||||
|
|
||||||
if (messageInfo != null) {
|
if (messageInfo != null) {
|
||||||
final messageInfoWithSender = messageInfo.sender == null ? tools.setUserInfoForMessage(messageInfo, messageInfo.id ?? textMessageInfo.id ?? "") : messageInfo;
|
final messageInfoWithSender = messageInfo.sender == null
|
||||||
|
? tools.setUserInfoForMessage(messageInfo, messageInfo.id ?? textMessageInfo.id ?? "")
|
||||||
|
: messageInfo;
|
||||||
messageInfoWithSender.status = MessageStatus.V2TIM_MSG_STATUS_SENDING;
|
messageInfoWithSender.status = MessageStatus.V2TIM_MSG_STATUS_SENDING;
|
||||||
final hasNickName = messageBeenReplied.nickName != null && messageBeenReplied.nickName != "";
|
final hasNickName = messageBeenReplied.nickName != null && messageBeenReplied.nickName != "";
|
||||||
final cloudCustomData = {
|
final cloudCustomData = {
|
||||||
|
|
@ -845,7 +886,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
return _sendMessage(
|
return _sendMessage(
|
||||||
cloudCustomData: json.encode(cloudCustomData),
|
cloudCustomData: json.encode(cloudCustomData),
|
||||||
id: textMessageInfo.id as String,
|
id: textMessageInfo.id as String,
|
||||||
offlinePushInfo: offlinePushInfo ?? tools.buildMessagePushInfo(messageInfo, convID, ConvType.values[convType.index]),
|
offlinePushInfo:
|
||||||
|
offlinePushInfo ?? tools.buildMessagePushInfo(messageInfo, convID, ConvType.values[convType.index]),
|
||||||
priority: priority,
|
priority: priority,
|
||||||
onlineUserOnly: onlineUserOnly,
|
onlineUserOnly: onlineUserOnly,
|
||||||
isExcludedFromUnreadCount: isExcludedFromUnreadCount,
|
isExcludedFromUnreadCount: isExcludedFromUnreadCount,
|
||||||
|
|
@ -939,7 +981,8 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
return sendMsgRes;
|
return sendMsgRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMessageList(String conversationID, List<V2TimMessage> messageList, {bool needResetNewMessageCount = true, bool isDeleteMsg = false}) {
|
void setMessageList(String conversationID, List<V2TimMessage> messageList,
|
||||||
|
{bool needResetNewMessageCount = true, bool isDeleteMsg = false}) {
|
||||||
_messageListMap[conversationID] = messageList;
|
_messageListMap[conversationID] = messageList;
|
||||||
if (needResetNewMessageCount) {
|
if (needResetNewMessageCount) {
|
||||||
_receivedNewMessageCount = 0;
|
_receivedNewMessageCount = 0;
|
||||||
|
|
@ -955,11 +998,14 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMessage(V2TimValueCallback<V2TimMessage> sendMsgRes, String convID, String id, ConvType convType, GroupReceiptAllowType? groupType, ValueChanged<String>? setInputField) {
|
updateMessage(V2TimValueCallback<V2TimMessage> sendMsgRes, String convID, String id, ConvType convType,
|
||||||
|
GroupReceiptAllowType? groupType, ValueChanged<String>? setInputField) {
|
||||||
List<V2TimMessage> currentHistoryMsgList = _messageListMap[convID] ?? [];
|
List<V2TimMessage> currentHistoryMsgList = _messageListMap[convID] ?? [];
|
||||||
final V2TimMessage sendMsgResData = sendMsgRes.data as V2TimMessage;
|
final V2TimMessage sendMsgResData = sendMsgRes.data as V2TimMessage;
|
||||||
final findIdIndex = currentHistoryMsgList.indexWhere((element) => element.id == id);
|
final findIdIndex = currentHistoryMsgList.indexWhere((element) => element.id == id);
|
||||||
final targetIndex = findIdIndex == -1 ? currentHistoryMsgList.indexWhere((element) => element.msgID == sendMsgResData.msgID) : findIdIndex;
|
final targetIndex = findIdIndex == -1
|
||||||
|
? currentHistoryMsgList.indexWhere((element) => element.msgID == sendMsgResData.msgID)
|
||||||
|
: findIdIndex;
|
||||||
if (targetIndex != -1) {
|
if (targetIndex != -1) {
|
||||||
currentHistoryMsgList[targetIndex] = sendMsgResData;
|
currentHistoryMsgList[targetIndex] = sendMsgResData;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -998,13 +1044,18 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<V2TimMessage>? getMessageList(String conversationID) {
|
List<V2TimMessage>? getMessageList(String conversationID) {
|
||||||
final list = (messageListMap[conversationID]?.reversed.toList() ?? []).where((element) => _lifeCycle?.messageShouldMount(element) ?? true).toList();
|
final list = (messageListMap[conversationID]?.reversed.toList() ?? [])
|
||||||
|
.where((element) => _lifeCycle?.messageShouldMount(element) ?? true)
|
||||||
|
.toList();
|
||||||
final finalList = _lifeCycle?.messageListShouldMount(list) ?? list;
|
final finalList = _lifeCycle?.messageListShouldMount(list) ?? list;
|
||||||
final List<V2TimMessage> listWithTimestamp = [];
|
final List<V2TimMessage> listWithTimestamp = [];
|
||||||
final interval = chatConfig.timeDividerConfig?.timeInterval ?? 300;
|
final interval = chatConfig.timeDividerConfig?.timeInterval ?? 300;
|
||||||
for (var item in finalList) {
|
for (var item in finalList) {
|
||||||
{
|
{
|
||||||
if (listWithTimestamp.isEmpty || (listWithTimestamp[listWithTimestamp.length - 1].timestamp != null && item.timestamp != null && (item.timestamp! - listWithTimestamp[listWithTimestamp.length - 1].timestamp! > interval))) {
|
if (listWithTimestamp.isEmpty ||
|
||||||
|
(listWithTimestamp[listWithTimestamp.length - 1].timestamp != null &&
|
||||||
|
item.timestamp != null &&
|
||||||
|
(item.timestamp! - listWithTimestamp[listWithTimestamp.length - 1].timestamp! > interval))) {
|
||||||
listWithTimestamp.add(V2TimMessage(
|
listWithTimestamp.add(V2TimMessage(
|
||||||
userID: '',
|
userID: '',
|
||||||
isSelf: false,
|
isSelf: false,
|
||||||
|
|
@ -1013,7 +1064,7 @@ class TUIChatGlobalModel extends ChangeNotifier implements TIMUIKitClass {
|
||||||
timestamp: item.timestamp,
|
timestamp: item.timestamp,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
listWithTimestamp.add(V2TimMessage.fromJson(item.toJson()));
|
listWithTimestamp.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return listWithTimestamp.reversed.toList();
|
return listWithTimestamp.reversed.toList();
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,12 @@
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/V2TimConversationListener.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/V2TimConversationListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_search_param.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_search_param.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/conversation_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/conversation_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
||||||
|
|
@ -135,7 +138,7 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
if (!PlatformUtils().isWeb) {
|
if (!PlatformUtils().isWeb) {
|
||||||
loadInitConversation();
|
loadInitConversation();
|
||||||
}
|
}
|
||||||
}, onConversationDeleted:(List<String> conversationIDList) {
|
}, onConversationDeleted: (List<String> conversationIDList) {
|
||||||
_onConversationDeleted(conversationIDList);
|
_onConversationDeleted(conversationIDList);
|
||||||
for (var conversationID in conversationIDList) {
|
for (var conversationID in conversationIDList) {
|
||||||
String resultID = "";
|
String resultID = "";
|
||||||
|
|
@ -181,8 +184,10 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
} else {
|
} else {
|
||||||
combinedConversationList = [..._conversationList, ...conversationList];
|
combinedConversationList = [..._conversationList, ...conversationList];
|
||||||
}
|
}
|
||||||
final List<V2TimConversation?> finalConversationList = await _lifeCycle?.conversationListWillMount(combinedConversationList) ?? combinedConversationList;
|
final List<V2TimConversation?> finalConversationList =
|
||||||
_conversationList = removeDuplicates<V2TimConversation?>(finalConversationList, (item1, item2) => item1?.conversationID == item2?.conversationID);
|
await _lifeCycle?.conversationListWillMount(combinedConversationList) ?? combinedConversationList;
|
||||||
|
_conversationList = removeDuplicates<V2TimConversation?>(
|
||||||
|
finalConversationList, (item1, item2) => item1?.conversationID == item2?.conversationID);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
_totalUnReadCount = await _conversationService.getTotalUnreadCount();
|
_totalUnReadCount = await _conversationService.getTotalUnreadCount();
|
||||||
|
|
@ -203,7 +208,8 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimCallback?> clearHistoryMessage({required String convID, required int convType}) async {
|
Future<V2TimCallback?> clearHistoryMessage({required String convID, required int convType}) async {
|
||||||
if (_lifeCycle?.shouldClearHistoricalMessageForConversation != null && await _lifeCycle!.shouldClearHistoricalMessageForConversation(convID) == false) {
|
if (_lifeCycle?.shouldClearHistoricalMessageForConversation != null &&
|
||||||
|
await _lifeCycle!.shouldClearHistoricalMessageForConversation(convID) == false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -222,7 +228,8 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimCallback?> deleteConversation({required String conversationID}) async {
|
Future<V2TimCallback?> deleteConversation({required String conversationID}) async {
|
||||||
if (_lifeCycle?.shouldDeleteConversation != null && await _lifeCycle!.shouldDeleteConversation(conversationID) == false) {
|
if (_lifeCycle?.shouldDeleteConversation != null &&
|
||||||
|
await _lifeCycle!.shouldDeleteConversation(conversationID) == false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final res = await _conversationService.deleteConversation(conversationID: conversationID);
|
final res = await _conversationService.deleteConversation(conversationID: conversationID);
|
||||||
|
|
@ -251,7 +258,8 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
int index = _conversationList.indexWhere((item) => item!.conversationID == list[i]);
|
int index = _conversationList.indexWhere((item) => item!.conversationID == list[i]);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
_conversationList.removeAt(index);
|
_conversationList.removeAt(index);
|
||||||
_conversationList = removeDuplicates<V2TimConversation?>(_conversationList, (item1, item2) => item1?.conversationID == item2?.conversationID);
|
_conversationList = removeDuplicates<V2TimConversation?>(
|
||||||
|
_conversationList, (item1, item2) => item1?.conversationID == item2?.conversationID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
@ -259,7 +267,8 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
|
|
||||||
_addNewConversation(List<V2TimConversation> list) {
|
_addNewConversation(List<V2TimConversation> list) {
|
||||||
_conversationList.addAll(list);
|
_conversationList.addAll(list);
|
||||||
_conversationList = removeDuplicates<V2TimConversation?>(_conversationList, (item1, item2) => item1?.conversationID == item2?.conversationID);
|
_conversationList = removeDuplicates<V2TimConversation?>(
|
||||||
|
_conversationList, (item1, item2) => item1?.conversationID == item2?.conversationID);
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -278,13 +287,16 @@ class TUIConversationViewModel extends ChangeNotifier {
|
||||||
String? groupID,
|
String? groupID,
|
||||||
bool isAllowWeb = true,
|
bool isAllowWeb = true,
|
||||||
}) async {
|
}) async {
|
||||||
assert(!isTopic || (groupID != null && groupID.isNotEmpty), "When 'isTopic' is true, 'groupID' must not be null or empty.");
|
assert(!isTopic || (groupID != null && groupID.isNotEmpty),
|
||||||
|
"When 'isTopic' is true, 'groupID' must not be null or empty.");
|
||||||
if (PlatformUtils().isWeb && isAllowWeb) {
|
if (PlatformUtils().isWeb && isAllowWeb) {
|
||||||
webDraftMap[conversationID] = draftText ?? "";
|
webDraftMap[conversationID] = draftText ?? "";
|
||||||
return V2TimCallback(code: 0, desc: "");
|
return V2TimCallback(code: 0, desc: "");
|
||||||
} else {
|
} else {
|
||||||
if (isTopic) {
|
if (isTopic) {
|
||||||
final topicInfoList = await TencentImSDKPlugin.v2TIMManager.getGroupManager().getTopicInfoList(groupID: groupID!, topicIDList: [conversationID]);
|
final topicInfoList = await TencentImSDKPlugin.v2TIMManager
|
||||||
|
.getGroupManager()
|
||||||
|
.getTopicInfoList(groupID: groupID!, topicIDList: [conversationID]);
|
||||||
final topicInfo = topicInfoList.data?.first.topicInfo;
|
final topicInfo = topicInfoList.data?.first.topicInfo;
|
||||||
topicInfo?.draftText = draftText;
|
topicInfo?.draftText = draftText;
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager.getGroupManager().setTopicInfo(topicInfo: topicInfo!);
|
final res = await TencentImSDKPlugin.v2TIMManager.getGroupManager().setTopicInfo(topicInfo: topicInfo!);
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,18 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/V2TimFriendshipListener.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/V2TimFriendshipListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_application_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_application_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_response_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_response_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_application.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_application.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_application.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_operation_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_status.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/block_list_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/block_list_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/friend_list_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/friend_list_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/new_contact_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/new_contact_life_cycle.dart';
|
||||||
|
|
@ -19,11 +25,9 @@ import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
||||||
|
|
||||||
class TUIFriendShipViewModel extends ChangeNotifier {
|
class TUIFriendShipViewModel extends ChangeNotifier {
|
||||||
final FriendshipServices _friendshipServices =
|
final FriendshipServices _friendshipServices = serviceLocator<FriendshipServices>();
|
||||||
serviceLocator<FriendshipServices>();
|
|
||||||
final GroupServices _groupServices = serviceLocator<GroupServices>();
|
final GroupServices _groupServices = serviceLocator<GroupServices>();
|
||||||
final TUISelfInfoViewModel selfInfoViewModel =
|
final TUISelfInfoViewModel selfInfoViewModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
late V2TimFriendshipListener friendShipListener;
|
late V2TimFriendshipListener friendShipListener;
|
||||||
List<V2TimFriendApplication?>? _friendApplicationList;
|
List<V2TimFriendApplication?>? _friendApplicationList;
|
||||||
List<V2TimFriendInfo>? _friendList;
|
List<V2TimFriendInfo>? _friendList;
|
||||||
|
|
@ -68,8 +72,7 @@ class TUIFriendShipViewModel extends ChangeNotifier {
|
||||||
|
|
||||||
int get friendApplicationAmount => _friendApplicationAmount;
|
int get friendApplicationAmount => _friendApplicationAmount;
|
||||||
|
|
||||||
List<V2TimFriendApplication?>? get friendApplicationList =>
|
List<V2TimFriendApplication?>? get friendApplicationList => _friendApplicationList;
|
||||||
_friendApplicationList;
|
|
||||||
|
|
||||||
TUIFriendShipViewModel() {
|
TUIFriendShipViewModel() {
|
||||||
friendShipListener = V2TimFriendshipListener(
|
friendShipListener = V2TimFriendshipListener(
|
||||||
|
|
@ -125,21 +128,17 @@ class TUIFriendShipViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadUserStatus() async {
|
loadUserStatus() async {
|
||||||
if (selfInfoViewModel.globalConfig?.isShowOnlineStatus == false ||
|
if (selfInfoViewModel.globalConfig?.isShowOnlineStatus == false || friendList == null || friendList!.isEmpty) {
|
||||||
friendList == null ||
|
|
||||||
friendList!.isEmpty) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<List<String>> userIDSet = [];
|
final List<List<String>> userIDSet = [];
|
||||||
final int needHowManyRequest = ((friendList!.length) / 500).ceil();
|
final int needHowManyRequest = ((friendList!.length) / 500).ceil();
|
||||||
final int amountEachRequest =
|
final int amountEachRequest = ((friendList!.length) / needHowManyRequest).ceil();
|
||||||
((friendList!.length) / needHowManyRequest).ceil();
|
|
||||||
|
|
||||||
for (int i = 0; i < needHowManyRequest; i++) {
|
for (int i = 0; i < needHowManyRequest; i++) {
|
||||||
userIDSet.add(friendList!
|
userIDSet.add(friendList!
|
||||||
.getRange(i * amountEachRequest,
|
.getRange(i * amountEachRequest, min(friendList!.length, (i + 1) * amountEachRequest))
|
||||||
min(friendList!.length, (i + 1) * amountEachRequest))
|
|
||||||
.map((e) => e.userID)
|
.map((e) => e.userID)
|
||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
|
|
@ -161,19 +160,15 @@ class TUIFriendShipViewModel extends ChangeNotifier {
|
||||||
final newContactRes = await _friendshipServices.getFriendApplicationList();
|
final newContactRes = await _friendshipServices.getFriendApplicationList();
|
||||||
// Only Received Application
|
// Only Received Application
|
||||||
_friendApplicationList = newContactRes?.friendApplicationList
|
_friendApplicationList = newContactRes?.friendApplicationList
|
||||||
?.where((item) =>
|
?.where((item) => item!.type == FriendApplicationTypeEnum.V2TIM_FRIEND_APPLICATION_COME_IN.index)
|
||||||
item!.type ==
|
|
||||||
FriendApplicationTypeEnum.V2TIM_FRIEND_APPLICATION_COME_IN.index)
|
|
||||||
.toList();
|
.toList();
|
||||||
_friendApplicationAmount = _friendApplicationList?.length ?? 0;
|
_friendApplicationAmount = _friendApplicationList?.length ?? 0;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> loadContactListData() async {
|
Future<void> loadContactListData() async {
|
||||||
final List<V2TimFriendInfo> res =
|
final List<V2TimFriendInfo> res = await _friendshipServices.getFriendList() ?? [];
|
||||||
await _friendshipServices.getFriendList() ?? [];
|
final memberList = await _contactListLifeCycle?.friendListWillMount(res) ?? res;
|
||||||
final memberList =
|
|
||||||
await _contactListLifeCycle?.friendListWillMount(res) ?? res;
|
|
||||||
_friendList = memberList;
|
_friendList = memberList;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return;
|
return;
|
||||||
|
|
@ -206,15 +201,12 @@ class TUIFriendShipViewModel extends ChangeNotifier {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<V2TimFriendOperationResult>?> deleteFromBlockList(
|
Future<List<V2TimFriendOperationResult>?> deleteFromBlockList(List<String> userIDList) async {
|
||||||
List<String> userIDList) async {
|
|
||||||
if (_blockListLifeCycle?.shouldDeleteFromBlockList != null &&
|
if (_blockListLifeCycle?.shouldDeleteFromBlockList != null &&
|
||||||
await _blockListLifeCycle!.shouldDeleteFromBlockList(userIDList) ==
|
await _blockListLifeCycle!.shouldDeleteFromBlockList(userIDList) == false) {
|
||||||
false) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final res =
|
final res = await _friendshipServices.deleteFromBlackList(userIDList: userIDList);
|
||||||
await _friendshipServices.deleteFromBlackList(userIDList: userIDList);
|
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -226,8 +218,7 @@ class TUIFriendShipViewModel extends ChangeNotifier {
|
||||||
int type,
|
int type,
|
||||||
) async {
|
) async {
|
||||||
if (_newContactLifeCycle?.shouldAcceptContactApplication != null &&
|
if (_newContactLifeCycle?.shouldAcceptContactApplication != null &&
|
||||||
await _newContactLifeCycle!.shouldAcceptContactApplication(userID) ==
|
await _newContactLifeCycle!.shouldAcceptContactApplication(userID) == false) {
|
||||||
false) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final res = await _friendshipServices.acceptFriendApplication(
|
final res = await _friendshipServices.acceptFriendApplication(
|
||||||
|
|
@ -246,8 +237,7 @@ class TUIFriendShipViewModel extends ChangeNotifier {
|
||||||
int type,
|
int type,
|
||||||
) async {
|
) async {
|
||||||
if (_newContactLifeCycle?.shouldRefuseContactApplication != null &&
|
if (_newContactLifeCycle?.shouldRefuseContactApplication != null &&
|
||||||
await _newContactLifeCycle!.shouldRefuseContactApplication(userID) ==
|
await _newContactLifeCycle!.shouldRefuseContactApplication(userID) == false) {
|
||||||
false) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final res = await _friendshipServices.refuseFriendApplication(
|
final res = await _friendshipServices.refuseFriendApplication(
|
||||||
|
|
@ -262,8 +252,7 @@ class TUIFriendShipViewModel extends ChangeNotifier {
|
||||||
|
|
||||||
Future<List<V2TimGroupMemberFullInfo?>> getGroupMembersInfo(
|
Future<List<V2TimGroupMemberFullInfo?>> getGroupMembersInfo(
|
||||||
{required String groupID, required List<String> memberList}) async {
|
{required String groupID, required List<String> memberList}) async {
|
||||||
final res = await _groupServices.getGroupMembersInfo(
|
final res = await _groupServices.getGroupMembersInfo(groupID: groupID, memberList: memberList);
|
||||||
groupID: groupID, memberList: memberList);
|
|
||||||
return res.data ?? [];
|
return res.data ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,31 +2,34 @@
|
||||||
|
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_search_param.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_search_param.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_search_param.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_search_param.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_param.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result_item.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result_item.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_search_result_item.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/friendShip/friendship_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/friendShip/friendship_services.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/message/message_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/message/message_services.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/conversation/conversation_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/conversation/conversation_services.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart';
|
||||||
|
|
||||||
enum KeywordListMatchType {
|
enum KeywordListMatchType { V2TIM_KEYWORD_LIST_MATCH_TYPE_OR, V2TIM_KEYWORD_LIST_MATCH_TYPE_AND }
|
||||||
V2TIM_KEYWORD_LIST_MATCH_TYPE_OR,
|
|
||||||
V2TIM_KEYWORD_LIST_MATCH_TYPE_AND
|
|
||||||
}
|
|
||||||
|
|
||||||
class TUISearchViewModel extends ChangeNotifier {
|
class TUISearchViewModel extends ChangeNotifier {
|
||||||
final FriendshipServices _friendshipServices =
|
final FriendshipServices _friendshipServices = serviceLocator<FriendshipServices>();
|
||||||
serviceLocator<FriendshipServices>();
|
|
||||||
final MessageService _messageService = serviceLocator<MessageService>();
|
final MessageService _messageService = serviceLocator<MessageService>();
|
||||||
final ConversationService _conversationService =
|
final ConversationService _conversationService = serviceLocator<ConversationService>();
|
||||||
serviceLocator<ConversationService>();
|
|
||||||
final GroupServices _groupServices = serviceLocator<GroupServices>();
|
final GroupServices _groupServices = serviceLocator<GroupServices>();
|
||||||
|
|
||||||
List<V2TimFriendInfoResult>? friendList = [];
|
List<V2TimFriendInfoResult>? friendList = [];
|
||||||
|
|
@ -43,8 +46,7 @@ class TUISearchViewModel extends ChangeNotifier {
|
||||||
List<V2TimConversation?> conversationList = [];
|
List<V2TimConversation?> conversationList = [];
|
||||||
|
|
||||||
Future<List<V2TimConversation?>?> initConversationMsg() async {
|
Future<List<V2TimConversation?>?> initConversationMsg() async {
|
||||||
final conversationResult = await _conversationService.getConversationList(
|
final conversationResult = await _conversationService.getConversationList(nextSeq: "0", count: 500);
|
||||||
nextSeq: "0", count: 500);
|
|
||||||
final conversationListData = conversationResult?.conversationList;
|
final conversationListData = conversationResult?.conversationList;
|
||||||
conversationList = conversationListData ?? [];
|
conversationList = conversationListData ?? [];
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
@ -60,21 +62,20 @@ class TUISearchViewModel extends ChangeNotifier {
|
||||||
}
|
}
|
||||||
|
|
||||||
void searchFriendByKey(String searchKey) async {
|
void searchFriendByKey(String searchKey) async {
|
||||||
final searchResult = await _friendshipServices.searchFriends(
|
final searchResult =
|
||||||
searchParam: V2TimFriendSearchParam(keywordList: [searchKey]));
|
await _friendshipServices.searchFriends(searchParam: V2TimFriendSearchParam(keywordList: [searchKey]));
|
||||||
friendList = searchResult;
|
friendList = searchResult;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void searchGroupByKey(String searchKey) async {
|
void searchGroupByKey(String searchKey) async {
|
||||||
final searchResult = await _groupServices.searchGroups(
|
final searchResult =
|
||||||
searchParam: V2TimGroupSearchParam(keywordList: [searchKey]));
|
await _groupServices.searchGroups(searchParam: V2TimGroupSearchParam(keywordList: [searchKey]));
|
||||||
groupList = searchResult.data ?? [];
|
groupList = searchResult.data ?? [];
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
void getMsgForConversation(
|
void getMsgForConversation(String keyword, String conversationId, int page) async {
|
||||||
String keyword, String conversationId, int page) async {
|
|
||||||
void clearData() {
|
void clearData() {
|
||||||
currentMsgListForConversation = [];
|
currentMsgListForConversation = [];
|
||||||
totalMsgInConversationCount = 0;
|
totalMsgInConversationCount = 0;
|
||||||
|
|
@ -98,8 +99,7 @@ class TUISearchViewModel extends ChangeNotifier {
|
||||||
type: KeywordListMatchType.V2TIM_KEYWORD_LIST_MATCH_TYPE_OR.index,
|
type: KeywordListMatchType.V2TIM_KEYWORD_LIST_MATCH_TYPE_OR.index,
|
||||||
));
|
));
|
||||||
if (searchResult.code == 0 && searchResult.data != null) {
|
if (searchResult.code == 0 && searchResult.data != null) {
|
||||||
final messageSearchResultItems = searchResult
|
final messageSearchResultItems = searchResult.data!.messageSearchResultItems!
|
||||||
.data!.messageSearchResultItems!
|
|
||||||
.firstWhereOrNull((element) => element.conversationID == conversationId);
|
.firstWhereOrNull((element) => element.conversationID == conversationId);
|
||||||
totalMsgInConversationCount = messageSearchResultItems?.messageCount ?? 0;
|
totalMsgInConversationCount = messageSearchResultItems?.messageCount ?? 0;
|
||||||
currentMsgListForConversation = [
|
currentMsgListForConversation = [
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_config.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_config.dart';
|
||||||
|
|
||||||
class TUISelfInfoViewModel extends ChangeNotifier {
|
class TUISelfInfoViewModel extends ChangeNotifier {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/V2TimConversationListener.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/V2TimConversationListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation_result.dart';
|
||||||
|
|
||||||
abstract class ConversationService {
|
abstract class ConversationService {
|
||||||
Future<V2TimConversationResult?> getConversationList({
|
Future<V2TimConversationResult?> getConversationList({
|
||||||
|
|
@ -26,14 +29,11 @@ abstract class ConversationService {
|
||||||
required V2TimConversationListener listener,
|
required V2TimConversationListener listener,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimCallback> setConversationDraft(
|
Future<V2TimCallback> setConversationDraft({required String conversationID, String? draftText});
|
||||||
{required String conversationID, String? draftText});
|
|
||||||
|
|
||||||
Future<void> removeConversationListener(
|
Future<void> removeConversationListener({V2TimConversationListener? listener});
|
||||||
{V2TimConversationListener? listener});
|
|
||||||
|
|
||||||
Future<int> getTotalUnreadCount();
|
Future<int> getTotalUnreadCount();
|
||||||
|
|
||||||
Future<V2TimConversation?> getConversationListByConversationId(
|
Future<V2TimConversation?> getConversationListByConversationId({required String convID});
|
||||||
{required String convID});
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/V2TimConversationListener.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/V2TimConversationListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/conversation/conversation_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/conversation/conversation_services.dart';
|
||||||
|
|
@ -22,10 +25,8 @@ class ConversationServicesImpl extends ConversationService {
|
||||||
if (result.code == 0) {
|
if (result.code == 0) {
|
||||||
return result.data;
|
return result.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -39,10 +40,8 @@ class ConversationServicesImpl extends ConversationService {
|
||||||
.getConversationManager()
|
.getConversationManager()
|
||||||
.pinConversation(conversationID: conversationID, isPinned: isPinned);
|
.pinConversation(conversationID: conversationID, isPinned: isPinned);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -55,10 +54,8 @@ class ConversationServicesImpl extends ConversationService {
|
||||||
.getConversationManager()
|
.getConversationManager()
|
||||||
.deleteConversation(conversationID: conversationID);
|
.deleteConversation(conversationID: conversationID);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -67,82 +64,60 @@ class ConversationServicesImpl extends ConversationService {
|
||||||
Future<void> addConversationListener({
|
Future<void> addConversationListener({
|
||||||
required V2TimConversationListener listener,
|
required V2TimConversationListener listener,
|
||||||
}) {
|
}) {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getConversationManager().addConversationListener(listener: listener);
|
||||||
.getConversationManager()
|
|
||||||
.addConversationListener(listener: listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimConversation?> getConversation({
|
Future<V2TimConversation?> getConversation({
|
||||||
required String conversationID,
|
required String conversationID,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res =
|
||||||
.getConversationManager()
|
await TencentImSDKPlugin.v2TIMManager.getConversationManager().getConversation(conversationID: conversationID);
|
||||||
.getConversation(conversationID: conversationID);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimCallback> setConversationDraft(
|
Future<V2TimCallback> setConversationDraft({required String conversationID, String? draftText}) async {
|
||||||
{required String conversationID, String? draftText}) async {
|
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getConversationManager()
|
.getConversationManager()
|
||||||
.setConversationDraft(
|
.setConversationDraft(conversationID: conversationID, draftText: draftText);
|
||||||
conversationID: conversationID, draftText: draftText);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> removeConversationListener(
|
Future<void> removeConversationListener({V2TimConversationListener? listener}) {
|
||||||
{V2TimConversationListener? listener}) {
|
return TencentImSDKPlugin.v2TIMManager.getConversationManager().removeConversationListener(listener: listener);
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
|
||||||
.getConversationManager()
|
|
||||||
.removeConversationListener(listener: listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimConversation?> getConversationListByConversationId(
|
Future<V2TimConversation?> getConversationListByConversationId({required String convID}) async {
|
||||||
{required String convID}) async {
|
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getConversationManager()
|
.getConversationManager()
|
||||||
.getConversationListByConversationIds(conversationIDList: [convID]);
|
.getConversationListByConversationIds(conversationIDList: [convID]);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return (result.data != null && result.data!.isNotEmpty)
|
return (result.data != null && result.data!.isNotEmpty) ? result.data![0] : null;
|
||||||
? result.data![0]
|
|
||||||
: null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<int> getTotalUnreadCount() async {
|
Future<int> getTotalUnreadCount() async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getConversationManager().getTotalUnreadMessageCount();
|
||||||
.getConversationManager()
|
|
||||||
.getTotalUnreadMessageCount();
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data ?? 0;
|
return res.data ?? 0;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/V2TimSDKListener.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/V2TimSDKListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/log_level_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/log_level_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_config.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_config.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
||||||
|
|
||||||
|
|
||||||
enum AppStatus { foreground, background }
|
enum AppStatus { foreground, background }
|
||||||
|
|
||||||
enum LanguageEnum {
|
enum LanguageEnum {
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,14 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tools/i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tools/i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/V2TimSDKListener.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/V2TimSDKListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/log_level_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/log_level_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_status.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_setting_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_setting_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
||||||
|
|
@ -38,8 +42,7 @@ class LoginInfo {
|
||||||
final int sdkAppID;
|
final int sdkAppID;
|
||||||
final V2TimUserFullInfo? loginUser;
|
final V2TimUserFullInfo? loginUser;
|
||||||
|
|
||||||
LoginInfo(
|
LoginInfo({this.sdkAppID = 0, this.userSig = "", this.userID = "", this.loginUser});
|
||||||
{this.sdkAppID = 0, this.userSig = "", this.userID = "", this.loginUser});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CoreServicesImpl implements CoreServices {
|
class CoreServicesImpl implements CoreServices {
|
||||||
|
|
@ -56,11 +59,7 @@ class CoreServicesImpl implements CoreServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginInfo get loginInfo {
|
LoginInfo get loginInfo {
|
||||||
return LoginInfo(
|
return LoginInfo(sdkAppID: _sdkAppID, userID: _userID, userSig: _userSig, loginUser: _loginInfo);
|
||||||
sdkAppID: _sdkAppID,
|
|
||||||
userID: _userID,
|
|
||||||
userSig: _userSig,
|
|
||||||
loginUser: _loginInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EmptyAvatarBuilder? _emptyAvatarBuilder;
|
EmptyAvatarBuilder? _emptyAvatarBuilder;
|
||||||
|
|
@ -74,8 +73,7 @@ class CoreServicesImpl implements CoreServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
setGlobalConfig(TIMUIKitConfig? config) {
|
setGlobalConfig(TIMUIKitConfig? config) {
|
||||||
final TUISelfInfoViewModel selfInfoViewModel =
|
final TUISelfInfoViewModel selfInfoViewModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
final TUISettingModel settingModel = serviceLocator<TUISettingModel>();
|
final TUISettingModel settingModel = serviceLocator<TUISettingModel>();
|
||||||
selfInfoViewModel.globalConfig = config;
|
selfInfoViewModel.globalConfig = config;
|
||||||
settingModel.init();
|
settingModel.init();
|
||||||
|
|
@ -185,14 +183,10 @@ class CoreServicesImpl implements CoreServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
void addInitListener() {
|
void addInitListener() {
|
||||||
final TUIFriendShipViewModel tuiFriendShipViewModel =
|
final TUIFriendShipViewModel tuiFriendShipViewModel = serviceLocator<TUIFriendShipViewModel>();
|
||||||
serviceLocator<TUIFriendShipViewModel>();
|
final TUIConversationViewModel tuiConversationViewModel = serviceLocator<TUIConversationViewModel>();
|
||||||
final TUIConversationViewModel tuiConversationViewModel =
|
final TUIChatGlobalModel tuiChatViewModel = serviceLocator<TUIChatGlobalModel>();
|
||||||
serviceLocator<TUIConversationViewModel>();
|
final TUIGroupListenerModel tuiGroupListenerModel = serviceLocator<TUIGroupListenerModel>();
|
||||||
final TUIChatGlobalModel tuiChatViewModel =
|
|
||||||
serviceLocator<TUIChatGlobalModel>();
|
|
||||||
final TUIGroupListenerModel tuiGroupListenerModel =
|
|
||||||
serviceLocator<TUIGroupListenerModel>();
|
|
||||||
|
|
||||||
tuiFriendShipViewModel.addFriendListener();
|
tuiFriendShipViewModel.addFriendListener();
|
||||||
tuiConversationViewModel.setConversationListener();
|
tuiConversationViewModel.setConversationListener();
|
||||||
|
|
@ -201,14 +195,10 @@ class CoreServicesImpl implements CoreServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeListener() {
|
void removeListener() {
|
||||||
final TUIFriendShipViewModel tuiFriendShipViewModel =
|
final TUIFriendShipViewModel tuiFriendShipViewModel = serviceLocator<TUIFriendShipViewModel>();
|
||||||
serviceLocator<TUIFriendShipViewModel>();
|
final TUIConversationViewModel tuiConversationViewModel = serviceLocator<TUIConversationViewModel>();
|
||||||
final TUIConversationViewModel tuiConversationViewModel =
|
final TUIChatGlobalModel tuiChatViewModel = serviceLocator<TUIChatGlobalModel>();
|
||||||
serviceLocator<TUIConversationViewModel>();
|
final TUIGroupListenerModel tuiGroupListenerModel = serviceLocator<TUIGroupListenerModel>();
|
||||||
final TUIChatGlobalModel tuiChatViewModel =
|
|
||||||
serviceLocator<TUIChatGlobalModel>();
|
|
||||||
final TUIGroupListenerModel tuiGroupListenerModel =
|
|
||||||
serviceLocator<TUIGroupListenerModel>();
|
|
||||||
|
|
||||||
tuiFriendShipViewModel.removeFriendshipListener();
|
tuiFriendShipViewModel.removeFriendshipListener();
|
||||||
tuiConversationViewModel.removeConversationListener();
|
tuiConversationViewModel.removeConversationListener();
|
||||||
|
|
@ -222,28 +212,22 @@ class CoreServicesImpl implements CoreServices {
|
||||||
onCallback!(callbackValue);
|
onCallback!(callbackValue);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
outputLogger.i(
|
outputLogger.i("TUIKit Callback: ${callbackValue.type} - ${callbackValue.stackTrace}");
|
||||||
"TUIKit Callback: ${callbackValue.type} - ${callbackValue.stackTrace}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initDataModel() {
|
initDataModel() {
|
||||||
final TUIFriendShipViewModel tuiFriendShipViewModel =
|
final TUIFriendShipViewModel tuiFriendShipViewModel = serviceLocator<TUIFriendShipViewModel>();
|
||||||
serviceLocator<TUIFriendShipViewModel>();
|
final TUIConversationViewModel tuiConversationViewModel = serviceLocator<TUIConversationViewModel>();
|
||||||
final TUIConversationViewModel tuiConversationViewModel =
|
|
||||||
serviceLocator<TUIConversationViewModel>();
|
|
||||||
|
|
||||||
tuiFriendShipViewModel.initFriendShipModel();
|
tuiFriendShipViewModel.initFriendShipModel();
|
||||||
tuiConversationViewModel.initConversation();
|
tuiConversationViewModel.initConversation();
|
||||||
}
|
}
|
||||||
|
|
||||||
clearData() {
|
clearData() {
|
||||||
final TUIFriendShipViewModel tuiFriendShipViewModel =
|
final TUIFriendShipViewModel tuiFriendShipViewModel = serviceLocator<TUIFriendShipViewModel>();
|
||||||
serviceLocator<TUIFriendShipViewModel>();
|
final TUIConversationViewModel tuiConversationViewModel = serviceLocator<TUIConversationViewModel>();
|
||||||
final TUIConversationViewModel tuiConversationViewModel =
|
final TUIChatGlobalModel tuiChatViewModel = serviceLocator<TUIChatGlobalModel>();
|
||||||
serviceLocator<TUIConversationViewModel>();
|
|
||||||
final TUIChatGlobalModel tuiChatViewModel =
|
|
||||||
serviceLocator<TUIChatGlobalModel>();
|
|
||||||
|
|
||||||
tuiFriendShipViewModel.clearData();
|
tuiFriendShipViewModel.clearData();
|
||||||
tuiConversationViewModel.clearData();
|
tuiConversationViewModel.clearData();
|
||||||
|
|
@ -252,19 +236,17 @@ class CoreServicesImpl implements CoreServices {
|
||||||
|
|
||||||
updateUserStatusList(List<V2TimUserStatus> newUserStatusList) {
|
updateUserStatusList(List<V2TimUserStatus> newUserStatusList) {
|
||||||
try {
|
try {
|
||||||
final TUISelfInfoViewModel selfInfoViewModel =
|
final TUISelfInfoViewModel selfInfoViewModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
if (selfInfoViewModel.globalConfig?.isShowOnlineStatus == false) {
|
if (selfInfoViewModel.globalConfig?.isShowOnlineStatus == false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final TUIFriendShipViewModel tuiFriendShipViewModel =
|
final TUIFriendShipViewModel tuiFriendShipViewModel = serviceLocator<TUIFriendShipViewModel>();
|
||||||
serviceLocator<TUIFriendShipViewModel>();
|
|
||||||
final currentUserStatusList = tuiFriendShipViewModel.userStatusList;
|
final currentUserStatusList = tuiFriendShipViewModel.userStatusList;
|
||||||
|
|
||||||
for (int i = 0; i < newUserStatusList.length; i++) {
|
for (int i = 0; i < newUserStatusList.length; i++) {
|
||||||
final int indexInCurrentUserList = currentUserStatusList.indexWhere(
|
final int indexInCurrentUserList =
|
||||||
(element) => element.userID == newUserStatusList[i].userID);
|
currentUserStatusList.indexWhere((element) => element.userID == newUserStatusList[i].userID);
|
||||||
if (indexInCurrentUserList == -1) {
|
if (indexInCurrentUserList == -1) {
|
||||||
currentUserStatusList.add(newUserStatusList[i]);
|
currentUserStatusList.add(newUserStatusList[i]);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -284,16 +266,12 @@ class CoreServicesImpl implements CoreServices {
|
||||||
}) async {
|
}) async {
|
||||||
_userID = userID;
|
_userID = userID;
|
||||||
_userSig = userSig;
|
_userSig = userSig;
|
||||||
V2TimCallback result = await TencentImSDKPlugin.v2TIMManager
|
V2TimCallback result = await TencentImSDKPlugin.v2TIMManager.login(userID: userID, userSig: userSig);
|
||||||
.login(userID: userID, userSig: userSig);
|
|
||||||
if (!PlatformUtils().isWeb) {
|
if (!PlatformUtils().isWeb) {
|
||||||
didLoginSuccess();
|
didLoginSuccess();
|
||||||
}
|
}
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
callOnCallback(TIMCallback(
|
callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorCode: result.code, errorMsg: result.desc));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorCode: result.code,
|
|
||||||
errorMsg: result.desc));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -307,8 +285,7 @@ class CoreServicesImpl implements CoreServices {
|
||||||
initDataModel();
|
initDataModel();
|
||||||
|
|
||||||
if (TencentUtils.checkString(_userID) == null) {
|
if (TencentUtils.checkString(_userID) == null) {
|
||||||
V2TimValueCallback<String> getLoginUserRes =
|
V2TimValueCallback<String> getLoginUserRes = await TencentImSDKPlugin.v2TIMManager.getLoginUser();
|
||||||
await TencentImSDKPlugin.v2TIMManager.getLoginUser();
|
|
||||||
if (getLoginUserRes.code == 0) {
|
if (getLoginUserRes.code == 0) {
|
||||||
_userID = getLoginUserRes.data ?? "";
|
_userID = getLoginUserRes.data ?? "";
|
||||||
}
|
}
|
||||||
|
|
@ -326,18 +303,15 @@ class CoreServicesImpl implements CoreServices {
|
||||||
if (res.code == 0 &&
|
if (res.code == 0 &&
|
||||||
res.data != null &&
|
res.data != null &&
|
||||||
res.data!.isNotEmpty &&
|
res.data!.isNotEmpty &&
|
||||||
res.data!.firstWhereOrNull((element) => element.userID == _userID) !=
|
res.data!.firstWhereOrNull((element) => element.userID == _userID) != null) {
|
||||||
null) {
|
|
||||||
success = true;
|
success = true;
|
||||||
} else {
|
} else {
|
||||||
await Future.delayed(const Duration(seconds: 2));
|
await Future.delayed(const Duration(seconds: 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_loginInfo =
|
_loginInfo = res?.data!.firstWhereOrNull((element) => element.userID == _userID);
|
||||||
res?.data!.firstWhereOrNull((element) => element.userID == _userID);
|
final TUISelfInfoViewModel selfInfoViewModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
final TUISelfInfoViewModel selfInfoViewModel =
|
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
if (_loginInfo != null) {
|
if (_loginInfo != null) {
|
||||||
selfInfoViewModel.setLoginInfo(_loginInfo);
|
selfInfoViewModel.setLoginInfo(_loginInfo);
|
||||||
}
|
}
|
||||||
|
|
@ -389,9 +363,7 @@ class CoreServicesImpl implements CoreServices {
|
||||||
bool isTPNSToken = false,
|
bool isTPNSToken = false,
|
||||||
int? businessID,
|
int? businessID,
|
||||||
}) {
|
}) {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getOfflinePushManager().setOfflinePushConfig(
|
||||||
.getOfflinePushManager()
|
|
||||||
.setOfflinePushConfig(
|
|
||||||
businessID: businessID?.toDouble() ?? 0,
|
businessID: businessID?.toDouble() ?? 0,
|
||||||
token: token,
|
token: token,
|
||||||
isTPNSToken: isTPNSToken,
|
isTPNSToken: isTPNSToken,
|
||||||
|
|
@ -402,8 +374,7 @@ class CoreServicesImpl implements CoreServices {
|
||||||
Future<V2TimCallback> setSelfInfo({
|
Future<V2TimCallback> setSelfInfo({
|
||||||
required V2TimUserFullInfo userFullInfo,
|
required V2TimUserFullInfo userFullInfo,
|
||||||
}) {
|
}) {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.setSelfInfo(userFullInfo: userFullInfo);
|
||||||
.setSelfInfo(userFullInfo: userFullInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -434,16 +405,11 @@ class CoreServicesImpl implements CoreServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimCallback> setOfflinePushStatus(
|
Future<V2TimCallback> setOfflinePushStatus({required AppStatus status, int? totalCount}) {
|
||||||
{required AppStatus status, int? totalCount}) {
|
|
||||||
if (status == AppStatus.foreground) {
|
if (status == AppStatus.foreground) {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getOfflinePushManager().doForeground();
|
||||||
.getOfflinePushManager()
|
|
||||||
.doForeground();
|
|
||||||
} else {
|
} else {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getOfflinePushManager().doBackground(unreadCount: totalCount ?? 0);
|
||||||
.getOfflinePushManager()
|
|
||||||
.doBackground(unreadCount: totalCount ?? 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,26 @@ import 'package:tencent_cloud_chat_sdk/enum/V2TimFriendshipListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_application_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_application_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_response_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_response_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_application_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_check_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_application_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_application_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_check_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_check_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_search_param.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_operation_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_status.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
|
|
||||||
abstract class FriendshipServices {
|
abstract class FriendshipServices {
|
||||||
Future<List<V2TimFriendInfoResult>?> getFriendsInfo({
|
Future<List<V2TimFriendInfoResult>?> getFriendsInfo({
|
||||||
|
|
@ -67,9 +77,7 @@ abstract class FriendshipServices {
|
||||||
Future<V2TimFriendApplicationResult?> getFriendApplicationList();
|
Future<V2TimFriendApplicationResult?> getFriendApplicationList();
|
||||||
|
|
||||||
Future<V2TimFriendOperationResult?> acceptFriendApplication(
|
Future<V2TimFriendOperationResult?> acceptFriendApplication(
|
||||||
{required FriendResponseTypeEnum responseType,
|
{required FriendResponseTypeEnum responseType, required FriendApplicationTypeEnum type, required String userID});
|
||||||
required FriendApplicationTypeEnum type,
|
|
||||||
required String userID});
|
|
||||||
|
|
||||||
Future<V2TimFriendOperationResult?> refuseFriendApplication(
|
Future<V2TimFriendOperationResult?> refuseFriendApplication(
|
||||||
{required FriendApplicationTypeEnum type, required String userID});
|
{required FriendApplicationTypeEnum type, required String userID});
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,26 @@ import 'package:tencent_cloud_chat_sdk/enum/V2TimFriendshipListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_application_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_application_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_response_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_response_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_application_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_check_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_application_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_application_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_check_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_check_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_search_param.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_operation_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_status.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/core_services_implements.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/core_services_implements.dart';
|
||||||
|
|
@ -27,16 +37,12 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
Future<List<V2TimFriendInfoResult>?> getFriendsInfo({
|
Future<List<V2TimFriendInfoResult>?> getFriendsInfo({
|
||||||
required List<String> userIDList,
|
required List<String> userIDList,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().getFriendsInfo(userIDList: userIDList);
|
||||||
.getFriendshipManager()
|
|
||||||
.getFriendsInfo(userIDList: userIDList);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -45,15 +51,12 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
Future<List<V2TimUserFullInfo>?> getUsersInfo({
|
Future<List<V2TimUserFullInfo>?> getUsersInfo({
|
||||||
required List<String> userIDList,
|
required List<String> userIDList,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getUsersInfo(userIDList: userIDList);
|
||||||
.getUsersInfo(userIDList: userIDList);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -62,16 +65,12 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
Future<List<V2TimFriendOperationResult>?> addToBlackList({
|
Future<List<V2TimFriendOperationResult>?> addToBlackList({
|
||||||
required List<String> userIDList,
|
required List<String> userIDList,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().addToBlackList(userIDList: userIDList);
|
||||||
.getFriendshipManager()
|
|
||||||
.addToBlackList(userIDList: userIDList);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,15 +84,14 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
String? addSource,
|
String? addSource,
|
||||||
String? addWording,
|
String? addWording,
|
||||||
}) async {
|
}) async {
|
||||||
final result =
|
final result = await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().addFriend(
|
||||||
await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().addFriend(
|
userID: userID,
|
||||||
userID: userID,
|
addType: addType,
|
||||||
addType: addType,
|
remark: remark,
|
||||||
remark: remark,
|
addWording: addWording,
|
||||||
addWording: addWording,
|
friendGroup: friendGroup,
|
||||||
friendGroup: friendGroup,
|
addSource: addSource,
|
||||||
addSource: addSource,
|
);
|
||||||
);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(
|
||||||
type: TIMCallbackType.API_ERROR,
|
type: TIMCallbackType.API_ERROR,
|
||||||
|
|
@ -115,10 +113,10 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(
|
||||||
type: TIMCallbackType.API_ERROR,
|
type: TIMCallbackType.API_ERROR,
|
||||||
errorMsg: result.desc,
|
errorMsg: result.desc,
|
||||||
errorCode: result.code,
|
errorCode: result.code,
|
||||||
infoRecommendText: TIM_t("好友添加成功"),
|
infoRecommendText: TIM_t("好友添加成功"),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,16 +127,13 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
Future<List<V2TimFriendOperationResult>?> deleteFromBlackList({
|
Future<List<V2TimFriendOperationResult>?> deleteFromBlackList({
|
||||||
required List<String> userIDList,
|
required List<String> userIDList,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res =
|
||||||
.getFriendshipManager()
|
await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().deleteFromBlackList(userIDList: userIDList);
|
||||||
.deleteFromBlackList(userIDList: userIDList);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -170,32 +165,24 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<V2TimFriendInfo>?> getFriendList() async {
|
Future<List<V2TimFriendInfo>?> getFriendList() async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().getFriendList();
|
||||||
.getFriendshipManager()
|
|
||||||
.getFriendList();
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<V2TimFriendInfo>?> getBlackList() async {
|
Future<List<V2TimFriendInfo>?> getBlackList() async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().getBlackList();
|
||||||
.getFriendshipManager()
|
|
||||||
.getBlackList();
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -211,10 +198,8 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -223,32 +208,24 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
Future<void> addFriendListener({
|
Future<void> addFriendListener({
|
||||||
required V2TimFriendshipListener listener,
|
required V2TimFriendshipListener listener,
|
||||||
}) {
|
}) {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getFriendshipManager().addFriendListener(listener: listener);
|
||||||
.getFriendshipManager()
|
|
||||||
.addFriendListener(listener: listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> removeFriendListener({
|
Future<void> removeFriendListener({
|
||||||
V2TimFriendshipListener? listener,
|
V2TimFriendshipListener? listener,
|
||||||
}) {
|
}) {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getFriendshipManager().removeFriendListener(listener: listener);
|
||||||
.getFriendshipManager()
|
|
||||||
.removeFriendListener(listener: listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimFriendApplicationResult?> getFriendApplicationList() async {
|
Future<V2TimFriendApplicationResult?> getFriendApplicationList() async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().getFriendApplicationList();
|
||||||
.getFriendshipManager()
|
|
||||||
.getFriendApplicationList();
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -259,9 +236,7 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
required FriendApplicationTypeEnum type,
|
required FriendApplicationTypeEnum type,
|
||||||
required String userID,
|
required String userID,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().acceptFriendApplication(
|
||||||
.getFriendshipManager()
|
|
||||||
.acceptFriendApplication(
|
|
||||||
responseType: responseType,
|
responseType: responseType,
|
||||||
type: type,
|
type: type,
|
||||||
userID: userID,
|
userID: userID,
|
||||||
|
|
@ -269,10 +244,8 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -286,10 +259,8 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -302,15 +273,10 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getFriendshipManager()
|
.getFriendshipManager()
|
||||||
.setFriendInfo(
|
.setFriendInfo(friendRemark: friendRemark, friendCustomInfo: friendCustomInfo, userID: userID);
|
||||||
friendRemark: friendRemark,
|
|
||||||
friendCustomInfo: friendCustomInfo,
|
|
||||||
userID: userID);
|
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -319,16 +285,12 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
Future<List<V2TimFriendInfoResult>?> searchFriends({
|
Future<List<V2TimFriendInfoResult>?> searchFriends({
|
||||||
required V2TimFriendSearchParam searchParam,
|
required V2TimFriendSearchParam searchParam,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getFriendshipManager().searchFriends(searchParam: searchParam);
|
||||||
.getFriendshipManager()
|
|
||||||
.searchFriends(searchParam: searchParam);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -337,15 +299,12 @@ class FriendshipServicesImpl implements FriendshipServices {
|
||||||
Future<List<V2TimUserStatus>> getUserStatus({
|
Future<List<V2TimUserStatus>> getUserStatus({
|
||||||
required List<String> userIDList,
|
required List<String> userIDList,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getUserStatus(userIDList: userIDList);
|
||||||
.getUserStatus(userIDList: userIDList);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data ?? [];
|
return res.data ?? [];
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,28 @@ import 'package:tencent_cloud_chat_sdk/enum/V2TimGroupListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_application_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_application_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_filter_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_filter_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_role_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_role_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_application_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_operation_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_search_param.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_info_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_info_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_operation_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_operation_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
|
|
||||||
abstract class GroupServices {
|
abstract class GroupServices {
|
||||||
Future<List<V2TimGroupInfo>?> getJoinedGroupList();
|
Future<List<V2TimGroupInfo>?> getJoinedGroupList();
|
||||||
|
|
@ -29,9 +40,8 @@ abstract class GroupServices {
|
||||||
int offset = 0,
|
int offset = 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimValueCallback<List<V2TimGroupMemberFullInfo>>>
|
Future<V2TimValueCallback<List<V2TimGroupMemberFullInfo>>> getGroupMembersInfo(
|
||||||
getGroupMembersInfo(
|
{required String groupID, required List<String> memberList});
|
||||||
{required String groupID, required List<String> memberList});
|
|
||||||
|
|
||||||
Future<V2TimCallback> setGroupInfo({
|
Future<V2TimCallback> setGroupInfo({
|
||||||
required V2TimGroupInfo info,
|
required V2TimGroupInfo info,
|
||||||
|
|
@ -43,10 +53,7 @@ abstract class GroupServices {
|
||||||
required GroupMemberRoleTypeEnum role,
|
required GroupMemberRoleTypeEnum role,
|
||||||
});
|
});
|
||||||
|
|
||||||
getGroupMembersInfoThrottle(
|
getGroupMembersInfoThrottle({required String groupID, required List<String> memberList, Function? callBack});
|
||||||
{required String groupID,
|
|
||||||
required List<String> memberList,
|
|
||||||
Function? callBack});
|
|
||||||
|
|
||||||
Future<V2TimCallback> muteGroupMember({
|
Future<V2TimCallback> muteGroupMember({
|
||||||
required String groupID,
|
required String groupID,
|
||||||
|
|
@ -67,8 +74,7 @@ abstract class GroupServices {
|
||||||
String? reason,
|
String? reason,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimValueCallback<List<V2TimGroupMemberOperationResult>>>
|
Future<V2TimValueCallback<List<V2TimGroupMemberOperationResult>>> inviteUserToGroup({
|
||||||
inviteUserToGroup({
|
|
||||||
required String groupID,
|
required String groupID,
|
||||||
required List<String> userList,
|
required List<String> userList,
|
||||||
});
|
});
|
||||||
|
|
@ -94,8 +100,7 @@ abstract class GroupServices {
|
||||||
V2TimGroupListener? listener,
|
V2TimGroupListener? listener,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimValueCallback<V2TimGroupApplicationResult>>
|
Future<V2TimValueCallback<V2TimGroupApplicationResult>> getGroupApplicationList();
|
||||||
getGroupApplicationList();
|
|
||||||
|
|
||||||
Future<V2TimCallback> acceptGroupApplication({
|
Future<V2TimCallback> acceptGroupApplication({
|
||||||
required String groupID,
|
required String groupID,
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,28 @@ import 'package:tencent_cloud_chat_sdk/enum/V2TimGroupListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_application_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_application_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_filter_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_filter_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_role_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_role_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_application_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_operation_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_search_param.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_info_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_info_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_operation_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_operation_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/core_services_implements.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/core_services_implements.dart';
|
||||||
|
|
@ -46,16 +57,12 @@ class GroupServicesImpl extends GroupServices {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<V2TimGroupInfo>?> getJoinedGroupList() async {
|
Future<List<V2TimGroupInfo>?> getJoinedGroupList() async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getGroupManager().getJoinedGroupList();
|
||||||
.getGroupManager()
|
|
||||||
.getJoinedGroupList();
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -64,25 +71,19 @@ class GroupServicesImpl extends GroupServices {
|
||||||
Future<List<V2TimGroupInfoResult>?> getGroupsInfo({
|
Future<List<V2TimGroupInfoResult>?> getGroupsInfo({
|
||||||
required List<String> groupIDList,
|
required List<String> groupIDList,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getGroupManager().getGroupsInfo(groupIDList: groupIDList);
|
||||||
.getGroupManager()
|
|
||||||
.getGroupsInfo(groupIDList: groupIDList);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void getGroupMembersInfoThrottle(
|
void getGroupMembersInfoThrottle(
|
||||||
{required String groupID,
|
{required String groupID, required List<String> memberList, Function? callBack}) async {
|
||||||
required List<String> memberList,
|
|
||||||
Function? callBack}) async {
|
|
||||||
if (callBack != null) {
|
if (callBack != null) {
|
||||||
groupInfoCallBackList.add(callBack);
|
groupInfoCallBackList.add(callBack);
|
||||||
throttleGetGroupInfo({"groupID": groupID, "memberList": memberList});
|
throttleGetGroupInfo({"groupID": groupID, "memberList": memberList});
|
||||||
|
|
@ -90,17 +91,14 @@ class GroupServicesImpl extends GroupServices {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimValueCallback<List<V2TimGroupMemberFullInfo>>>
|
Future<V2TimValueCallback<List<V2TimGroupMemberFullInfo>>> getGroupMembersInfo(
|
||||||
getGroupMembersInfo(
|
{required String groupID, required List<String> memberList}) async {
|
||||||
{required String groupID, required List<String> memberList}) async {
|
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getGroupManager()
|
.getGroupManager()
|
||||||
.getGroupMembersInfo(groupID: groupID, memberList: memberList);
|
.getGroupMembersInfo(groupID: groupID, memberList: memberList);
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -115,17 +113,10 @@ class GroupServicesImpl extends GroupServices {
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getGroupManager()
|
.getGroupManager()
|
||||||
.getGroupMemberList(
|
.getGroupMemberList(groupID: groupID, filter: filter, nextSeq: nextSeq, count: count, offset: offset);
|
||||||
groupID: groupID,
|
|
||||||
filter: filter,
|
|
||||||
nextSeq: nextSeq,
|
|
||||||
count: count,
|
|
||||||
offset: offset);
|
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -134,14 +125,10 @@ class GroupServicesImpl extends GroupServices {
|
||||||
Future<V2TimCallback> setGroupInfo({
|
Future<V2TimCallback> setGroupInfo({
|
||||||
required V2TimGroupInfo info,
|
required V2TimGroupInfo info,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.getGroupManager().setGroupInfo(info: info);
|
||||||
.getGroupManager()
|
|
||||||
.setGroupInfo(info: info);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -156,10 +143,8 @@ class GroupServicesImpl extends GroupServices {
|
||||||
.getGroupManager()
|
.getGroupManager()
|
||||||
.setGroupMemberRole(groupID: groupID, userID: userID, role: role);
|
.setGroupMemberRole(groupID: groupID, userID: userID, role: role);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -174,10 +159,8 @@ class GroupServicesImpl extends GroupServices {
|
||||||
.getGroupManager()
|
.getGroupManager()
|
||||||
.muteGroupMember(groupID: groupID, userID: userID, seconds: seconds);
|
.muteGroupMember(groupID: groupID, userID: userID, seconds: seconds);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -191,16 +174,10 @@ class GroupServicesImpl extends GroupServices {
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getGroupManager()
|
.getGroupManager()
|
||||||
.setGroupMemberInfo(
|
.setGroupMemberInfo(groupID: groupID, userID: userID, nameCard: nameCard, customInfo: customInfo);
|
||||||
groupID: groupID,
|
|
||||||
userID: userID,
|
|
||||||
nameCard: nameCard,
|
|
||||||
customInfo: customInfo);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -213,31 +190,24 @@ class GroupServicesImpl extends GroupServices {
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getGroupManager()
|
.getGroupManager()
|
||||||
.kickGroupMember(
|
.kickGroupMember(groupID: groupID, memberList: memberList, reason: reason);
|
||||||
groupID: groupID, memberList: memberList, reason: reason);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimValueCallback<List<V2TimGroupMemberOperationResult>>>
|
Future<V2TimValueCallback<List<V2TimGroupMemberOperationResult>>> inviteUserToGroup({
|
||||||
inviteUserToGroup({
|
|
||||||
required String groupID,
|
required String groupID,
|
||||||
required List<String> userList,
|
required List<String> userList,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result =
|
||||||
.getGroupManager()
|
await TencentImSDKPlugin.v2TIMManager.getGroupManager().inviteUserToGroup(groupID: groupID, userList: userList);
|
||||||
.inviteUserToGroup(groupID: groupID, userList: userList);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -246,14 +216,10 @@ class GroupServicesImpl extends GroupServices {
|
||||||
Future<V2TimValueCallback<List<V2TimGroupInfo>>> searchGroups({
|
Future<V2TimValueCallback<List<V2TimGroupInfo>>> searchGroups({
|
||||||
required V2TimGroupSearchParam searchParam,
|
required V2TimGroupSearchParam searchParam,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.getGroupManager().searchGroups(searchParam: searchParam);
|
||||||
.getGroupManager()
|
|
||||||
.searchGroups(searchParam: searchParam);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -263,8 +229,7 @@ class GroupServicesImpl extends GroupServices {
|
||||||
required String groupID,
|
required String groupID,
|
||||||
required String message,
|
required String message,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.joinGroup(groupID: groupID, message: message);
|
||||||
.joinGroup(groupID: groupID, message: message);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
String recommendText = ErrorMessageConverter.getErrorMessage(result.code);
|
String recommendText = ErrorMessageConverter.getErrorMessage(result.code);
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(
|
||||||
|
|
@ -280,14 +245,10 @@ class GroupServicesImpl extends GroupServices {
|
||||||
Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMembers({
|
Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMembers({
|
||||||
required V2TimGroupMemberSearchParam searchParam,
|
required V2TimGroupMemberSearchParam searchParam,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.getGroupManager().searchGroupMembers(param: searchParam);
|
||||||
.getGroupManager()
|
|
||||||
.searchGroupMembers(param: searchParam);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -296,8 +257,7 @@ class GroupServicesImpl extends GroupServices {
|
||||||
Future<void> addGroupListener({
|
Future<void> addGroupListener({
|
||||||
required V2TimGroupListener listener,
|
required V2TimGroupListener listener,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.addGroupListener(listener: listener);
|
||||||
.addGroupListener(listener: listener);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -305,22 +265,16 @@ class GroupServicesImpl extends GroupServices {
|
||||||
Future<void> removeGroupListener({
|
Future<void> removeGroupListener({
|
||||||
V2TimGroupListener? listener,
|
V2TimGroupListener? listener,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.removeGroupListener(listener: listener);
|
||||||
.removeGroupListener(listener: listener);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimValueCallback<V2TimGroupApplicationResult>>
|
Future<V2TimValueCallback<V2TimGroupApplicationResult>> getGroupApplicationList() async {
|
||||||
getGroupApplicationList() async {
|
final result = await TencentImSDKPlugin.v2TIMManager.getGroupManager().getGroupApplicationList();
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
|
||||||
.getGroupManager()
|
|
||||||
.getGroupApplicationList();
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -333,9 +287,7 @@ class GroupServicesImpl extends GroupServices {
|
||||||
required int type,
|
required int type,
|
||||||
required int addTime,
|
required int addTime,
|
||||||
String? reason}) async {
|
String? reason}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.getGroupManager().acceptGroupApplication(
|
||||||
.getGroupManager()
|
|
||||||
.acceptGroupApplication(
|
|
||||||
groupID: groupID,
|
groupID: groupID,
|
||||||
fromUser: fromUser,
|
fromUser: fromUser,
|
||||||
toUser: toUser,
|
toUser: toUser,
|
||||||
|
|
@ -344,10 +296,8 @@ class GroupServicesImpl extends GroupServices {
|
||||||
reason: reason ?? "",
|
reason: reason ?? "",
|
||||||
);
|
);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -360,20 +310,11 @@ class GroupServicesImpl extends GroupServices {
|
||||||
required String fromUser,
|
required String fromUser,
|
||||||
required String toUser,
|
required String toUser,
|
||||||
required GroupApplicationTypeEnum type}) async {
|
required GroupApplicationTypeEnum type}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.getGroupManager().refuseGroupApplication(
|
||||||
.getGroupManager()
|
groupID: groupID, fromUser: fromUser, toUser: toUser, type: type, addTime: addTime, reason: reason);
|
||||||
.refuseGroupApplication(
|
|
||||||
groupID: groupID,
|
|
||||||
fromUser: fromUser,
|
|
||||||
toUser: toUser,
|
|
||||||
type: type,
|
|
||||||
addTime: addTime,
|
|
||||||
reason: reason);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,17 +10,28 @@ import 'package:tencent_cloud_chat_sdk/enum/history_msg_get_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_priority_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_priority_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/receive_message_opt_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/receive_message_opt_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_message_read_member_list.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_message_read_member_list.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_message_read_member_list.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_list_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_online_url.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_receipt.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_param.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_change_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_list_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_msg_create_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_list_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_online_url.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_online_url.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_receipt.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_receipt.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_search_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_msg_create_info_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_msg_create_info_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_conversation_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_conversation_view_model.dart';
|
||||||
|
|
@ -37,8 +48,7 @@ class MessageServiceImpl extends MessageService {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<MessageListResponse> getHistoryMessageListV2({
|
Future<MessageListResponse> getHistoryMessageListV2({
|
||||||
HistoryMsgGetTypeEnum getType =
|
HistoryMsgGetTypeEnum getType = HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
||||||
HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
|
||||||
String? userID,
|
String? userID,
|
||||||
String? groupID,
|
String? groupID,
|
||||||
int lastMsgSeq = -1,
|
int lastMsgSeq = -1,
|
||||||
|
|
@ -47,16 +57,14 @@ class MessageServiceImpl extends MessageService {
|
||||||
List<int>? messageTypeList,
|
List<int>? messageTypeList,
|
||||||
}) async {
|
}) async {
|
||||||
bool haveMoreData = true;
|
bool haveMoreData = true;
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().getHistoryMessageList(
|
||||||
.getMessageManager()
|
count: count,
|
||||||
.getHistoryMessageList(
|
getType: getType,
|
||||||
count: count,
|
userID: userID,
|
||||||
getType: getType,
|
groupID: groupID,
|
||||||
userID: userID,
|
lastMsgID: lastMsgID,
|
||||||
groupID: groupID,
|
lastMsgSeq: lastMsgSeq,
|
||||||
lastMsgID: lastMsgID,
|
messageTypeList: messageTypeList);
|
||||||
lastMsgSeq: lastMsgSeq,
|
|
||||||
messageTypeList: messageTypeList);
|
|
||||||
final List<V2TimMessage> responseMessageList = res.data ?? [];
|
final List<V2TimMessage> responseMessageList = res.data ?? [];
|
||||||
final conversationID = userID ?? groupID;
|
final conversationID = userID ?? groupID;
|
||||||
final cachedMessageList = messageListMap[conversationID];
|
final cachedMessageList = messageListMap[conversationID];
|
||||||
|
|
@ -66,41 +74,33 @@ class MessageServiceImpl extends MessageService {
|
||||||
combinedMessageList = [...cachedMessageList, ...responseMessageList];
|
combinedMessageList = [...cachedMessageList, ...responseMessageList];
|
||||||
// 首次加载
|
// 首次加载
|
||||||
} else {
|
} else {
|
||||||
final bool existSendingMessage = sendingMessage[conversationID] != null &&
|
final bool existSendingMessage =
|
||||||
sendingMessage[conversationID]!.isNotEmpty;
|
sendingMessage[conversationID] != null && sendingMessage[conversationID]!.isNotEmpty;
|
||||||
// 存在未发送完成的消息
|
// 存在未发送完成的消息
|
||||||
if (existSendingMessage) {
|
if (existSendingMessage) {
|
||||||
combinedMessageList = [
|
combinedMessageList = [...sendingMessage[conversationID]!, ...responseMessageList];
|
||||||
...sendingMessage[conversationID]!,
|
|
||||||
...responseMessageList
|
|
||||||
];
|
|
||||||
} else {
|
} else {
|
||||||
sendingMessage.remove(conversationID);
|
sendingMessage.remove(conversationID);
|
||||||
combinedMessageList = responseMessageList;
|
combinedMessageList = responseMessageList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
}
|
}
|
||||||
if (responseMessageList.isEmpty ||
|
if (responseMessageList.isEmpty ||
|
||||||
(!PlatformUtils().isWeb && responseMessageList.length < count) ||
|
(!PlatformUtils().isWeb && responseMessageList.length < count) ||
|
||||||
(PlatformUtils().isWeb &&
|
(PlatformUtils().isWeb && responseMessageList.length < min(count, 20))) {
|
||||||
responseMessageList.length < min(count, 20))) {
|
|
||||||
haveMoreData = false;
|
haveMoreData = false;
|
||||||
} else {
|
} else {
|
||||||
haveMoreData = true;
|
haveMoreData = true;
|
||||||
}
|
}
|
||||||
return MessageListResponse(
|
return MessageListResponse(haveMoreData: haveMoreData, data: combinedMessageList);
|
||||||
haveMoreData: haveMoreData, data: combinedMessageList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<V2TimMessage>> getHistoryMessageList({
|
Future<List<V2TimMessage>> getHistoryMessageList({
|
||||||
HistoryMsgGetTypeEnum getType =
|
HistoryMsgGetTypeEnum getType = HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
||||||
HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
|
||||||
String? userID,
|
String? userID,
|
||||||
String? groupID,
|
String? groupID,
|
||||||
int lastMsgSeq = -1,
|
int lastMsgSeq = -1,
|
||||||
|
|
@ -108,30 +108,25 @@ class MessageServiceImpl extends MessageService {
|
||||||
String? lastMsgID,
|
String? lastMsgID,
|
||||||
List<int>? messageTypeList,
|
List<int>? messageTypeList,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().getHistoryMessageList(
|
||||||
.getMessageManager()
|
count: count,
|
||||||
.getHistoryMessageList(
|
getType: getType,
|
||||||
count: count,
|
userID: userID,
|
||||||
getType: getType,
|
groupID: groupID,
|
||||||
userID: userID,
|
lastMsgID: lastMsgID,
|
||||||
groupID: groupID,
|
lastMsgSeq: lastMsgSeq,
|
||||||
lastMsgID: lastMsgID,
|
messageTypeList: messageTypeList);
|
||||||
lastMsgSeq: lastMsgSeq,
|
|
||||||
messageTypeList: messageTypeList);
|
|
||||||
final reponseMessageList = res.data ?? [];
|
final reponseMessageList = res.data ?? [];
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
}
|
}
|
||||||
return reponseMessageList;
|
return reponseMessageList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimMessageListResult?> getHistoryMessageListWithComplete({
|
Future<V2TimMessageListResult?> getHistoryMessageListWithComplete({
|
||||||
HistoryMsgGetTypeEnum getType =
|
HistoryMsgGetTypeEnum getType = HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
||||||
HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
|
||||||
String? userID,
|
String? userID,
|
||||||
String? groupID,
|
String? groupID,
|
||||||
int lastMsgSeq = 0,
|
int lastMsgSeq = 0,
|
||||||
|
|
@ -139,22 +134,18 @@ class MessageServiceImpl extends MessageService {
|
||||||
String? lastMsgID,
|
String? lastMsgID,
|
||||||
List<int>? messageTypeList,
|
List<int>? messageTypeList,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().getHistoryMessageListV2(
|
||||||
.getMessageManager()
|
count: count,
|
||||||
.getHistoryMessageListV2(
|
getType: getType,
|
||||||
count: count,
|
userID: userID,
|
||||||
getType: getType,
|
groupID: groupID,
|
||||||
userID: userID,
|
lastMsgID: lastMsgID,
|
||||||
groupID: groupID,
|
lastMsgSeq: lastMsgSeq,
|
||||||
lastMsgID: lastMsgID,
|
messageTypeList: messageTypeList);
|
||||||
lastMsgSeq: lastMsgSeq,
|
|
||||||
messageTypeList: messageTypeList);
|
|
||||||
final responseMessageList = res.data;
|
final responseMessageList = res.data;
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
}
|
}
|
||||||
return responseMessageList;
|
return responseMessageList;
|
||||||
}
|
}
|
||||||
|
|
@ -163,28 +154,23 @@ class MessageServiceImpl extends MessageService {
|
||||||
Future addSimpleMsgListener({
|
Future addSimpleMsgListener({
|
||||||
required V2TimSimpleMsgListener listener,
|
required V2TimSimpleMsgListener listener,
|
||||||
}) async {
|
}) async {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.addSimpleMsgListener(listener: listener);
|
||||||
.addSimpleMsgListener(listener: listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> removeSimpleMsgListener({V2TimSimpleMsgListener? listener}) {
|
Future<void> removeSimpleMsgListener({V2TimSimpleMsgListener? listener}) {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.removeSimpleMsgListener(listener: listener);
|
||||||
.removeSimpleMsgListener(listener: listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> addAdvancedMsgListener({
|
Future<void> addAdvancedMsgListener({
|
||||||
required V2TimAdvancedMsgListener listener,
|
required V2TimAdvancedMsgListener listener,
|
||||||
}) {
|
}) {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getMessageManager().addAdvancedMsgListener(listener: listener);
|
||||||
.getMessageManager()
|
|
||||||
.addAdvancedMsgListener(listener: listener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimValueCallback<V2TimGroupMessageReadMemberList>>
|
Future<V2TimValueCallback<V2TimGroupMessageReadMemberList>> getGroupMessageReadMemberList({
|
||||||
getGroupMessageReadMemberList({
|
|
||||||
required String messageID,
|
required String messageID,
|
||||||
required GetGroupMessageReadMemberListFilter filter,
|
required GetGroupMessageReadMemberListFilter filter,
|
||||||
int nextSeq = 0,
|
int nextSeq = 0,
|
||||||
|
|
@ -192,16 +178,10 @@ class MessageServiceImpl extends MessageService {
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.getGroupMessageReadMemberList(
|
.getGroupMessageReadMemberList(messageID: messageID, filter: filter, nextSeq: nextSeq, count: count);
|
||||||
messageID: messageID,
|
|
||||||
filter: filter,
|
|
||||||
nextSeq: nextSeq,
|
|
||||||
count: count);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -210,14 +190,11 @@ class MessageServiceImpl extends MessageService {
|
||||||
Future<V2TimValueCallback<List<V2TimMessageReceipt>>> getMessageReadReceipts({
|
Future<V2TimValueCallback<List<V2TimMessageReceipt>>> getMessageReadReceipts({
|
||||||
required List<String> messageIDList,
|
required List<String> messageIDList,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result =
|
||||||
.getMessageManager()
|
await TencentImSDKPlugin.v2TIMManager.getMessageManager().getMessageReadReceipts(messageIDList: messageIDList);
|
||||||
.getMessageReadReceipts(messageIDList: messageIDList);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -226,78 +203,53 @@ class MessageServiceImpl extends MessageService {
|
||||||
Future<V2TimCallback> sendMessageReadReceipts({
|
Future<V2TimCallback> sendMessageReadReceipts({
|
||||||
required List<String> messageIDList,
|
required List<String> messageIDList,
|
||||||
}) async {
|
}) async {
|
||||||
return _retryMarkMessageAsRead(action: (){
|
return _retryMarkMessageAsRead(action: () {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getMessageManager().sendMessageReadReceipts(messageIDList: messageIDList);
|
||||||
.getMessageManager()
|
|
||||||
.sendMessageReadReceipts(messageIDList: messageIDList);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimMsgCreateInfoResult?> createTextMessage(
|
Future<V2TimMsgCreateInfoResult?> createTextMessage({required String text}) async {
|
||||||
{required String text}) async {
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().createTextMessage(text: text);
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
|
||||||
.getMessageManager()
|
|
||||||
.createTextMessage(text: text);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
final messageResult = res.data;
|
final messageResult = res.data;
|
||||||
return messageResult;
|
return messageResult;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimMsgCreateInfoResult?> createCustomMessage(
|
Future<V2TimMsgCreateInfoResult?> createCustomMessage({required String data}) async {
|
||||||
{required String data}) async {
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().createCustomMessage(data: data);
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
|
||||||
.getMessageManager()
|
|
||||||
.createCustomMessage(data: data);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
final messageResult = res.data;
|
final messageResult = res.data;
|
||||||
return messageResult;
|
return messageResult;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimMsgCreateInfoResult?> createFaceMessage(
|
Future<V2TimMsgCreateInfoResult?> createFaceMessage({required int index, required String data}) async {
|
||||||
{required int index, required String data}) async {
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().createFaceMessage(index: index, data: data);
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
|
||||||
.getMessageManager()
|
|
||||||
.createFaceMessage(index: index, data: data);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
final messageResult = res.data;
|
final messageResult = res.data;
|
||||||
return messageResult;
|
return messageResult;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimValueCallback<V2TimMessage>> reSendMessage(
|
Future<V2TimValueCallback<V2TimMessage>> reSendMessage({required String msgID, bool? onlineUserOnly}) async {
|
||||||
{required String msgID,
|
|
||||||
bool? onlineUserOnly}) async {
|
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.reSendMessage(msgID: msgID, onlineUserOnly: onlineUserOnly ?? false);
|
.reSendMessage(msgID: msgID, onlineUserOnly: onlineUserOnly ?? false);
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
String recommendText = ErrorMessageConverter.getErrorMessage(res.code);
|
String recommendText = ErrorMessageConverter.getErrorMessage(res.code);
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(
|
||||||
type: TIMCallbackType.API_ERROR,
|
type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code, infoRecommendText: recommendText));
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code,
|
|
||||||
infoRecommendText: recommendText));
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -312,10 +264,7 @@ class MessageServiceImpl extends MessageService {
|
||||||
final messageResult = res.data;
|
final messageResult = res.data;
|
||||||
return messageResult;
|
return messageResult;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -324,17 +273,11 @@ class MessageServiceImpl extends MessageService {
|
||||||
{String? imageName, String? imagePath, dynamic inputElement}) async {
|
{String? imageName, String? imagePath, dynamic inputElement}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.createImageMessage(
|
.createImageMessage(imageName: imageName, imagePath: imagePath ?? "", inputElement: inputElement);
|
||||||
imageName: imageName,
|
|
||||||
imagePath: imagePath ?? "",
|
|
||||||
inputElement: inputElement);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -349,10 +292,7 @@ class MessageServiceImpl extends MessageService {
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -370,19 +310,18 @@ class MessageServiceImpl extends MessageService {
|
||||||
String? localCustomData,
|
String? localCustomData,
|
||||||
bool isExcludedFromContentModeration = false,
|
bool isExcludedFromContentModeration = false,
|
||||||
}) async {
|
}) async {
|
||||||
final result =
|
final result = await TencentImSDKPlugin.v2TIMManager.getMessageManager().sendMessage(
|
||||||
await TencentImSDKPlugin.v2TIMManager.getMessageManager().sendMessage(
|
id: id,
|
||||||
id: id,
|
receiver: receiver,
|
||||||
receiver: receiver,
|
groupID: groupID,
|
||||||
groupID: groupID,
|
priority: priority,
|
||||||
priority: priority,
|
onlineUserOnly: onlineUserOnly,
|
||||||
onlineUserOnly: onlineUserOnly,
|
offlinePushInfo: offlinePushInfo,
|
||||||
offlinePushInfo: offlinePushInfo,
|
needReadReceipt: needReadReceipt,
|
||||||
needReadReceipt: needReadReceipt,
|
localCustomData: localCustomData,
|
||||||
localCustomData: localCustomData,
|
cloudCustomData: cloudCustomData,
|
||||||
cloudCustomData: cloudCustomData,
|
isExcludedFromContentModeration: isExcludedFromContentModeration,
|
||||||
isExcludedFromContentModeration: isExcludedFromContentModeration,
|
);
|
||||||
);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
String recommendText = ErrorMessageConverter.getErrorMessage(result.code);
|
String recommendText = ErrorMessageConverter.getErrorMessage(result.code);
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(
|
||||||
|
|
@ -403,34 +342,26 @@ class MessageServiceImpl extends MessageService {
|
||||||
if (kIsWeb) {
|
if (kIsWeb) {
|
||||||
result = await TencentImSDKPlugin.v2TIMManager
|
result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.deleteMessages(
|
.deleteMessages(msgIDs: [], webMessageInstanceList: [webMessageInstance]);
|
||||||
msgIDs: [], webMessageInstanceList: [webMessageInstance]);
|
|
||||||
} else {
|
} else {
|
||||||
result = await TencentImSDKPlugin.v2TIMManager
|
result = await TencentImSDKPlugin.v2TIMManager.getMessageManager().deleteMessageFromLocalStorage(msgID: msgID);
|
||||||
.getMessageManager()
|
|
||||||
.deleteMessageFromLocalStorage(msgID: msgID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimCallback> revokeMessage(
|
Future<V2TimCallback> revokeMessage({required String msgID, Object? webMessageInstance}) async {
|
||||||
{required String msgID, Object? webMessageInstance}) async {
|
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.revokeMessage(msgID: msgID, webMessageInstatnce: webMessageInstance);
|
.revokeMessage(msgID: msgID, webMessageInstatnce: webMessageInstance);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -439,14 +370,10 @@ class MessageServiceImpl extends MessageService {
|
||||||
Future<V2TimCallback> clearC2CHistoryMessage({
|
Future<V2TimCallback> clearC2CHistoryMessage({
|
||||||
required String userID,
|
required String userID,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.getMessageManager().clearC2CHistoryMessage(userID: userID);
|
||||||
.getMessageManager()
|
|
||||||
.clearC2CHistoryMessage(userID: userID);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -455,14 +382,10 @@ class MessageServiceImpl extends MessageService {
|
||||||
Future<V2TimCallback> clearGroupHistoryMessage({
|
Future<V2TimCallback> clearGroupHistoryMessage({
|
||||||
required String groupID,
|
required String groupID,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.getMessageManager().clearGroupHistoryMessage(groupID: groupID);
|
||||||
.getMessageManager()
|
|
||||||
.clearGroupHistoryMessage(groupID: groupID);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -482,10 +405,8 @@ class MessageServiceImpl extends MessageService {
|
||||||
await Future.delayed(const Duration(milliseconds: 500));
|
await Future.delayed(const Duration(milliseconds: 500));
|
||||||
} while (attempts < retries);
|
} while (attempts < retries);
|
||||||
|
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -495,13 +416,11 @@ class MessageServiceImpl extends MessageService {
|
||||||
required String userID,
|
required String userID,
|
||||||
}) {
|
}) {
|
||||||
return _retryMarkMessageAsRead(action: () {
|
return _retryMarkMessageAsRead(action: () {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getConversationManager().cleanConversationUnreadMessageCount(
|
||||||
.getConversationManager()
|
conversationID: "${TUIConversationViewModel.conversationC2CPrefix}$userID",
|
||||||
.cleanConversationUnreadMessageCount(
|
cleanTimestamp: 0,
|
||||||
conversationID: "${TUIConversationViewModel.conversationC2CPrefix}$userID",
|
cleanSequence: 0,
|
||||||
cleanTimestamp: 0,
|
);
|
||||||
cleanSequence: 0,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -510,22 +429,18 @@ class MessageServiceImpl extends MessageService {
|
||||||
required String groupID,
|
required String groupID,
|
||||||
}) {
|
}) {
|
||||||
return _retryMarkMessageAsRead(action: () {
|
return _retryMarkMessageAsRead(action: () {
|
||||||
return TencentImSDKPlugin.v2TIMManager
|
return TencentImSDKPlugin.v2TIMManager.getConversationManager().cleanConversationUnreadMessageCount(
|
||||||
.getConversationManager()
|
conversationID: "${TUIConversationViewModel.conversationGroupPrefix}$groupID",
|
||||||
.cleanConversationUnreadMessageCount(
|
cleanTimestamp: 0,
|
||||||
conversationID: "${TUIConversationViewModel.conversationGroupPrefix}$groupID",
|
cleanSequence: 0,
|
||||||
cleanTimestamp: 0,
|
);
|
||||||
cleanSequence: 0,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> removeAdvancedMsgListener(
|
Future<void> removeAdvancedMsgListener({V2TimAdvancedMsgListener? listener}) async {
|
||||||
{V2TimAdvancedMsgListener? listener}) async {
|
final result =
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
await TencentImSDKPlugin.v2TIMManager.getMessageManager().removeAdvancedMsgListener(listener: listener);
|
||||||
.getMessageManager()
|
|
||||||
.removeAdvancedMsgListener(listener: listener);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -533,16 +448,11 @@ class MessageServiceImpl extends MessageService {
|
||||||
Future<List<V2TimMessage>?> downloadMergerMessage({
|
Future<List<V2TimMessage>?> downloadMergerMessage({
|
||||||
required String msgID,
|
required String msgID,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().downloadMergerMessage(msgID: msgID);
|
||||||
.getMessageManager()
|
|
||||||
.downloadMergerMessage(msgID: msgID);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -550,16 +460,11 @@ class MessageServiceImpl extends MessageService {
|
||||||
Future<V2TimMsgCreateInfoResult?> createForwardMessage({
|
Future<V2TimMsgCreateInfoResult?> createForwardMessage({
|
||||||
required String msgID,
|
required String msgID,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().createForwardMessage(msgID: msgID);
|
||||||
.getMessageManager()
|
|
||||||
.createForwardMessage(msgID: msgID);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -570,62 +475,40 @@ class MessageServiceImpl extends MessageService {
|
||||||
required List<String> abstractList,
|
required List<String> abstractList,
|
||||||
required String compatibleText,
|
required String compatibleText,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().createMergerMessage(
|
||||||
.getMessageManager()
|
msgIDList: msgIDList, title: title, abstractList: abstractList, compatibleText: compatibleText);
|
||||||
.createMergerMessage(
|
|
||||||
msgIDList: msgIDList,
|
|
||||||
title: title,
|
|
||||||
abstractList: abstractList,
|
|
||||||
compatibleText: compatibleText);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimCallback> deleteMessages(
|
Future<V2TimCallback> deleteMessages({required List<String> msgIDs, List<dynamic>? webMessageInstanceList}) async {
|
||||||
{required List<String> msgIDs,
|
|
||||||
List<dynamic>? webMessageInstanceList}) async {
|
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.deleteMessages(
|
.deleteMessages(msgIDs: msgIDs, webMessageInstanceList: webMessageInstanceList);
|
||||||
msgIDs: msgIDs, webMessageInstanceList: webMessageInstanceList);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimMsgCreateInfoResult?> createVideoMessage(
|
Future<V2TimMsgCreateInfoResult?> createVideoMessage(
|
||||||
{String? videoPath,
|
{String? videoPath, String? type, int? duration, String? snapshotPath, dynamic inputElement}) async {
|
||||||
String? type,
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().createVideoMessage(
|
||||||
int? duration,
|
videoFilePath: videoPath ?? "",
|
||||||
String? snapshotPath,
|
type: type ?? "",
|
||||||
dynamic inputElement}) async {
|
duration: duration ?? 1,
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
snapshotPath: snapshotPath ?? "",
|
||||||
.getMessageManager()
|
inputElement: inputElement);
|
||||||
.createVideoMessage(
|
|
||||||
videoFilePath: videoPath ?? "",
|
|
||||||
type: type ?? "",
|
|
||||||
duration: duration ?? 1,
|
|
||||||
snapshotPath: snapshotPath ?? "",
|
|
||||||
inputElement: inputElement);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -638,75 +521,54 @@ class MessageServiceImpl extends MessageService {
|
||||||
bool needReadReceipt = false,
|
bool needReadReceipt = false,
|
||||||
required V2TimMessage replyMessage, // 被回复的消息
|
required V2TimMessage replyMessage, // 被回复的消息
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager.getMessageManager().sendReplyMessage(
|
||||||
.getMessageManager()
|
id: id,
|
||||||
.sendReplyMessage(
|
receiver: receiver,
|
||||||
id: id,
|
offlinePushInfo: offlinePushInfo,
|
||||||
receiver: receiver,
|
groupID: groupID,
|
||||||
offlinePushInfo: offlinePushInfo,
|
needReadReceipt: needReadReceipt,
|
||||||
groupID: groupID,
|
replyMessage: replyMessage);
|
||||||
needReadReceipt: needReadReceipt,
|
|
||||||
replyMessage: replyMessage);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimMsgCreateInfoResult?> createFileMessage(
|
Future<V2TimMsgCreateInfoResult?> createFileMessage(
|
||||||
{String? filePath,
|
{String? filePath, required String fileName, dynamic inputElement}) async {
|
||||||
required String fileName,
|
|
||||||
dynamic inputElement}) async {
|
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.createFileMessage(
|
.createFileMessage(filePath: filePath ?? "", fileName: fileName, inputElement: inputElement);
|
||||||
filePath: filePath ?? "",
|
|
||||||
fileName: fileName,
|
|
||||||
inputElement: inputElement);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimMsgCreateInfoResult?> createLocationMessage(
|
Future<V2TimMsgCreateInfoResult?> createLocationMessage(
|
||||||
{required String desc,
|
{required String desc, required double longitude, required double latitude}) async {
|
||||||
required double longitude,
|
|
||||||
required double latitude}) async {
|
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.createLocationMessage(
|
.createLocationMessage(desc: desc, longitude: longitude, latitude: latitude);
|
||||||
desc: desc, longitude: longitude, latitude: latitude);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimValueCallback<V2TimMessageSearchResult>> searchLocalMessages(
|
Future<V2TimValueCallback<V2TimMessageSearchResult>> searchLocalMessages(
|
||||||
{required V2TimMessageSearchParam searchParam}) async {
|
{required V2TimMessageSearchParam searchParam}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result =
|
||||||
.getMessageManager()
|
await TencentImSDKPlugin.v2TIMManager.getMessageManager().searchLocalMessages(searchParam: searchParam);
|
||||||
.searchLocalMessages(searchParam: searchParam);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -715,30 +577,22 @@ class MessageServiceImpl extends MessageService {
|
||||||
Future<List<V2TimMessage>?> findMessages({
|
Future<List<V2TimMessage>?> findMessages({
|
||||||
required List<String> messageIDList,
|
required List<String> messageIDList,
|
||||||
}) async {
|
}) async {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getMessageManager().findMessages(messageIDList: messageIDList);
|
||||||
.getMessageManager()
|
|
||||||
.findMessages(messageIDList: messageIDList);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: res.desc, errorCode: res.code));
|
||||||
type: TIMCallbackType.API_ERROR,
|
|
||||||
errorMsg: res.desc,
|
|
||||||
errorCode: res.code));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimCallback> setLocalCustomInt(
|
Future<V2TimCallback> setLocalCustomInt({required String msgID, required int localCustomInt}) async {
|
||||||
{required String msgID, required int localCustomInt}) async {
|
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.setLocalCustomInt(msgID: msgID, localCustomInt: localCustomInt);
|
.setLocalCustomInt(msgID: msgID, localCustomInt: localCustomInt);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -752,10 +606,8 @@ class MessageServiceImpl extends MessageService {
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.setC2CReceiveMessageOpt(userIDList: userIDList, opt: opt);
|
.setC2CReceiveMessageOpt(userIDList: userIDList, opt: opt);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -765,96 +617,68 @@ class MessageServiceImpl extends MessageService {
|
||||||
required String groupID,
|
required String groupID,
|
||||||
required ReceiveMsgOptEnum opt,
|
required ReceiveMsgOptEnum opt,
|
||||||
}) async {
|
}) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result =
|
||||||
.getMessageManager()
|
await TencentImSDKPlugin.v2TIMManager.getMessageManager().setGroupReceiveMessageOpt(groupID: groupID, opt: opt);
|
||||||
.setGroupReceiveMessageOpt(groupID: groupID, opt: opt);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimValueCallback<V2TimMessageChangeInfo>> modifyMessage(
|
Future<V2TimValueCallback<V2TimMessageChangeInfo>> modifyMessage({required V2TimMessage message}) async {
|
||||||
{required V2TimMessage message}) async {
|
final result = await TencentImSDKPlugin.v2TIMManager.getMessageManager().modifyMessage(message: message);
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
|
||||||
.getMessageManager()
|
|
||||||
.modifyMessage(message: message);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimCallback> setLocalCustomData(
|
Future<V2TimCallback> setLocalCustomData({required String msgID, required String localCustomData}) async {
|
||||||
{required String msgID, required String localCustomData}) async {
|
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.setLocalCustomData(msgID: msgID, localCustomData: localCustomData);
|
.setLocalCustomData(msgID: msgID, localCustomData: localCustomData);
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimValueCallback<V2TimMessageOnlineUrl>> getMessageOnlineUrl(
|
Future<V2TimValueCallback<V2TimMessageOnlineUrl>> getMessageOnlineUrl({required String msgID}) async {
|
||||||
{required String msgID}) async {
|
final result = await TencentImSDKPlugin.v2TIMManager.getMessageManager().getMessageOnlineUrl(msgID: msgID);
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
|
||||||
.getMessageManager()
|
|
||||||
.getMessageOnlineUrl(msgID: msgID);
|
|
||||||
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<V2TimCallback> downloadMessage(
|
Future<V2TimCallback> downloadMessage(
|
||||||
{required String msgID,
|
{required String msgID, required int messageType, required int imageType, required bool isSnapshot}) async {
|
||||||
required int messageType,
|
|
||||||
required int imageType,
|
|
||||||
required bool isSnapshot}) async {
|
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result = await TencentImSDKPlugin.v2TIMManager
|
||||||
.getMessageManager()
|
.getMessageManager()
|
||||||
.downloadMessage(
|
.downloadMessage(msgID: msgID, messageType: messageType, imageType: imageType, isSnapshot: isSnapshot);
|
||||||
msgID: msgID,
|
|
||||||
messageType: messageType,
|
|
||||||
imageType: imageType,
|
|
||||||
isSnapshot: isSnapshot);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<String> translateText(String text, String target) async {
|
Future<String> translateText(String text, String target) async {
|
||||||
final result = await TencentImSDKPlugin.v2TIMManager
|
final result =
|
||||||
.getMessageManager()
|
await TencentImSDKPlugin.v2TIMManager.getMessageManager().translateText(texts: [text], targetLanguage: target);
|
||||||
.translateText(texts: [text], targetLanguage: target);
|
|
||||||
if (result.code != 0) {
|
if (result.code != 0) {
|
||||||
_coreService.callOnCallback(TIMCallback(
|
_coreService
|
||||||
type: TIMCallbackType.API_ERROR,
|
.callOnCallback(TIMCallback(type: TIMCallbackType.API_ERROR, errorMsg: result.desc, errorCode: result.code));
|
||||||
errorMsg: result.desc,
|
|
||||||
errorCode: result.code));
|
|
||||||
}
|
}
|
||||||
return result.data?[text] ?? "";
|
return result.data?[text] ?? "";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,28 @@ import 'package:tencent_cloud_chat_sdk/enum/history_msg_get_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_priority_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_priority_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/receive_message_opt_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/receive_message_opt_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_message_read_member_list.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_message_read_member_list.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_message_read_member_list.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_list_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_online_url.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_receipt.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_param.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_change_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_list_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_msg_create_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_list_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_online_url.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_online_url.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_receipt.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_receipt.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_search_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_msg_create_info_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_msg_create_info_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
|
|
||||||
class MessageListResponse {
|
class MessageListResponse {
|
||||||
final bool haveMoreData;
|
final bool haveMoreData;
|
||||||
|
|
@ -26,8 +37,7 @@ class MessageListResponse {
|
||||||
|
|
||||||
abstract class MessageService {
|
abstract class MessageService {
|
||||||
Future<List<V2TimMessage>> getHistoryMessageList({
|
Future<List<V2TimMessage>> getHistoryMessageList({
|
||||||
HistoryMsgGetTypeEnum getType =
|
HistoryMsgGetTypeEnum getType = HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
||||||
HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
|
||||||
String? userID,
|
String? userID,
|
||||||
String? groupID,
|
String? groupID,
|
||||||
int lastMsgSeq,
|
int lastMsgSeq,
|
||||||
|
|
@ -37,8 +47,7 @@ abstract class MessageService {
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimMessageListResult?> getHistoryMessageListWithComplete({
|
Future<V2TimMessageListResult?> getHistoryMessageListWithComplete({
|
||||||
HistoryMsgGetTypeEnum getType =
|
HistoryMsgGetTypeEnum getType = HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
||||||
HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
|
||||||
String? userID,
|
String? userID,
|
||||||
String? groupID,
|
String? groupID,
|
||||||
int lastMsgSeq,
|
int lastMsgSeq,
|
||||||
|
|
@ -48,8 +57,7 @@ abstract class MessageService {
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<MessageListResponse> getHistoryMessageListV2({
|
Future<MessageListResponse> getHistoryMessageListV2({
|
||||||
HistoryMsgGetTypeEnum getType =
|
HistoryMsgGetTypeEnum getType = HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
||||||
HistoryMsgGetTypeEnum.V2TIM_GET_LOCAL_OLDER_MSG,
|
|
||||||
String? userID,
|
String? userID,
|
||||||
String? groupID,
|
String? groupID,
|
||||||
int lastMsgSeq,
|
int lastMsgSeq,
|
||||||
|
|
@ -70,13 +78,11 @@ abstract class MessageService {
|
||||||
|
|
||||||
Future<V2TimMsgCreateInfoResult?> createTextMessage({required String text});
|
Future<V2TimMsgCreateInfoResult?> createTextMessage({required String text});
|
||||||
|
|
||||||
Future<V2TimMsgCreateInfoResult?> createFaceMessage(
|
Future<V2TimMsgCreateInfoResult?> createFaceMessage({required int index, required String data});
|
||||||
{required int index, required String data});
|
|
||||||
|
|
||||||
Future<V2TimMsgCreateInfoResult?> createCustomMessage({required String data});
|
Future<V2TimMsgCreateInfoResult?> createCustomMessage({required String data});
|
||||||
|
|
||||||
Future<V2TimMsgCreateInfoResult?> createTextAtMessage(
|
Future<V2TimMsgCreateInfoResult?> createTextAtMessage({required String text, required List<String> atUserList});
|
||||||
{required String text, required List<String> atUserList});
|
|
||||||
|
|
||||||
Future<V2TimValueCallback<V2TimMessage>> sendMessage(
|
Future<V2TimValueCallback<V2TimMessage>> sendMessage(
|
||||||
{required String id, // 自己创建的ID
|
{required String id, // 自己创建的ID
|
||||||
|
|
@ -100,30 +106,20 @@ abstract class MessageService {
|
||||||
required V2TimMessage replyMessage, // 被回复的消息
|
required V2TimMessage replyMessage, // 被回复的消息
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimValueCallback<V2TimMessage>> reSendMessage(
|
Future<V2TimValueCallback<V2TimMessage>> reSendMessage({required String msgID, bool onlineUserOnly});
|
||||||
{required String msgID,
|
|
||||||
bool onlineUserOnly});
|
|
||||||
|
|
||||||
Future<V2TimValueCallback<V2TimMessageChangeInfo>> modifyMessage(
|
Future<V2TimValueCallback<V2TimMessageChangeInfo>> modifyMessage({required V2TimMessage message});
|
||||||
{required V2TimMessage message});
|
|
||||||
|
|
||||||
Future<V2TimMsgCreateInfoResult?> createImageMessage(
|
Future<V2TimMsgCreateInfoResult?> createImageMessage({String? imageName, String? imagePath, dynamic inputElement});
|
||||||
{String? imageName, String? imagePath, dynamic inputElement});
|
|
||||||
|
|
||||||
Future<V2TimMsgCreateInfoResult?> createVideoMessage(
|
Future<V2TimMsgCreateInfoResult?> createVideoMessage(
|
||||||
{String? videoPath = "",
|
{String? videoPath = "", String? type = "", int? duration = 0, String? snapshotPath = "", dynamic inputElement});
|
||||||
String? type = "",
|
|
||||||
int? duration = 0,
|
|
||||||
String? snapshotPath = "",
|
|
||||||
dynamic inputElement});
|
|
||||||
|
|
||||||
Future<V2TimMsgCreateInfoResult?> createFileMessage(
|
Future<V2TimMsgCreateInfoResult?> createFileMessage(
|
||||||
{String? filePath, required String fileName, dynamic inputElement});
|
{String? filePath, required String fileName, dynamic inputElement});
|
||||||
|
|
||||||
Future<V2TimMsgCreateInfoResult?> createLocationMessage(
|
Future<V2TimMsgCreateInfoResult?> createLocationMessage(
|
||||||
{required String desc,
|
{required String desc, required double longitude, required double latitude});
|
||||||
required double longitude,
|
|
||||||
required double latitude});
|
|
||||||
|
|
||||||
Future<V2TimMsgCreateInfoResult?> createSoundMessage({
|
Future<V2TimMsgCreateInfoResult?> createSoundMessage({
|
||||||
required String soundPath,
|
required String soundPath,
|
||||||
|
|
@ -146,8 +142,7 @@ abstract class MessageService {
|
||||||
Object? webMessageInstance,
|
Object? webMessageInstance,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimCallback> revokeMessage(
|
Future<V2TimCallback> revokeMessage({required String msgID, Object? webMessageInstance});
|
||||||
{required String msgID, Object? webMessageInstance});
|
|
||||||
|
|
||||||
Future<V2TimCallback> clearC2CHistoryMessage({
|
Future<V2TimCallback> clearC2CHistoryMessage({
|
||||||
required String userID,
|
required String userID,
|
||||||
|
|
@ -171,8 +166,7 @@ abstract class MessageService {
|
||||||
required String msgID,
|
required String msgID,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimCallback> deleteMessages(
|
Future<V2TimCallback> deleteMessages({required List<String> msgIDs, List<dynamic>? webMessageInstanceList});
|
||||||
{required List<String> msgIDs, List<dynamic>? webMessageInstanceList});
|
|
||||||
|
|
||||||
Future<List<V2TimMessage>?> findMessages({
|
Future<List<V2TimMessage>?> findMessages({
|
||||||
required List<String> messageIDList,
|
required List<String> messageIDList,
|
||||||
|
|
@ -182,11 +176,9 @@ abstract class MessageService {
|
||||||
required V2TimMessageSearchParam searchParam,
|
required V2TimMessageSearchParam searchParam,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimCallback> setLocalCustomInt(
|
Future<V2TimCallback> setLocalCustomInt({required String msgID, required int localCustomInt});
|
||||||
{required String msgID, required int localCustomInt});
|
|
||||||
|
|
||||||
Future<V2TimCallback> setLocalCustomData(
|
Future<V2TimCallback> setLocalCustomData({required String msgID, required String localCustomData});
|
||||||
{required String msgID, required String localCustomData});
|
|
||||||
|
|
||||||
Future<V2TimCallback> setC2CReceiveMessageOpt({
|
Future<V2TimCallback> setC2CReceiveMessageOpt({
|
||||||
required List<String> userIDList,
|
required List<String> userIDList,
|
||||||
|
|
@ -198,8 +190,7 @@ abstract class MessageService {
|
||||||
required ReceiveMsgOptEnum opt,
|
required ReceiveMsgOptEnum opt,
|
||||||
});
|
});
|
||||||
|
|
||||||
Future<V2TimValueCallback<V2TimGroupMessageReadMemberList>>
|
Future<V2TimValueCallback<V2TimGroupMessageReadMemberList>> getGroupMessageReadMemberList({
|
||||||
getGroupMessageReadMemberList({
|
|
||||||
required String messageID,
|
required String messageID,
|
||||||
required GetGroupMessageReadMemberListFilter filter,
|
required GetGroupMessageReadMemberListFilter filter,
|
||||||
int nextSeq = 0,
|
int nextSeq = 0,
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,14 @@ import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/history_msg_get_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/history_msg_get_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_priority_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_priority_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
||||||
|
|
@ -18,8 +22,7 @@ class TIMUIKitChatController {
|
||||||
late TUIChatSeparateViewModel? model;
|
late TUIChatSeparateViewModel? model;
|
||||||
late TIMUIKitInputTextFieldController? textFieldController;
|
late TIMUIKitInputTextFieldController? textFieldController;
|
||||||
late AutoScrollController? scrollController;
|
late AutoScrollController? scrollController;
|
||||||
final TUIChatGlobalModel globalChatModel =
|
final TUIChatGlobalModel globalChatModel = serviceLocator<TUIChatGlobalModel>();
|
||||||
serviceLocator<TUIChatGlobalModel>();
|
|
||||||
|
|
||||||
TIMUIKitChatController({TUIChatSeparateViewModel? viewModel}) {
|
TIMUIKitChatController({TUIChatSeparateViewModel? viewModel}) {
|
||||||
if (viewModel != null) {
|
if (viewModel != null) {
|
||||||
|
|
@ -28,8 +31,7 @@ class TIMUIKitChatController {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> loadHistoryMessageList(
|
Future<bool> loadHistoryMessageList(
|
||||||
{HistoryMsgGetTypeEnum getType =
|
{HistoryMsgGetTypeEnum getType = HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_OLDER_MSG,
|
||||||
HistoryMsgGetTypeEnum.V2TIM_GET_CLOUD_OLDER_MSG,
|
|
||||||
String? userID,
|
String? userID,
|
||||||
String? groupID,
|
String? groupID,
|
||||||
int lastMsgSeq = -1,
|
int lastMsgSeq = -1,
|
||||||
|
|
@ -59,16 +61,15 @@ class TIMUIKitChatController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Refresh the history message list manually;
|
/// Refresh the history message list manually;
|
||||||
Future<bool> refreshCurrentHistoryList(
|
Future<bool> refreshCurrentHistoryList([String? convID, ConvType? convType]) async {
|
||||||
[String? convID, ConvType? convType]) async {
|
if (model != null) {
|
||||||
if(model != null){
|
try {
|
||||||
try{
|
|
||||||
scrollController?.animateTo(
|
scrollController?.animateTo(
|
||||||
scrollController!.position.minScrollExtent,
|
scrollController!.position.minScrollExtent,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
curve: Curves.ease,
|
curve: Curves.ease,
|
||||||
);
|
);
|
||||||
}catch(e){}
|
} catch (e) {}
|
||||||
return model!.loadDataFromController();
|
return model!.loadDataFromController();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -150,13 +151,13 @@ class TIMUIKitChatController {
|
||||||
assert(groupID != null || convType != ConvType.group);
|
assert(groupID != null || convType != ConvType.group);
|
||||||
assert(userID != null || convType != ConvType.c2c);
|
assert(userID != null || convType != ConvType.c2c);
|
||||||
if (isNavigateToMessageListBottom && scrollController != null) {
|
if (isNavigateToMessageListBottom && scrollController != null) {
|
||||||
try{
|
try {
|
||||||
scrollController?.animateTo(
|
scrollController?.animateTo(
|
||||||
scrollController!.position.minScrollExtent,
|
scrollController!.position.minScrollExtent,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
curve: Curves.ease,
|
curve: Curves.ease,
|
||||||
);
|
);
|
||||||
}catch(e){}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
return globalChatModel.sendMessageFromController(
|
return globalChatModel.sendMessageFromController(
|
||||||
priority: priority,
|
priority: priority,
|
||||||
|
|
@ -173,13 +174,13 @@ class TIMUIKitChatController {
|
||||||
} else if (model != null) {
|
} else if (model != null) {
|
||||||
/// Sends a message to the current conversation specified on `TIMUIKitChat`. 发送到 `TIMUIKitChat` 中指定的当前对话。
|
/// Sends a message to the current conversation specified on `TIMUIKitChat`. 发送到 `TIMUIKitChat` 中指定的当前对话。
|
||||||
if (isNavigateToMessageListBottom && scrollController != null) {
|
if (isNavigateToMessageListBottom && scrollController != null) {
|
||||||
try{
|
try {
|
||||||
scrollController?.animateTo(
|
scrollController?.animateTo(
|
||||||
scrollController!.position.minScrollExtent,
|
scrollController!.position.minScrollExtent,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
curve: Curves.ease,
|
curve: Curves.ease,
|
||||||
);
|
);
|
||||||
}catch(e){}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
return model!.sendMessageFromController(
|
return model!.sendMessageFromController(
|
||||||
priority: priority,
|
priority: priority,
|
||||||
|
|
@ -245,13 +246,13 @@ class TIMUIKitChatController {
|
||||||
assert(groupID != null || convType != ConvType.group);
|
assert(groupID != null || convType != ConvType.group);
|
||||||
assert(userID != null || convType != ConvType.c2c);
|
assert(userID != null || convType != ConvType.c2c);
|
||||||
if (isNavigateToMessageListBottom && scrollController != null) {
|
if (isNavigateToMessageListBottom && scrollController != null) {
|
||||||
try{
|
try {
|
||||||
scrollController?.animateTo(
|
scrollController?.animateTo(
|
||||||
scrollController!.position.minScrollExtent,
|
scrollController!.position.minScrollExtent,
|
||||||
duration: const Duration(milliseconds: 200),
|
duration: const Duration(milliseconds: 200),
|
||||||
curve: Curves.ease,
|
curve: Curves.ease,
|
||||||
);
|
);
|
||||||
}catch(e){}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
return globalChatModel.sendReplyMessageFromController(
|
return globalChatModel.sendReplyMessageFromController(
|
||||||
text: messageText,
|
text: messageText,
|
||||||
|
|
@ -307,34 +308,27 @@ class TIMUIKitChatController {
|
||||||
required BuildContext context,
|
required BuildContext context,
|
||||||
}) async {
|
}) async {
|
||||||
return model?.sendMergerMessage(
|
return model?.sendMergerMessage(
|
||||||
conversationList: conversationList,
|
conversationList: conversationList, title: title, abstractList: abstractList, context: context);
|
||||||
title: title,
|
|
||||||
abstractList: abstractList,
|
|
||||||
context: context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set local custom data; returns the bool shows if succeed.
|
/// Set local custom data; returns the bool shows if succeed.
|
||||||
/// Please provide `convID`, if you use `TIMUIKitChatController` without specifying to a `TIMUIKitChat`.
|
/// Please provide `convID`, if you use `TIMUIKitChatController` without specifying to a `TIMUIKitChat`.
|
||||||
Future<bool> setLocalCustomData(String msgID, String localCustomData,
|
Future<bool> setLocalCustomData(String msgID, String localCustomData, [String? convID]) async {
|
||||||
[String? convID]) async {
|
|
||||||
final String? conversationID = convID ?? model?.conversationID;
|
final String? conversationID = convID ?? model?.conversationID;
|
||||||
if (conversationID == null) {
|
if (conversationID == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return globalChatModel.setLocalCustomData(
|
return globalChatModel.setLocalCustomData(msgID, localCustomData, conversationID);
|
||||||
msgID, localCustomData, conversationID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set local custom int; returns the bool shows if succeed.
|
/// Set local custom int; returns the bool shows if succeed.
|
||||||
/// Please provide `convID`, if you use `TIMUIKitChatController` without specifying to a `TIMUIKitChat`.
|
/// Please provide `convID`, if you use `TIMUIKitChatController` without specifying to a `TIMUIKitChat`.
|
||||||
Future<bool> setLocalCustomInt(String msgID, int localCustomInt,
|
Future<bool> setLocalCustomInt(String msgID, int localCustomInt, [String? convID]) async {
|
||||||
[String? convID]) async {
|
|
||||||
final String? conversationID = convID ?? model?.conversationID;
|
final String? conversationID = convID ?? model?.conversationID;
|
||||||
if (conversationID == null) {
|
if (conversationID == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return globalChatModel.setLocalCustomInt(
|
return globalChatModel.setLocalCustomInt(msgID, localCustomInt, conversationID);
|
||||||
msgID, localCustomInt, conversationID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get current conversation, returns UserID or GroupID if in the chat page, returns "" if not.
|
/// Get current conversation, returns UserID or GroupID if in the chat page, returns "" if not.
|
||||||
|
|
@ -350,8 +344,7 @@ class TIMUIKitChatController {
|
||||||
|
|
||||||
/// Mention or @ other members in a group manually.
|
/// Mention or @ other members in a group manually.
|
||||||
/// This function solely works when `TIMUIKitChatController` is specified for use within a `TIMUIKitChat`.
|
/// This function solely works when `TIMUIKitChatController` is specified for use within a `TIMUIKitChat`.
|
||||||
void mentionOtherMemberInGroup(
|
void mentionOtherMemberInGroup({required String showNameInMessage, required String userID}) {
|
||||||
{required String showNameInMessage, required String userID}) {
|
|
||||||
textFieldController?.longPressToAt(showNameInMessage, userID);
|
textFieldController?.longPressToAt(showNameInMessage, userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,9 +364,7 @@ class TIMUIKitChatController {
|
||||||
/// This function solely works when `TIMUIKitChatController` is specified for use within a `TIMUIKitChat`.
|
/// This function solely works when `TIMUIKitChatController` is specified for use within a `TIMUIKitChat`.
|
||||||
List<V2TimGroupMemberFullInfo> getGroupMemberList({String? keyword}) {
|
List<V2TimGroupMemberFullInfo> getGroupMemberList({String? keyword}) {
|
||||||
final List<V2TimGroupMemberFullInfo> memberList =
|
final List<V2TimGroupMemberFullInfo> memberList =
|
||||||
(model?.groupMemberList ?? [])
|
(model?.groupMemberList ?? []).whereType<V2TimGroupMemberFullInfo>().toList();
|
||||||
.whereType<V2TimGroupMemberFullInfo>()
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
return TencentUtils.checkString(keyword) == null
|
return TencentUtils.checkString(keyword) == null
|
||||||
? memberList
|
? memberList
|
||||||
|
|
@ -381,9 +372,7 @@ class TIMUIKitChatController {
|
||||||
final userID = e.userID;
|
final userID = e.userID;
|
||||||
final nickName = e.nickName ?? "";
|
final nickName = e.nickName ?? "";
|
||||||
final friendRemark = e.friendRemark ?? "";
|
final friendRemark = e.friendRemark ?? "";
|
||||||
return userID.contains(keyword!) ||
|
return userID.contains(keyword!) || nickName.contains(keyword) || friendRemark.contains(keyword);
|
||||||
nickName.contains(keyword) ||
|
|
||||||
friendRemark.contains(keyword);
|
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_conversation_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_conversation_view_model.dart';
|
||||||
|
|
||||||
class TIMUIKitConversationController {
|
class TIMUIKitConversationController {
|
||||||
|
|
@ -36,22 +38,17 @@ class TIMUIKitConversationController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pin one conversation to the top
|
/// Pin one conversation to the top
|
||||||
Future<V2TimCallback> pinConversation(
|
Future<V2TimCallback> pinConversation({required String conversationID, required bool isPinned}) {
|
||||||
{required String conversationID, required bool isPinned}) {
|
return model.pinConversation(conversationID: conversationID, isPinned: isPinned);
|
||||||
return model.pinConversation(
|
|
||||||
conversationID: conversationID, isPinned: isPinned);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the draft for a conversation
|
/// Set the draft for a conversation
|
||||||
Future<V2TimCallback> setConversationDraft(
|
Future<V2TimCallback> setConversationDraft({required String conversationID, String? draftText}) {
|
||||||
{required String conversationID, String? draftText}) {
|
return model.setConversationDraft(conversationID: conversationID, draftText: draftText);
|
||||||
return model.setConversationDraft(
|
|
||||||
conversationID: conversationID, draftText: draftText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Clear the historical message in a specific conversation
|
/// Clear the historical message in a specific conversation
|
||||||
Future<V2TimCallback?>? clearHistoryMessage(
|
Future<V2TimCallback?>? clearHistoryMessage({required V2TimConversation conversation}) {
|
||||||
{required V2TimConversation conversation}) {
|
|
||||||
final convType = conversation.type;
|
final convType = conversation.type;
|
||||||
final convID = convType == 1 ? conversation.userID : conversation.groupID;
|
final convID = convType == 1 ? conversation.userID : conversation.groupID;
|
||||||
if (convType != null && convID != null) {
|
if (convType != null && convID != null) {
|
||||||
|
|
@ -72,7 +69,7 @@ class TIMUIKitConversationController {
|
||||||
|
|
||||||
/// Scroll to a specific conversation, this conversation must be existed in conversation list.
|
/// Scroll to a specific conversation, this conversation must be existed in conversation list.
|
||||||
/// If not exist, invoking `loadData` recursively, until find the target conversation.
|
/// If not exist, invoking `loadData` recursively, until find the target conversation.
|
||||||
scrollToConversation(String conversationID){
|
scrollToConversation(String conversationID) {
|
||||||
model.scrollToConversation = conversationID;
|
model.scrollToConversation = conversationID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_operation_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_operation_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_profile_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_profile_view_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/widgets/text_input_bottom_sheet.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/widgets/text_input_bottom_sheet.dart';
|
||||||
|
|
||||||
|
|
@ -27,8 +30,7 @@ class TIMUIKitProfileController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// add a user to block list
|
/// add a user to block list
|
||||||
Future<List<V2TimFriendOperationResult>?> addUserToBlackList(
|
Future<List<V2TimFriendOperationResult>?> addUserToBlackList(bool shouldAdd, String userID) {
|
||||||
bool shouldAdd, String userID) {
|
|
||||||
return model.addToBlackList(shouldAdd, userID);
|
return model.addToBlackList(shouldAdd, userID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,22 @@ import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_change_info_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_change_info_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_tips_elem_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_tips_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_change_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_change_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_change_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_tips_elem.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_image.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_tips_elem.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_tips_elem.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_image.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_image.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/constants/history_message_constant.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/constants/history_message_constant.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/constants/time.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/constants/time.dart';
|
||||||
|
|
@ -41,8 +49,7 @@ class MessageUtils {
|
||||||
// 是否是群组TRTC信息
|
// 是否是群组TRTC信息
|
||||||
static isGroupCallingMessage(V2TimMessage message) {
|
static isGroupCallingMessage(V2TimMessage message) {
|
||||||
final isGroup = message.groupID != null;
|
final isGroup = message.groupID != null;
|
||||||
final isCustomMessage =
|
final isCustomMessage = message.elemType == MessageElemType.V2TIM_ELEM_TYPE_CUSTOM;
|
||||||
message.elemType == MessageElemType.V2TIM_ELEM_TYPE_CUSTOM;
|
|
||||||
if (isCustomMessage) {
|
if (isCustomMessage) {
|
||||||
final customElemData = message.customElem?.data ?? "";
|
final customElemData = message.customElem?.data ?? "";
|
||||||
return isCallingData(customElemData) && isGroup;
|
return isCallingData(customElemData) && isGroup;
|
||||||
|
|
@ -70,8 +77,8 @@ class MessageUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String> _getGroupChangeType(V2TimGroupChangeInfo info,
|
static Future<String> _getGroupChangeType(
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList) async {
|
V2TimGroupChangeInfo info, List<V2TimGroupMemberFullInfo?> groupMemberList) async {
|
||||||
int? type = info.type;
|
int? type = info.type;
|
||||||
var value = info.value;
|
var value = info.value;
|
||||||
String s = TIM_t('群资料信息');
|
String s = TIM_t('群资料信息');
|
||||||
|
|
@ -93,22 +100,20 @@ class MessageUtils {
|
||||||
break;
|
break;
|
||||||
case GroupChangeInfoType.V2TIM_GROUP_INFO_CHANGE_TYPE_OWNER:
|
case GroupChangeInfoType.V2TIM_GROUP_INFO_CHANGE_TYPE_OWNER:
|
||||||
s = TIM_t("群主");
|
s = TIM_t("群主");
|
||||||
final V2TimGroupMemberFullInfo? groupMemberInfo = groupMemberList
|
final V2TimGroupMemberFullInfo? groupMemberInfo =
|
||||||
.firstWhereOrNull((element) => element?.userID == value);
|
groupMemberList.firstWhereOrNull((element) => element?.userID == value);
|
||||||
if (groupMemberInfo != null) {
|
if (groupMemberInfo != null) {
|
||||||
value = TencentUtils.checkString(groupMemberInfo.friendRemark) ??
|
value = TencentUtils.checkString(groupMemberInfo.friendRemark) ??
|
||||||
TencentUtils.checkString(groupMemberInfo.nameCard) ??
|
TencentUtils.checkString(groupMemberInfo.nameCard) ??
|
||||||
TencentUtils.checkString(groupMemberInfo.nickName) ??
|
TencentUtils.checkString(groupMemberInfo.nickName) ??
|
||||||
TencentUtils.checkString(groupMemberInfo.userID);
|
TencentUtils.checkString(groupMemberInfo.userID);
|
||||||
} else {
|
} else {
|
||||||
final res = await TencentImSDKPlugin.v2TIMManager
|
final res = await TencentImSDKPlugin.v2TIMManager.getUsersInfo(userIDList: [value ?? ""]);
|
||||||
.getUsersInfo(userIDList: [value ?? ""]);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
final List<V2TimUserFullInfo> data = res.data ?? [];
|
final List<V2TimUserFullInfo> data = res.data ?? [];
|
||||||
if (data.isNotEmpty) {
|
if (data.isNotEmpty) {
|
||||||
final firstPerson = data[0];
|
final firstPerson = data[0];
|
||||||
value = TencentUtils.checkString(firstPerson.nickName) ??
|
value = TencentUtils.checkString(firstPerson.nickName) ?? TencentUtils.checkString(firstPerson.userID);
|
||||||
TencentUtils.checkString(firstPerson.userID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -126,15 +131,14 @@ class MessageUtils {
|
||||||
|
|
||||||
final String option8 = s;
|
final String option8 = s;
|
||||||
if (value != null && value.isNotEmpty) {
|
if (value != null && value.isNotEmpty) {
|
||||||
return TIM_t_para("{{option8}}为 ", "$option8为 ")(option8: option8) +
|
return TIM_t_para("{{option8}}为 ", "$option8为 ")(option8: option8) + value;
|
||||||
value;
|
|
||||||
} else {
|
} else {
|
||||||
return option8;
|
return option8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static String? _getOpUserNick(V2TimGroupMemberInfo? opUser) {
|
static String? _getOpUserNick(V2TimGroupMemberInfo? opUser) {
|
||||||
if(opUser == null){
|
if (opUser == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return TencentUtils.checkString(opUser.friendRemark) ??
|
return TencentUtils.checkString(opUser.friendRemark) ??
|
||||||
|
|
@ -160,8 +164,7 @@ class MessageUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<String> groupTipsMessageAbstract(
|
static Future<String> groupTipsMessageAbstract(
|
||||||
V2TimGroupTipsElem groupTipsElem,
|
V2TimGroupTipsElem groupTipsElem, List<V2TimGroupMemberFullInfo?> groupMemberList) async {
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList) async {
|
|
||||||
String displayMessage;
|
String displayMessage;
|
||||||
final operationType = groupTipsElem.type;
|
final operationType = groupTipsElem.type;
|
||||||
final operationMember = groupTipsElem.opMember;
|
final operationMember = groupTipsElem.opMember;
|
||||||
|
|
@ -175,8 +178,7 @@ class MessageUtils {
|
||||||
bool changedValue = false;
|
bool changedValue = false;
|
||||||
for (V2TimGroupChangeInfo? element in groupChangeInfoList) {
|
for (V2TimGroupChangeInfo? element in groupChangeInfoList) {
|
||||||
final newText = await _getGroupChangeType(element!, groupMemberList);
|
final newText = await _getGroupChangeType(element!, groupMemberList);
|
||||||
changedInfoString +=
|
changedInfoString += (changedInfoString.isEmpty ? "" : " / ") + newText;
|
||||||
(changedInfoString.isEmpty ? "" : " / ") + newText;
|
|
||||||
changedValue = element!.boolValue ?? false;
|
changedValue = element!.boolValue ?? false;
|
||||||
}
|
}
|
||||||
if (changedInfoString.isEmpty) {
|
if (changedInfoString.isEmpty) {
|
||||||
|
|
@ -184,73 +186,56 @@ class MessageUtils {
|
||||||
}
|
}
|
||||||
if (changedInfoString == TIM_t("全员禁言状态")) {
|
if (changedInfoString == TIM_t("全员禁言状态")) {
|
||||||
changedInfoString = TIM_t("全员禁言");
|
changedInfoString = TIM_t("全员禁言");
|
||||||
displayMessage = changedValue == false ? TIM_t_para("{{option7}} 取消", "$option7 取消")(option7: option7) +
|
displayMessage = changedValue == false
|
||||||
changedInfoString : TIM_t_para("{{option7}} 开启", "$option7 开启")(option7: option7) +
|
? TIM_t_para("{{option7}} 取消", "$option7 取消")(option7: option7) + changedInfoString
|
||||||
changedInfoString;
|
: TIM_t_para("{{option7}} 开启", "$option7 开启")(option7: option7) + changedInfoString;
|
||||||
} else {
|
} else {
|
||||||
displayMessage =
|
displayMessage = TIM_t_para("{{option7}}修改", "$option7修改")(option7: option7) + changedInfoString;
|
||||||
TIM_t_para("{{option7}}修改", "$option7修改")(option7: option7) +
|
|
||||||
changedInfoString;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_QUIT:
|
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_QUIT:
|
||||||
final String? option6 = opUserNickName ?? "";
|
final String? option6 = opUserNickName ?? "";
|
||||||
displayMessage =
|
displayMessage = TIM_t_para("{{option6}}退出群聊", "$option6退出群聊")(option6: option6);
|
||||||
TIM_t_para("{{option6}}退出群聊", "$option6退出群聊")(option6: option6);
|
|
||||||
break;
|
break;
|
||||||
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_INVITE:
|
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_INVITE:
|
||||||
final option5 =
|
final option5 = memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
||||||
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
|
||||||
final inviteUser = _getOpUserNick(operationMember);
|
final inviteUser = _getOpUserNick(operationMember);
|
||||||
displayMessage = '$inviteUser' +
|
displayMessage = '$inviteUser' + TIM_t_para("邀请{{option5}}加入群组", "邀请$option5加入群组")(option5: option5);
|
||||||
TIM_t_para("邀请{{option5}}加入群组", "邀请$option5加入群组")(option5: option5);
|
|
||||||
break;
|
break;
|
||||||
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_KICKED:
|
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_KICKED:
|
||||||
final option4 =
|
final option4 = memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
||||||
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
|
||||||
final kickUser = _getOpUserNick(operationMember);
|
final kickUser = _getOpUserNick(operationMember);
|
||||||
displayMessage = '$kickUser' +
|
displayMessage = '$kickUser' + TIM_t_para("将{{option4}}踢出群组", "将$option4踢出群组")(option4: option4);
|
||||||
TIM_t_para("将{{option4}}踢出群组", "将$option4踢出群组")(option4: option4);
|
|
||||||
break;
|
break;
|
||||||
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_JOIN:
|
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_JOIN:
|
||||||
final option3 =
|
final option3 = memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
||||||
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
displayMessage = TIM_t_para("用户{{option3}}加入了群聊", "用户$option3加入了群聊")(option3: option3);
|
||||||
displayMessage = TIM_t_para("用户{{option3}}加入了群聊", "用户$option3加入了群聊")(
|
|
||||||
option3: option3);
|
|
||||||
break;
|
break;
|
||||||
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_MEMBER_INFO_CHANGE:
|
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_MEMBER_INFO_CHANGE:
|
||||||
displayMessage = groupTipsElem.memberList!.map((e) {
|
displayMessage = groupTipsElem.memberList!.map((e) {
|
||||||
final changedMember = groupTipsElem.memberChangeInfoList!
|
final changedMember =
|
||||||
.firstWhere((element) => element!.userID == e!.userID);
|
groupTipsElem.memberChangeInfoList!.firstWhere((element) => element!.userID == e!.userID);
|
||||||
final isMute = changedMember!.muteTime != 0;
|
final isMute = changedMember!.muteTime != 0;
|
||||||
final option2 = _getMemberNickName(e!);
|
final option2 = _getMemberNickName(e!);
|
||||||
final displayMessage = isMute ? TIM_t("禁言") : TIM_t("解除禁言");
|
final displayMessage = isMute ? TIM_t("禁言") : TIM_t("解除禁言");
|
||||||
return TIM_t_para("{{option2}} 被", "$option2 被")(option2: option2) +
|
return TIM_t_para("{{option2}} 被", "$option2 被")(option2: option2) + displayMessage;
|
||||||
displayMessage;
|
|
||||||
}).join("、");
|
}).join("、");
|
||||||
break;
|
break;
|
||||||
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_SET_ADMIN:
|
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_SET_ADMIN:
|
||||||
final adminMember =
|
final adminMember = memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
||||||
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
|
||||||
final opMember = _getOpUserNick(operationMember);
|
final opMember = _getOpUserNick(operationMember);
|
||||||
final option1 = adminMember;
|
final option1 = adminMember;
|
||||||
displayMessage = '$opMember' +
|
displayMessage = '$opMember' + TIM_t_para("将 {{option1}} 设置为管理员", "将 $option1 设置为管理员")(option1: option1);
|
||||||
TIM_t_para("将 {{option1}} 设置为管理员", "将 $option1 设置为管理员")(
|
|
||||||
option1: option1);
|
|
||||||
break;
|
break;
|
||||||
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_CANCEL_ADMIN:
|
case GroupTipsElemType.V2TIM_GROUP_TIPS_TYPE_CANCEL_ADMIN:
|
||||||
final adminMember =
|
final adminMember = memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
||||||
memberList!.map((e) => _getMemberNickName(e!).toString()).join("、");
|
|
||||||
final opMember = _getOpUserNick(operationMember);
|
final opMember = _getOpUserNick(operationMember);
|
||||||
final option1 = adminMember;
|
final option1 = adminMember;
|
||||||
displayMessage = '$opMember' +
|
displayMessage = '$opMember' + TIM_t_para("将 {{option1}} 取消管理员", "将 $option1 取消管理员")(option1: option1);
|
||||||
TIM_t_para("将 {{option1}} 取消管理员", "将 $option1 取消管理员")(
|
|
||||||
option1: option1);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
final String option2 = operationType.toString();
|
final String option2 = operationType.toString();
|
||||||
displayMessage =
|
displayMessage = TIM_t_para("系统消息 {{option2}}", "系统消息 $option2")(option2: option2);
|
||||||
TIM_t_para("系统消息 {{option2}}", "系统消息 $option2")(option2: option2);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return displayMessage;
|
return displayMessage;
|
||||||
|
|
@ -286,12 +271,10 @@ class MessageUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
static Widget wrapMessageTips(Widget child, TUITheme? theme) {
|
static Widget wrapMessageTips(Widget child, TUITheme? theme) {
|
||||||
return Container(
|
return Container(margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 30), child: child);
|
||||||
margin: const EdgeInsets.symmetric(vertical: 10, horizontal: 30), child: child);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getAbstractMessageAsync(V2TimMessage message,
|
static String getAbstractMessageAsync(V2TimMessage message, List<V2TimGroupMemberFullInfo?> groupMemberList) {
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList) {
|
|
||||||
final msgType = message.elemType;
|
final msgType = message.elemType;
|
||||||
switch (msgType) {
|
switch (msgType) {
|
||||||
case MessageElemType.V2TIM_ELEM_TYPE_CUSTOM:
|
case MessageElemType.V2TIM_ELEM_TYPE_CUSTOM:
|
||||||
|
|
@ -304,8 +287,7 @@ class MessageUtils {
|
||||||
return TIM_t("[表情]");
|
return TIM_t("[表情]");
|
||||||
case MessageElemType.V2TIM_ELEM_TYPE_FILE:
|
case MessageElemType.V2TIM_ELEM_TYPE_FILE:
|
||||||
final String? option2 = message.fileElem!.fileName ?? "";
|
final String? option2 = message.fileElem!.fileName ?? "";
|
||||||
return TIM_t_para("[文件] {{option2}}", "[文件] $option2")(
|
return TIM_t_para("[文件] {{option2}}", "[文件] $option2")(option2: option2);
|
||||||
option2: option2);
|
|
||||||
case MessageElemType.V2TIM_ELEM_TYPE_GROUP_TIPS:
|
case MessageElemType.V2TIM_ELEM_TYPE_GROUP_TIPS:
|
||||||
return TIM_t("群提示");
|
return TIM_t("群提示");
|
||||||
case MessageElemType.V2TIM_ELEM_TYPE_IMAGE:
|
case MessageElemType.V2TIM_ELEM_TYPE_IMAGE:
|
||||||
|
|
@ -321,15 +303,12 @@ class MessageUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static V2TimImage? getImageFromImgList(
|
static V2TimImage? getImageFromImgList(List<V2TimImage?>? list, List<String> order) {
|
||||||
List<V2TimImage?>? list, List<String> order) {
|
|
||||||
V2TimImage? img;
|
V2TimImage? img;
|
||||||
try {
|
try {
|
||||||
for (String type in order) {
|
for (String type in order) {
|
||||||
img = list?.firstWhere(
|
img =
|
||||||
(e) =>
|
list?.firstWhere((e) => e?.type == HistoryMessageDartConstant.V2_TIM_IMAGE_TYPES[type], orElse: () => null);
|
||||||
e?.type == HistoryMessageDartConstant.V2_TIM_IMAGE_TYPES[type],
|
|
||||||
orElse: () => null);
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
outputLogger.i('getImageFromImgList error ${e.toString()}');
|
outputLogger.i('getImageFromImgList error ${e.toString()}');
|
||||||
|
|
@ -345,16 +324,15 @@ class MessageUtils {
|
||||||
final displayName = friendRemark.isNotEmpty
|
final displayName = friendRemark.isNotEmpty
|
||||||
? friendRemark
|
? friendRemark
|
||||||
: nameCard.isNotEmpty
|
: nameCard.isNotEmpty
|
||||||
? nameCard
|
? nameCard
|
||||||
: nickName.isNotEmpty
|
: nickName.isNotEmpty
|
||||||
? nickName
|
? nickName
|
||||||
: sender;
|
: sender;
|
||||||
return displayName.toString();
|
return displayName.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<V2TimValueCallback<V2TimMessage>?> handleMessageError(
|
static Future<V2TimValueCallback<V2TimMessage>?> handleMessageError(
|
||||||
Future<V2TimValueCallback<V2TimMessage>?> fun,
|
Future<V2TimValueCallback<V2TimMessage>?> fun, BuildContext context) async {
|
||||||
BuildContext context) async {
|
|
||||||
final res = await fun;
|
final res = await fun;
|
||||||
return handleMessageErrorCode(res, context);
|
return handleMessageErrorCode(res, context);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_wide_modal_operation_key.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_wide_modal_operation_key.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/widgets/wide_popup.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/widgets/wide_popup.dart';
|
||||||
|
|
@ -44,32 +45,24 @@ class TIMUIKitAddFriend extends StatefulWidget {
|
||||||
class _TIMUIKitAddFriendState extends TIMUIKitState<TIMUIKitAddFriend> {
|
class _TIMUIKitAddFriendState extends TIMUIKitState<TIMUIKitAddFriend> {
|
||||||
final TextEditingController _controller = TextEditingController();
|
final TextEditingController _controller = TextEditingController();
|
||||||
final CoreServicesImpl _coreServicesImpl = serviceLocator<CoreServicesImpl>();
|
final CoreServicesImpl _coreServicesImpl = serviceLocator<CoreServicesImpl>();
|
||||||
final FriendshipServices _friendshipServices =
|
final FriendshipServices _friendshipServices = serviceLocator<FriendshipServices>();
|
||||||
serviceLocator<FriendshipServices>();
|
final TUISelfInfoViewModel _selfInfoViewModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
final TUISelfInfoViewModel _selfInfoViewModel =
|
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
final FocusNode _focusNode = FocusNode();
|
final FocusNode _focusNode = FocusNode();
|
||||||
bool isFocused = false;
|
bool isFocused = false;
|
||||||
bool showResult = false;
|
bool showResult = false;
|
||||||
List<V2TimUserFullInfo>? searchResult;
|
List<V2TimUserFullInfo>? searchResult;
|
||||||
|
|
||||||
Widget _searchResultItemBuilder(
|
Widget _searchResultItemBuilder(V2TimUserFullInfo friendInfo, TUITheme theme) {
|
||||||
V2TimUserFullInfo friendInfo, TUITheme theme) {
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
final isDesktopScreen =
|
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
|
|
||||||
final faceUrl = friendInfo.faceUrl ?? "";
|
final faceUrl = friendInfo.faceUrl ?? "";
|
||||||
final userID = friendInfo.userID ?? "";
|
final userID = friendInfo.userID ?? "";
|
||||||
final String showName =
|
final String showName =
|
||||||
((friendInfo.nickName != null && friendInfo.nickName!.isNotEmpty)
|
((friendInfo.nickName != null && friendInfo.nickName!.isNotEmpty) ? friendInfo.nickName : userID) ?? "";
|
||||||
? friendInfo.nickName
|
|
||||||
: userID) ??
|
|
||||||
"";
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final checkFriend = await _friendshipServices.checkFriend(
|
final checkFriend = await _friendshipServices
|
||||||
userIDList: [userID],
|
.checkFriend(userIDList: [userID], checkType: FriendTypeEnum.V2TIM_FRIEND_TYPE_SINGLE);
|
||||||
checkType: FriendTypeEnum.V2TIM_FRIEND_TYPE_SINGLE);
|
|
||||||
if (checkFriend != null) {
|
if (checkFriend != null) {
|
||||||
final res = checkFriend.first;
|
final res = checkFriend.first;
|
||||||
if (res.resultCode == 0 && res.resultType != 0) {
|
if (res.resultCode == 0 && res.resultType != 0) {
|
||||||
|
|
@ -126,9 +119,7 @@ class _TIMUIKitAddFriendState extends TIMUIKitState<TIMUIKitAddFriend> {
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
showName,
|
showName,
|
||||||
style: TextStyle(
|
style: TextStyle(color: theme.darkTextColor, fontSize: isDesktopScreen ? 16 : 18),
|
||||||
color: theme.darkTextColor,
|
|
||||||
fontSize: isDesktopScreen ? 16 : 18),
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 4,
|
height: 4,
|
||||||
|
|
@ -145,16 +136,14 @@ class _TIMUIKitAddFriendState extends TIMUIKitState<TIMUIKitAddFriend> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _searchResultBuilder(
|
List<Widget> _searchResultBuilder(List<V2TimUserFullInfo>? searchResult, TUITheme theme) {
|
||||||
List<V2TimUserFullInfo>? searchResult, TUITheme theme) {
|
|
||||||
final noResult = searchResult == null || searchResult.isEmpty;
|
final noResult = searchResult == null || searchResult.isEmpty;
|
||||||
if (noResult) {
|
if (noResult) {
|
||||||
return [
|
return [
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(top: 20),
|
margin: const EdgeInsets.only(top: 20),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(TIM_t("该用户不存在"),
|
child: Text(TIM_t("该用户不存在"), style: TextStyle(color: theme.weakTextColor, fontSize: 14)),
|
||||||
style: TextStyle(color: theme.weakTextColor, fontSize: 14)),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/friend_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
|
|
@ -20,11 +21,7 @@ class SendApplication extends StatefulWidget {
|
||||||
final AddFriendLifeCycle? lifeCycle;
|
final AddFriendLifeCycle? lifeCycle;
|
||||||
|
|
||||||
const SendApplication(
|
const SendApplication(
|
||||||
{Key? key,
|
{Key? key, this.lifeCycle, required this.friendInfo, required this.model, this.isShowDefaultGroup = false})
|
||||||
this.lifeCycle,
|
|
||||||
required this.friendInfo,
|
|
||||||
required this.model,
|
|
||||||
this.isShowDefaultGroup = false})
|
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -38,21 +35,18 @@ class _SendApplicationState extends TIMUIKitState<SendApplication> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
final showName =
|
final showName = widget.model.loginInfo?.nickName ?? widget.model.loginInfo?.userID;
|
||||||
widget.model.loginInfo?.nickName ?? widget.model.loginInfo?.userID;
|
|
||||||
_verficationController.text = "我是: $showName";
|
_verficationController.text = "我是: $showName";
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final TUITheme theme = value.theme;
|
final TUITheme theme = value.theme;
|
||||||
final FriendshipServices _friendshipServices =
|
final FriendshipServices _friendshipServices = serviceLocator<FriendshipServices>();
|
||||||
serviceLocator<FriendshipServices>();
|
|
||||||
|
|
||||||
final faceUrl = widget.friendInfo.faceUrl ?? "";
|
final faceUrl = widget.friendInfo.faceUrl ?? "";
|
||||||
final userID = widget.friendInfo.userID ?? "";
|
final userID = widget.friendInfo.userID ?? "";
|
||||||
final String showName = ((widget.friendInfo.nickName != null &&
|
final String showName = ((widget.friendInfo.nickName != null && widget.friendInfo.nickName!.isNotEmpty)
|
||||||
widget.friendInfo.nickName!.isNotEmpty)
|
|
||||||
? widget.friendInfo.nickName
|
? widget.friendInfo.nickName
|
||||||
: userID) ??
|
: userID) ??
|
||||||
"";
|
"";
|
||||||
|
|
@ -81,26 +75,22 @@ class _SendApplicationState extends TIMUIKitState<SendApplication> {
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
showName,
|
showName,
|
||||||
style:
|
style: TextStyle(color: theme.darkTextColor, fontSize: 18),
|
||||||
TextStyle(color: theme.darkTextColor, fontSize: 18),
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 4,
|
height: 4,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"ID: $userID",
|
"ID: $userID",
|
||||||
style:
|
style: TextStyle(fontSize: 13, color: theme.weakTextColor),
|
||||||
TextStyle(fontSize: 13, color: theme.weakTextColor),
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 4,
|
height: 4,
|
||||||
),
|
),
|
||||||
if (TencentUtils.checkString(option2) != null)
|
if (TencentUtils.checkString(option2) != null)
|
||||||
Text(
|
Text(
|
||||||
TIM_t_para("个性签名: {{option2}}", "个性签名: $option2")(
|
TIM_t_para("个性签名: {{option2}}", "个性签名: $option2")(option2: option2),
|
||||||
option2: option2),
|
style: TextStyle(fontSize: 13, color: theme.weakTextColor),
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 13, color: theme.weakTextColor),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
@ -171,20 +161,17 @@ class _SendApplicationState extends TIMUIKitState<SendApplication> {
|
||||||
if (widget.isShowDefaultGroup == true)
|
if (widget.isShowDefaultGroup == true)
|
||||||
Container(
|
Container(
|
||||||
color: theme.white,
|
color: theme.white,
|
||||||
padding:
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
TIM_t("分组"),
|
TIM_t("分组"),
|
||||||
style:
|
style: TextStyle(color: theme.darkTextColor, fontSize: 16),
|
||||||
TextStyle(color: theme.darkTextColor, fontSize: 16),
|
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
TIM_t("我的好友"),
|
TIM_t("我的好友"),
|
||||||
style:
|
style: TextStyle(color: theme.darkTextColor, fontSize: 16),
|
||||||
TextStyle(color: theme.darkTextColor, fontSize: 16),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -200,8 +187,7 @@ class _SendApplicationState extends TIMUIKitState<SendApplication> {
|
||||||
final friendGroup = TIM_t("我的好友");
|
final friendGroup = TIM_t("我的好友");
|
||||||
|
|
||||||
if (widget.lifeCycle?.shouldAddFriend != null &&
|
if (widget.lifeCycle?.shouldAddFriend != null &&
|
||||||
await widget.lifeCycle!.shouldAddFriend(userID, remark,
|
await widget.lifeCycle!.shouldAddFriend(userID, remark, friendGroup, addWording, context) ==
|
||||||
friendGroup, addWording, context) ==
|
|
||||||
false) {
|
false) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_wide_modal_operation_key.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_wide_modal_operation_key.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/widgets/wide_popup.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/widgets/wide_popup.dart';
|
||||||
|
|
@ -23,14 +25,11 @@ class TIMUIKitAddGroup extends StatefulWidget {
|
||||||
final AddGroupLifeCycle? lifeCycle;
|
final AddGroupLifeCycle? lifeCycle;
|
||||||
|
|
||||||
/// Navigate to group chat, if user is already a member of the current group.
|
/// Navigate to group chat, if user is already a member of the current group.
|
||||||
final Function(String groupID, V2TimConversation conversation)
|
final Function(String groupID, V2TimConversation conversation) onTapExistGroup;
|
||||||
onTapExistGroup;
|
|
||||||
|
|
||||||
final VoidCallback? closeFunc;
|
final VoidCallback? closeFunc;
|
||||||
|
|
||||||
const TIMUIKitAddGroup(
|
const TIMUIKitAddGroup({Key? key, this.lifeCycle, required this.onTapExistGroup, this.closeFunc}) : super(key: key);
|
||||||
{Key? key, this.lifeCycle, required this.onTapExistGroup, this.closeFunc})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _TIMUIKitAddGroupState();
|
State<StatefulWidget> createState() => _TIMUIKitAddGroupState();
|
||||||
|
|
@ -39,10 +38,8 @@ class TIMUIKitAddGroup extends StatefulWidget {
|
||||||
class _TIMUIKitAddGroupState extends TIMUIKitState<TIMUIKitAddGroup> {
|
class _TIMUIKitAddGroupState extends TIMUIKitState<TIMUIKitAddGroup> {
|
||||||
final TextEditingController _controller = TextEditingController();
|
final TextEditingController _controller = TextEditingController();
|
||||||
final GroupServices _groupServices = serviceLocator<GroupServices>();
|
final GroupServices _groupServices = serviceLocator<GroupServices>();
|
||||||
final ConversationService _conversationService =
|
final ConversationService _conversationService = serviceLocator<ConversationService>();
|
||||||
serviceLocator<ConversationService>();
|
final TUIFriendShipViewModel friendShipViewModel = serviceLocator<TUIFriendShipViewModel>();
|
||||||
final TUIFriendShipViewModel friendShipViewModel =
|
|
||||||
serviceLocator<TUIFriendShipViewModel>();
|
|
||||||
List<V2TimGroupInfo>? _addedGroupList;
|
List<V2TimGroupInfo>? _addedGroupList;
|
||||||
List<V2TimGroupInfo>? groupResult = [];
|
List<V2TimGroupInfo>? groupResult = [];
|
||||||
final FocusNode _focusNode = FocusNode();
|
final FocusNode _focusNode = FocusNode();
|
||||||
|
|
@ -79,24 +76,19 @@ class _TIMUIKitAddGroupState extends TIMUIKitState<TIMUIKitAddGroup> {
|
||||||
final groupID = groupInfo.groupID;
|
final groupID = groupInfo.groupID;
|
||||||
final showName = groupInfo.groupName ?? groupID;
|
final showName = groupInfo.groupName ?? groupID;
|
||||||
final groupType = _getGroupType(groupInfo.groupType);
|
final groupType = _getGroupType(groupInfo.groupType);
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final V2TimConversation? groupConversation =
|
final V2TimConversation? groupConversation = await getGroupConversation(groupID);
|
||||||
await getGroupConversation(groupID);
|
|
||||||
if (groupConversation != null) {
|
if (groupConversation != null) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("您已是群成员"), infoCode: 6660202));
|
||||||
type: TIMCallbackType.INFO,
|
|
||||||
infoRecommendText: TIM_t("您已是群成员"),
|
|
||||||
infoCode: 6660202));
|
|
||||||
if (widget.closeFunc != null) {
|
if (widget.closeFunc != null) {
|
||||||
widget.closeFunc!();
|
widget.closeFunc!();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isDesktopScreen){
|
if (isDesktopScreen) {
|
||||||
if (widget.closeFunc != null) {
|
if (widget.closeFunc != null) {
|
||||||
widget.closeFunc!();
|
widget.closeFunc!();
|
||||||
}
|
}
|
||||||
|
|
@ -107,20 +99,19 @@ class _TIMUIKitAddGroupState extends TIMUIKitState<TIMUIKitAddGroup> {
|
||||||
height: MediaQuery.of(context).size.width * 0.4,
|
height: MediaQuery.of(context).size.width * 0.4,
|
||||||
title: TIM_t("添加群聊"),
|
title: TIM_t("添加群聊"),
|
||||||
child: (closeFuncSendApplication) => SendJoinGroupApplication(
|
child: (closeFuncSendApplication) => SendJoinGroupApplication(
|
||||||
lifeCycle: widget.lifeCycle,
|
lifeCycle: widget.lifeCycle,
|
||||||
groupInfo: groupInfo,
|
groupInfo: groupInfo,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}else{
|
} else {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => SendJoinGroupApplication(
|
builder: (context) => SendJoinGroupApplication(
|
||||||
lifeCycle: widget.lifeCycle,
|
lifeCycle: widget.lifeCycle,
|
||||||
groupInfo: groupInfo,
|
groupInfo: groupInfo,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||||
|
|
@ -156,24 +147,19 @@ class _TIMUIKitAddGroupState extends TIMUIKitState<TIMUIKitAddGroup> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _searchResultBuilder(
|
List<Widget> _searchResultBuilder(List<V2TimGroupInfo>? searchResult, TUITheme theme) {
|
||||||
List<V2TimGroupInfo>? searchResult, TUITheme theme) {
|
|
||||||
final noResult = searchResult != null && searchResult.isEmpty;
|
final noResult = searchResult != null && searchResult.isEmpty;
|
||||||
if (noResult) {
|
if (noResult) {
|
||||||
return [
|
return [
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(top: 20),
|
margin: const EdgeInsets.only(top: 20),
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(TIM_t("该群聊不存在"),
|
child: Text(TIM_t("该群聊不存在"), style: TextStyle(color: theme.weakTextColor, fontSize: 14)),
|
||||||
style: TextStyle(color: theme.weakTextColor, fontSize: 14)),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return searchResult
|
return searchResult?.map((e) => _searchResultItemBuilder(e, theme)).toList() ?? [];
|
||||||
?.map((e) => _searchResultItemBuilder(e, theme))
|
|
||||||
.toList() ??
|
|
||||||
[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimConversation?> getGroupConversation(String groupID) async {
|
Future<V2TimConversation?> getGroupConversation(String groupID) async {
|
||||||
|
|
@ -186,15 +172,12 @@ class _TIMUIKitAddGroupState extends TIMUIKitState<TIMUIKitAddGroup> {
|
||||||
})) !=
|
})) !=
|
||||||
null) {
|
null) {
|
||||||
V2TimConversation? conversation;
|
V2TimConversation? conversation;
|
||||||
conversation = await _conversationService
|
conversation = await _conversationService.getConversationListByConversationId(convID: "group_$groupID");
|
||||||
.getConversationListByConversationId(convID: "group_$groupID");
|
|
||||||
if (conversation == null) {
|
if (conversation == null) {
|
||||||
await friendShipViewModel.loadGroupListData();
|
await friendShipViewModel.loadGroupListData();
|
||||||
if (friendShipViewModel.groupList
|
if (friendShipViewModel.groupList.indexWhere((element) => element.groupID == groupID) > -1) {
|
||||||
.indexWhere((element) => element.groupID == groupID) >
|
final V2TimGroupInfo groupInfo =
|
||||||
-1) {
|
friendShipViewModel.groupList.firstWhere((element) => element.groupID == groupID);
|
||||||
final V2TimGroupInfo groupInfo = friendShipViewModel.groupList
|
|
||||||
.firstWhere((element) => element.groupID == groupID);
|
|
||||||
conversation = V2TimConversation(
|
conversation = V2TimConversation(
|
||||||
conversationID: "group_$groupID",
|
conversationID: "group_$groupID",
|
||||||
type: 2,
|
type: 2,
|
||||||
|
|
@ -237,10 +220,7 @@ class _TIMUIKitAddGroupState extends TIMUIKitState<TIMUIKitAddGroup> {
|
||||||
final res = await _groupServices.getGroupsInfo(groupIDList: [params]);
|
final res = await _groupServices.getGroupsInfo(groupIDList: [params]);
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
setState(() {
|
setState(() {
|
||||||
groupResult = res
|
groupResult = res.where((e) => e.resultCode == 0).map((e) => e.groupInfo!).toList();
|
||||||
.where((e) => e.resultCode == 0)
|
|
||||||
.map((e) => e.groupInfo!)
|
|
||||||
.toList();
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_callback.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_callback.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/add_group_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/add_group_life_cycle.dart';
|
||||||
|
|
@ -18,16 +20,13 @@ class SendJoinGroupApplication extends StatefulWidget {
|
||||||
final V2TimGroupInfo groupInfo;
|
final V2TimGroupInfo groupInfo;
|
||||||
final AddGroupLifeCycle? lifeCycle;
|
final AddGroupLifeCycle? lifeCycle;
|
||||||
|
|
||||||
const SendJoinGroupApplication(
|
const SendJoinGroupApplication({Key? key, required this.groupInfo, this.lifeCycle}) : super(key: key);
|
||||||
{Key? key, required this.groupInfo, this.lifeCycle})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _SendJoinGroupApplicationState();
|
State<StatefulWidget> createState() => _SendJoinGroupApplicationState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SendJoinGroupApplicationState
|
class _SendJoinGroupApplicationState extends TIMUIKitState<SendJoinGroupApplication> {
|
||||||
extends TIMUIKitState<SendJoinGroupApplication> {
|
|
||||||
final TextEditingController _verficationController = TextEditingController();
|
final TextEditingController _verficationController = TextEditingController();
|
||||||
final GroupServices _groupServices = serviceLocator<GroupServices>();
|
final GroupServices _groupServices = serviceLocator<GroupServices>();
|
||||||
final CoreServicesImpl _coreServicesImpl = serviceLocator<CoreServicesImpl>();
|
final CoreServicesImpl _coreServicesImpl = serviceLocator<CoreServicesImpl>();
|
||||||
|
|
@ -37,14 +36,12 @@ class _SendJoinGroupApplicationState
|
||||||
super.initState();
|
super.initState();
|
||||||
final loginUserInfo = _coreServicesImpl.loginUserInfo;
|
final loginUserInfo = _coreServicesImpl.loginUserInfo;
|
||||||
final option1 = loginUserInfo?.nickName ?? loginUserInfo?.userID;
|
final option1 = loginUserInfo?.nickName ?? loginUserInfo?.userID;
|
||||||
_verficationController.text =
|
_verficationController.text = TIM_t_para("我是: {{option1}}", "我是: $option1")(option1: option1);
|
||||||
TIM_t_para("我是: {{option1}}", "我是: $option1")(option1: option1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<V2TimCallback?> addGroup(String groupID, String message) async {
|
Future<V2TimCallback?> addGroup(String groupID, String message) async {
|
||||||
if (widget.lifeCycle?.shouldAddGroup != null &&
|
if (widget.lifeCycle?.shouldAddGroup != null &&
|
||||||
await widget.lifeCycle!.shouldAddGroup(groupID, message, context) ==
|
await widget.lifeCycle!.shouldAddGroup(groupID, message, context) == false) {
|
||||||
false) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return _groupServices.joinGroup(groupID: groupID, message: message);
|
return _groupServices.joinGroup(groupID: groupID, message: message);
|
||||||
|
|
@ -107,25 +104,21 @@ class _SendJoinGroupApplicationState
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
showName,
|
showName,
|
||||||
style:
|
style: TextStyle(color: theme.darkTextColor, fontSize: 18),
|
||||||
TextStyle(color: theme.darkTextColor, fontSize: 18),
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 4,
|
height: 4,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
"ID: $groupID",
|
"ID: $groupID",
|
||||||
style:
|
style: TextStyle(fontSize: 13, color: theme.weakTextColor),
|
||||||
TextStyle(fontSize: 13, color: theme.weakTextColor),
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 4,
|
height: 4,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
TIM_t_para("群类型: {{option1}}", "群类型: $option1")(
|
TIM_t_para("群类型: {{option1}}", "群类型: $option1")(option1: option1),
|
||||||
option1: option1),
|
style: TextStyle(fontSize: 12, color: theme.weakTextColor),
|
||||||
style:
|
|
||||||
TextStyle(fontSize: 12, color: theme.weakTextColor),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
@ -164,9 +157,7 @@ class _SendJoinGroupApplicationState
|
||||||
final res = await addGroup(groupID, addWording);
|
final res = await addGroup(groupID, addWording);
|
||||||
if (res?.code == 0) {
|
if (res?.code == 0) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(
|
||||||
type: TIMCallbackType.INFO,
|
type: TIMCallbackType.INFO, infoRecommendText: TIM_t("群申请已发送"), infoCode: 6660201));
|
||||||
infoRecommendText: TIM_t("群申请已发送"),
|
|
||||||
infoCode: 6660201));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(TIM_t("发送"))),
|
child: Text(TIM_t("发送"))),
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_slidable_plus_plus/flutter_slidable_plus_plus.dart';
|
import 'package:flutter_slidable_plus_plus/flutter_slidable_plus_plus.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/block_list_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/block_list_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_friendship_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_friendship_view_model.dart';
|
||||||
|
|
@ -13,8 +14,7 @@ import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
||||||
|
|
||||||
typedef BlackListItemBuilder = Widget Function(
|
typedef BlackListItemBuilder = Widget Function(BuildContext context, V2TimFriendInfo friendInfo);
|
||||||
BuildContext context, V2TimFriendInfo friendInfo);
|
|
||||||
|
|
||||||
class TIMUIKitBlackList extends StatefulWidget {
|
class TIMUIKitBlackList extends StatefulWidget {
|
||||||
final void Function(V2TimFriendInfo friendInfo)? onTapItem;
|
final void Function(V2TimFriendInfo friendInfo)? onTapItem;
|
||||||
|
|
@ -24,12 +24,7 @@ class TIMUIKitBlackList extends StatefulWidget {
|
||||||
/// The life cycle hooks for block list business logic
|
/// The life cycle hooks for block list business logic
|
||||||
final BlockListLifeCycle? lifeCycle;
|
final BlockListLifeCycle? lifeCycle;
|
||||||
|
|
||||||
const TIMUIKitBlackList(
|
const TIMUIKitBlackList({Key? key, this.onTapItem, this.emptyBuilder, this.itemBuilder, this.lifeCycle})
|
||||||
{Key? key,
|
|
||||||
this.onTapItem,
|
|
||||||
this.emptyBuilder,
|
|
||||||
this.itemBuilder,
|
|
||||||
this.lifeCycle})
|
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -37,8 +32,7 @@ class TIMUIKitBlackList extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TIMUIKitBlackListState extends TIMUIKitState<TIMUIKitBlackList> {
|
class _TIMUIKitBlackListState extends TIMUIKitState<TIMUIKitBlackList> {
|
||||||
final TUIFriendShipViewModel _friendshipViewModel =
|
final TUIFriendShipViewModel _friendshipViewModel = serviceLocator<TUIFriendShipViewModel>();
|
||||||
serviceLocator<TUIFriendShipViewModel>();
|
|
||||||
|
|
||||||
_getShowName(V2TimFriendInfo item) {
|
_getShowName(V2TimFriendInfo item) {
|
||||||
final friendRemark = item.friendRemark ?? "";
|
final friendRemark = item.friendRemark ?? "";
|
||||||
|
|
@ -52,8 +46,7 @@ class _TIMUIKitBlackListState extends TIMUIKitState<TIMUIKitBlackList> {
|
||||||
final theme = Provider.of<TUIThemeViewModel>(context).theme;
|
final theme = Provider.of<TUIThemeViewModel>(context).theme;
|
||||||
final showName = _getShowName(friendInfo);
|
final showName = _getShowName(friendInfo);
|
||||||
final faceUrl = friendInfo.userProfile?.faceUrl ?? "";
|
final faceUrl = friendInfo.userProfile?.faceUrl ?? "";
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
|
|
||||||
Widget itemWidget() {
|
Widget itemWidget() {
|
||||||
return Material(
|
return Material(
|
||||||
|
|
@ -67,10 +60,7 @@ class _TIMUIKitBlackListState extends TIMUIKitState<TIMUIKitBlackList> {
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.only(top: 10, left: 16, right: 16),
|
padding: const EdgeInsets.only(top: 10, left: 16, right: 16),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
bottom: BorderSide(
|
|
||||||
color: theme.weakDividerColor ??
|
|
||||||
CommonColor.weakDividerColor))),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
|
@ -88,15 +78,13 @@ class _TIMUIKitBlackListState extends TIMUIKitState<TIMUIKitBlackList> {
|
||||||
padding: const EdgeInsets.only(top: 10, bottom: 20),
|
padding: const EdgeInsets.only(top: 10, bottom: 20),
|
||||||
child: Text(
|
child: Text(
|
||||||
showName,
|
showName,
|
||||||
style: TextStyle(
|
style: TextStyle(color: theme.black, fontSize: isDesktopScreen ? 14 : 18),
|
||||||
color: theme.black, fontSize: isDesktopScreen ? 14 : 18),
|
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
if (isDesktopScreen)
|
if (isDesktopScreen)
|
||||||
OutlinedButton(
|
OutlinedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
_friendshipViewModel
|
_friendshipViewModel.deleteFromBlockList([friendInfo.userID]);
|
||||||
.deleteFromBlockList([friendInfo.userID]);
|
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t("移出黑名单"),
|
TIM_t("移出黑名单"),
|
||||||
|
|
@ -116,8 +104,7 @@ class _TIMUIKitBlackListState extends TIMUIKitState<TIMUIKitBlackList> {
|
||||||
endActionPane: ActionPane(motion: const DrawerMotion(), children: [
|
endActionPane: ActionPane(motion: const DrawerMotion(), children: [
|
||||||
SlidableAction(
|
SlidableAction(
|
||||||
onPressed: (context) async {
|
onPressed: (context) async {
|
||||||
await _friendshipViewModel
|
await _friendshipViewModel.deleteFromBlockList([friendInfo.userID]);
|
||||||
.deleteFromBlockList([friendInfo.userID]);
|
|
||||||
},
|
},
|
||||||
backgroundColor: theme.cautionColor ?? CommonColor.cautionColor,
|
backgroundColor: theme.cautionColor ?? CommonColor.cautionColor,
|
||||||
foregroundColor: theme.white,
|
foregroundColor: theme.white,
|
||||||
|
|
@ -133,7 +120,6 @@ class _TIMUIKitBlackListState extends TIMUIKitState<TIMUIKitBlackList> {
|
||||||
return widget.itemBuilder ?? _itemBuilder;
|
return widget.itemBuilder ?? _itemBuilder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_at_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
|
|
@ -60,11 +62,18 @@ class _TIMUIKitHistoryMessageListTongueContainerState extends TIMUIKitState<TIMU
|
||||||
if (offset <= 0.0 && conversationUnreadCount != 0) {
|
if (offset <= 0.0 && conversationUnreadCount != 0) {
|
||||||
widget.model.showLatestUnread();
|
widget.model.showLatestUnread();
|
||||||
}
|
}
|
||||||
if (widget.scrollController.offset <= widget.scrollController.position.minScrollExtent && !widget.scrollController.position.outOfRange && !widget.model.haveMoreLatestData) {
|
if (widget.scrollController.offset <= widget.scrollController.position.minScrollExtent &&
|
||||||
|
!widget.scrollController.position.outOfRange &&
|
||||||
|
!widget.model.haveMoreLatestData) {
|
||||||
changePositionState(HistoryMessagePosition.bottom);
|
changePositionState(HistoryMessagePosition.bottom);
|
||||||
} else if (widget.scrollController.offset <= screenHeight * 1.6 && widget.scrollController.offset > 0 && !widget.scrollController.position.outOfRange && !widget.model.haveMoreLatestData) {
|
} else if (widget.scrollController.offset <= screenHeight * 1.6 &&
|
||||||
|
widget.scrollController.offset > 0 &&
|
||||||
|
!widget.scrollController.position.outOfRange &&
|
||||||
|
!widget.model.haveMoreLatestData) {
|
||||||
changePositionState(HistoryMessagePosition.inTwoScreen);
|
changePositionState(HistoryMessagePosition.inTwoScreen);
|
||||||
} else if (widget.scrollController.offset > screenHeight * 1.6 && !widget.scrollController.position.outOfRange && !widget.model.haveMoreLatestData) {
|
} else if (widget.scrollController.offset > screenHeight * 1.6 &&
|
||||||
|
!widget.scrollController.position.outOfRange &&
|
||||||
|
!widget.model.haveMoreLatestData) {
|
||||||
changePositionState(HistoryMessagePosition.awayTwoScreen);
|
changePositionState(HistoryMessagePosition.awayTwoScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +143,8 @@ class _TIMUIKitHistoryMessageListTongueContainerState extends TIMUIKitState<TIMU
|
||||||
try {
|
try {
|
||||||
isClickShowPrevious = true;
|
isClickShowPrevious = true;
|
||||||
final String? lastSeqString = widget.conversation.lastMessage?.seq;
|
final String? lastSeqString = widget.conversation.lastMessage?.seq;
|
||||||
final int? lastSeq = TencentUtils.checkString(lastSeqString) != null ? int.parse(lastSeqString!) : null;
|
final int? lastSeq =
|
||||||
|
TencentUtils.checkString(lastSeqString) != null ? int.parse(lastSeqString!) : null;
|
||||||
final int? previousCount = widget.conversation.unreadCount;
|
final int? previousCount = widget.conversation.unreadCount;
|
||||||
if (lastSeq != null && previousCount != null) {
|
if (lastSeq != null && previousCount != null) {
|
||||||
final targetSeq = lastSeq - previousCount;
|
final targetSeq = lastSeq - previousCount;
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,12 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_at_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
|
|
@ -186,7 +189,9 @@ class _TIMUIKitHistoryMessageListState extends TIMUIKitState<TIMUIKitHistoryMess
|
||||||
int targetIndex = 1;
|
int targetIndex = 1;
|
||||||
for (int i = msgList.length - 1; i >= 0; i--) {
|
for (int i = msgList.length - 1; i >= 0; i--) {
|
||||||
final currentMsg = msgList[i];
|
final currentMsg = msgList[i];
|
||||||
if (currentMsg?.timestamp == targetTimeStamp && currentMsg?.elemType != 11 && currentMsg!.msgID == targetMsg.msgID) {
|
if (currentMsg?.timestamp == targetTimeStamp &&
|
||||||
|
currentMsg?.elemType != 11 &&
|
||||||
|
currentMsg!.msgID == targetMsg.msgID) {
|
||||||
// find the target index by timestamp and msgID
|
// find the target index by timestamp and msgID
|
||||||
isFound = true;
|
isFound = true;
|
||||||
targetIndex = -i;
|
targetIndex = -i;
|
||||||
|
|
@ -268,7 +273,8 @@ class _TIMUIKitHistoryMessageListState extends TIMUIKitState<TIMUIKitHistoryMess
|
||||||
if (maybeHaveMoreMessageForFind) {
|
if (maybeHaveMoreMessageForFind) {
|
||||||
findingSeq = targetSeq;
|
findingSeq = targetSeq;
|
||||||
int requestCount = int.parse(lastSeq) - int.parse(targetSeq);
|
int requestCount = int.parse(lastSeq) - int.parse(targetSeq);
|
||||||
maybeHaveMoreMessageForFind = await widget.onLoadMore(_getMessageId(widget.messageList.length - 1), LoadDirection.previous, requestCount, int.parse(lastSeq));
|
maybeHaveMoreMessageForFind = await widget.onLoadMore(
|
||||||
|
_getMessageId(widget.messageList.length - 1), LoadDirection.previous, requestCount, int.parse(lastSeq));
|
||||||
} else {
|
} else {
|
||||||
showCantFindMsg();
|
showCantFindMsg();
|
||||||
}
|
}
|
||||||
|
|
@ -285,7 +291,9 @@ class _TIMUIKitHistoryMessageListState extends TIMUIKitState<TIMUIKitHistoryMess
|
||||||
int targetIndex = 1;
|
int targetIndex = 1;
|
||||||
for (int i = msgList.length - 1; i >= 0; i--) {
|
for (int i = msgList.length - 1; i >= 0; i--) {
|
||||||
final currentMsg = msgList[i];
|
final currentMsg = msgList[i];
|
||||||
if (currentMsg?.timestamp == targetTimeStamp && currentMsg?.elemType != 11 && currentMsg!.msgID == targetMsg.msgID) {
|
if (currentMsg?.timestamp == targetTimeStamp &&
|
||||||
|
currentMsg?.elemType != 11 &&
|
||||||
|
currentMsg!.msgID == targetMsg.msgID) {
|
||||||
isFound = true;
|
isFound = true;
|
||||||
targetIndex = -i;
|
targetIndex = -i;
|
||||||
break;
|
break;
|
||||||
|
|
@ -354,14 +362,17 @@ class _TIMUIKitHistoryMessageListState extends TIMUIKitState<TIMUIKitHistoryMess
|
||||||
center: shouldShowUnreadMessage ? centerKey : null,
|
center: shouldShowUnreadMessage ? centerKey : null,
|
||||||
key: widget.mainHistoryListConfig?.key,
|
key: widget.mainHistoryListConfig?.key,
|
||||||
primary: widget.mainHistoryListConfig?.primary,
|
primary: widget.mainHistoryListConfig?.primary,
|
||||||
physics: (widget.isAllowScroll == false) ? const NeverScrollableScrollPhysics() : widget.mainHistoryListConfig?.physics,
|
physics: (widget.isAllowScroll == false)
|
||||||
|
? const NeverScrollableScrollPhysics()
|
||||||
|
: widget.mainHistoryListConfig?.physics,
|
||||||
// padding: widget.mainHistoryListConfig?.padding ?? EdgeInsets.zero,
|
// padding: widget.mainHistoryListConfig?.padding ?? EdgeInsets.zero,
|
||||||
// itemExtent: widget.mainHistoryListConfig?.itemExtent,
|
// itemExtent: widget.mainHistoryListConfig?.itemExtent,
|
||||||
// prototypeItem: widget.mainHistoryListConfig?.prototypeItem,
|
// prototypeItem: widget.mainHistoryListConfig?.prototypeItem,
|
||||||
cacheExtent: widget.mainHistoryListConfig?.cacheExtent ?? 1500,
|
cacheExtent: widget.mainHistoryListConfig?.cacheExtent ?? 1500,
|
||||||
semanticChildCount: widget.mainHistoryListConfig?.semanticChildCount,
|
semanticChildCount: widget.mainHistoryListConfig?.semanticChildCount,
|
||||||
dragStartBehavior: widget.mainHistoryListConfig?.dragStartBehavior ?? DragStartBehavior.start,
|
dragStartBehavior: widget.mainHistoryListConfig?.dragStartBehavior ?? DragStartBehavior.start,
|
||||||
keyboardDismissBehavior: widget.mainHistoryListConfig?.keyboardDismissBehavior ?? ScrollViewKeyboardDismissBehavior.manual,
|
keyboardDismissBehavior:
|
||||||
|
widget.mainHistoryListConfig?.keyboardDismissBehavior ?? ScrollViewKeyboardDismissBehavior.manual,
|
||||||
restorationId: widget.mainHistoryListConfig?.restorationId,
|
restorationId: widget.mainHistoryListConfig?.restorationId,
|
||||||
clipBehavior: widget.mainHistoryListConfig?.clipBehavior ?? Clip.hardEdge,
|
clipBehavior: widget.mainHistoryListConfig?.clipBehavior ?? Clip.hardEdge,
|
||||||
reverse: true,
|
reverse: true,
|
||||||
|
|
@ -377,20 +388,24 @@ class _TIMUIKitHistoryMessageListState extends TIMUIKitState<TIMUIKitHistoryMess
|
||||||
if (index == unreadMessageList.length - 1 && widget.model.haveMoreLatestData == true) {
|
if (index == unreadMessageList.length - 1 && widget.model.haveMoreLatestData == true) {
|
||||||
throttleFunctionWithMsgID(messageItem?.msgID ?? "", LoadDirection.latest);
|
throttleFunctionWithMsgID(messageItem?.msgID ?? "", LoadDirection.latest);
|
||||||
}
|
}
|
||||||
outputLogger.i("Rendering a unread message: ${getMessageIdentifier(messageItem, 0)}, message Type: ${messageItem?.elemType}");
|
outputLogger.i(
|
||||||
|
"Rendering a unread message: ${getMessageIdentifier(messageItem, 0)}, message Type: ${messageItem?.elemType}");
|
||||||
return AutoScrollTag(
|
return AutoScrollTag(
|
||||||
controller: _autoScrollController,
|
controller: _autoScrollController,
|
||||||
index: -index,
|
index: -index,
|
||||||
key: ValueKey(getMessageIdentifier(messageItem, index)),
|
key: ValueKey(getMessageIdentifier(messageItem, index)),
|
||||||
highlightColor: Colors.black.withOpacity(0.1),
|
highlightColor: Colors.black.withOpacity(0.1),
|
||||||
child: KeepAliveWrapper(keepAlive: messageItem?.elemType == MessageElemType.V2TIM_ELEM_TYPE_SOUND, child: Container(child: _getMessageItemBuilder(messageItem))),
|
child: KeepAliveWrapper(
|
||||||
|
keepAlive: messageItem?.elemType == MessageElemType.V2TIM_ELEM_TYPE_SOUND,
|
||||||
|
child: Container(child: _getMessageItemBuilder(messageItem))),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount: unreadMessageList.length,
|
childCount: unreadMessageList.length,
|
||||||
findChildIndexCallback: (Key key) {
|
findChildIndexCallback: (Key key) {
|
||||||
final ValueKey<String> valueKey = key as ValueKey<String>;
|
final ValueKey<String> valueKey = key as ValueKey<String>;
|
||||||
final String data = valueKey.value;
|
final String data = valueKey.value;
|
||||||
final int index = unreadMessageList.indexWhere((element) => getMessageIdentifier(element, 0) == data);
|
final int index =
|
||||||
|
unreadMessageList.indexWhere((element) => getMessageIdentifier(element, 0) == data);
|
||||||
return index != -1 ? index : null;
|
return index != -1 ? index : null;
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
|
|
@ -414,7 +429,11 @@ class _TIMUIKitHistoryMessageListState extends TIMUIKitState<TIMUIKitHistoryMess
|
||||||
final messageItem = readMessageList[index];
|
final messageItem = readMessageList[index];
|
||||||
if (index == readMessageList.length - 1) {
|
if (index == readMessageList.length - 1) {
|
||||||
if (haveMoreData) {
|
if (haveMoreData) {
|
||||||
final lastMessage = globalModel.messageListMap[TencentUtils.checkString(widget.conversation.groupID) ?? widget.conversation.userID ?? widget.conversation.conversationID]?.last;
|
final lastMessage = globalModel
|
||||||
|
.messageListMap[TencentUtils.checkString(widget.conversation.groupID) ??
|
||||||
|
widget.conversation.userID ??
|
||||||
|
widget.conversation.conversationID]
|
||||||
|
?.last;
|
||||||
if (lastMessage != null) {
|
if (lastMessage != null) {
|
||||||
throttleFunctionWithMsgID(lastMessage.msgID ?? "", LoadDirection.previous);
|
throttleFunctionWithMsgID(lastMessage.msgID ?? "", LoadDirection.previous);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -431,29 +450,37 @@ class _TIMUIKitHistoryMessageListState extends TIMUIKitState<TIMUIKitHistoryMess
|
||||||
index: -index,
|
index: -index,
|
||||||
key: ValueKey(getMessageIdentifier(messageItem, index)),
|
key: ValueKey(getMessageIdentifier(messageItem, index)),
|
||||||
highlightColor: Colors.black.withOpacity(0.1),
|
highlightColor: Colors.black.withOpacity(0.1),
|
||||||
child: KeepAliveWrapper(keepAlive: messageItem?.elemType == MessageElemType.V2TIM_ELEM_TYPE_SOUND, child: Container(child: _getMessageItemBuilder(messageItem))),
|
child: KeepAliveWrapper(
|
||||||
|
keepAlive: messageItem?.elemType == MessageElemType.V2TIM_ELEM_TYPE_SOUND,
|
||||||
|
child: Container(child: _getMessageItemBuilder(messageItem))),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == 0 && widget.model.haveMoreLatestData == true && globalModel.receivedNewMessageCount < 10) {
|
if (index == 0 &&
|
||||||
|
widget.model.haveMoreLatestData == true &&
|
||||||
|
globalModel.receivedNewMessageCount < 10) {
|
||||||
throttleFunction(index, LoadDirection.latest);
|
throttleFunction(index, LoadDirection.latest);
|
||||||
}
|
}
|
||||||
outputLogger.i("Rendering a read message: ${getMessageIdentifier(messageItem, 0)}, message Type: ${messageItem?.elemType}");
|
outputLogger.i(
|
||||||
|
"Rendering a read message: ${getMessageIdentifier(messageItem, 0)}, message Type: ${messageItem?.elemType}");
|
||||||
return AutoScrollTag(
|
return AutoScrollTag(
|
||||||
controller: _autoScrollController,
|
controller: _autoScrollController,
|
||||||
index: -index,
|
index: -index,
|
||||||
key: ValueKey(getMessageIdentifier(messageItem, index)),
|
key: ValueKey(getMessageIdentifier(messageItem, index)),
|
||||||
highlightColor: Colors.black.withOpacity(0.1),
|
highlightColor: Colors.black.withOpacity(0.1),
|
||||||
child: KeepAliveWrapper(keepAlive: messageItem?.elemType == MessageElemType.V2TIM_ELEM_TYPE_SOUND, child: Container(child: _getMessageItemBuilder(messageItem))),
|
child: KeepAliveWrapper(
|
||||||
|
keepAlive: messageItem?.elemType == MessageElemType.V2TIM_ELEM_TYPE_SOUND,
|
||||||
|
child: Container(child: _getMessageItemBuilder(messageItem))),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
childCount: readMessageList.length,
|
childCount: readMessageList.length,
|
||||||
findChildIndexCallback: (Key key) {
|
findChildIndexCallback: (Key key) {
|
||||||
final ValueKey<String> valueKey = key as ValueKey<String>;
|
final ValueKey<String> valueKey = key as ValueKey<String>;
|
||||||
final String data = valueKey.value;
|
final String data = valueKey.value;
|
||||||
final int index = readMessageList.indexWhere((element) => getMessageIdentifier(element, 0) == data);
|
final int index =
|
||||||
|
readMessageList.indexWhere((element) => getMessageIdentifier(element, 0) == data);
|
||||||
return index > -1 ? index : null;
|
return index > -1 ? index : null;
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,14 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_change_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
|
|
@ -68,7 +72,8 @@ typedef MessageRowBuilder = Widget? Function(
|
||||||
Function onScrollToIndexBegin,
|
Function onScrollToIndexBegin,
|
||||||
);
|
);
|
||||||
|
|
||||||
typedef MessageNickNameBuilder = Widget Function(BuildContext context, V2TimMessage message, TUIChatSeparateViewModel model);
|
typedef MessageNickNameBuilder = Widget Function(
|
||||||
|
BuildContext context, V2TimMessage message, TUIChatSeparateViewModel model);
|
||||||
|
|
||||||
typedef MessageItemContent = Widget? Function(
|
typedef MessageItemContent = Widget? Function(
|
||||||
V2TimMessage message,
|
V2TimMessage message,
|
||||||
|
|
@ -175,7 +180,8 @@ class ToolTipsConfig {
|
||||||
bool showTranslation;
|
bool showTranslation;
|
||||||
|
|
||||||
/// A builder for additional custom items. We recommend using `additionalMessageToolTips` instead of this field since version 2.0, as you only need to provide the data rather than the whole widget. This makes usage easier and you don't need to worry about the UI display.
|
/// A builder for additional custom items. We recommend using `additionalMessageToolTips` instead of this field since version 2.0, as you only need to provide the data rather than the whole widget. This makes usage easier and you don't need to worry about the UI display.
|
||||||
final Widget? Function(V2TimMessage message, Function() closeTooltip, [Key? key, BuildContext? context])? additionalItemBuilder;
|
final Widget? Function(V2TimMessage message, Function() closeTooltip, [Key? key, BuildContext? context])?
|
||||||
|
additionalItemBuilder;
|
||||||
|
|
||||||
/// A list of additional message tooltip menu items, provided with the data only. We recommend using this field instead of the previous `additionalItemBuilder`.
|
/// A list of additional message tooltip menu items, provided with the data only. We recommend using this field instead of the previous `additionalItemBuilder`.
|
||||||
List<MessageToolTipItem> Function(V2TimMessage message, Function() closeTooltip)? additionalMessageToolTips;
|
List<MessageToolTipItem> Function(V2TimMessage message, Function() closeTooltip)? additionalMessageToolTips;
|
||||||
|
|
@ -189,7 +195,8 @@ class ToolTipsConfig {
|
||||||
this.showCopyMessage = true,
|
this.showCopyMessage = true,
|
||||||
this.showForwardMessage = true,
|
this.showForwardMessage = true,
|
||||||
this.additionalMessageToolTips,
|
this.additionalMessageToolTips,
|
||||||
@Deprecated("Please use `additionalMessageToolTips` instead. You are now only expected to specify the data, rather than providing a whole widget. This makes usage easier, as you no longer need to worry about the UI display.")
|
@Deprecated(
|
||||||
|
"Please use `additionalMessageToolTips` instead. You are now only expected to specify the data, rather than providing a whole widget. This makes usage easier, as you no longer need to worry about the UI display.")
|
||||||
this.additionalItemBuilder});
|
this.additionalItemBuilder});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -230,7 +237,8 @@ class TIMUIKitHistoryMessageListItem extends StatefulWidget {
|
||||||
/// Auto mention user when send reply message
|
/// Auto mention user when send reply message
|
||||||
final bool allowAtUserWhenReply;
|
final bool allowAtUserWhenReply;
|
||||||
|
|
||||||
@Deprecated("Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
@Deprecated(
|
||||||
|
"Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
||||||
|
|
||||||
/// allow show user nick name
|
/// allow show user nick name
|
||||||
final bool showNickName;
|
final bool showNickName;
|
||||||
|
|
@ -278,7 +286,9 @@ class TIMUIKitHistoryMessageListItem extends StatefulWidget {
|
||||||
const TIMUIKitHistoryMessageListItem(
|
const TIMUIKitHistoryMessageListItem(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
required this.message,
|
required this.message,
|
||||||
@Deprecated("Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead") this.showNickName = false,
|
@Deprecated(
|
||||||
|
"Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
||||||
|
this.showNickName = false,
|
||||||
this.onScrollToIndex,
|
this.onScrollToIndex,
|
||||||
this.onScrollToIndexBegin,
|
this.onScrollToIndexBegin,
|
||||||
this.onTapForOthersPortrait,
|
this.onTapForOthersPortrait,
|
||||||
|
|
@ -342,7 +352,8 @@ class TipsActionItem extends TIMUIKitStatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistoryMessageListItem> with SingleTickerProviderStateMixin {
|
class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistoryMessageListItem>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
SuperTooltip? tooltip;
|
SuperTooltip? tooltip;
|
||||||
late AnimationController _animationController;
|
late AnimationController _animationController;
|
||||||
|
|
||||||
|
|
@ -370,7 +381,8 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
final hasCustomData = message.cloudCustomData != null && message.cloudCustomData != "";
|
final hasCustomData = message.cloudCustomData != null && message.cloudCustomData != "";
|
||||||
if (hasCustomData) {
|
if (hasCustomData) {
|
||||||
try {
|
try {
|
||||||
final CloudCustomData messageCloudCustomData = CloudCustomData.fromJson(json.decode(TencentUtils.checkString(message.cloudCustomData) != null ? message.cloudCustomData! : "{}"));
|
final CloudCustomData messageCloudCustomData = CloudCustomData.fromJson(
|
||||||
|
json.decode(TencentUtils.checkString(message.cloudCustomData) != null ? message.cloudCustomData! : "{}"));
|
||||||
if (messageCloudCustomData.messageReply != null) {
|
if (messageCloudCustomData.messageReply != null) {
|
||||||
MessageRepliedData.fromJson(messageCloudCustomData.messageReply!);
|
MessageRepliedData.fromJson(messageCloudCustomData.messageReply!);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -612,7 +624,10 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
|
|
||||||
Widget _groupTipsMessageBuilder(TUIChatSeparateViewModel model) {
|
Widget _groupTipsMessageBuilder(TUIChatSeparateViewModel model) {
|
||||||
final messageItem = widget.message;
|
final messageItem = widget.message;
|
||||||
return Container(padding: const EdgeInsets.only(bottom: 20), child: TIMUIKitGroupTipsElem(groupTipsElem: messageItem.groupTipsElem!, groupMemberList: model.groupMemberList ?? []));
|
return Container(
|
||||||
|
padding: const EdgeInsets.only(bottom: 20),
|
||||||
|
child: TIMUIKitGroupTipsElem(
|
||||||
|
groupTipsElem: messageItem.groupTipsElem!, groupMemberList: model.groupMemberList ?? []));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _selfRevokeEditMessageBuilder(theme, TUIChatSeparateViewModel model) {
|
Widget _selfRevokeEditMessageBuilder(theme, TUIChatSeparateViewModel model) {
|
||||||
|
|
@ -650,7 +665,9 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
margin: const EdgeInsets.symmetric(vertical: 20),
|
margin: const EdgeInsets.symmetric(vertical: 20),
|
||||||
child: Text(
|
child: Text(
|
||||||
model.chatConfig.timeDividerConfig?.timestampParser != null ? (model.chatConfig.timeDividerConfig?.timestampParser!(timeStamp))! : TimeAgo().getTimeForMessage(timeStamp),
|
model.chatConfig.timeDividerConfig?.timestampParser != null
|
||||||
|
? (model.chatConfig.timeDividerConfig?.timestampParser!(timeStamp))!
|
||||||
|
: TimeAgo().getTimeForMessage(timeStamp),
|
||||||
style: widget.themeData?.timelineTextStyle ??
|
style: widget.themeData?.timelineTextStyle ??
|
||||||
TextStyle(
|
TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
|
|
@ -674,7 +691,8 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
width: 100,
|
width: 100,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
gradient: LinearGradient(colors: [const Color(0x00C0E1FF), theme.primaryColor ?? CommonColor.lightPrimaryColor]),
|
gradient: LinearGradient(
|
||||||
|
colors: [const Color(0x00C0E1FF), theme.primaryColor ?? CommonColor.lightPrimaryColor]),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -733,15 +751,25 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
final isSelf = message.isSelf ?? true;
|
final isSelf = message.isSelf ?? true;
|
||||||
|
|
||||||
final targetWidth = min(MediaQuery.of(context).size.width * 0.84, 350).toDouble();
|
final targetWidth = min(MediaQuery.of(context).size.width * 0.84, 350).toDouble();
|
||||||
final double dx = !isSelf ? min(tapDetails?.globalPosition.dx ?? targetWidth, screenWidth - targetWidth) : max(tapDetails?.globalPosition.dx ?? targetWidth, targetWidth).toDouble();
|
final double dx = !isSelf
|
||||||
final double dy = min(tapDetails?.globalPosition.dy ?? MediaQuery.of(context).size.height, MediaQuery.of(context).size.height - 320).toDouble();
|
? min(tapDetails?.globalPosition.dx ?? targetWidth, screenWidth - targetWidth)
|
||||||
|
: max(tapDetails?.globalPosition.dx ?? targetWidth, targetWidth).toDouble();
|
||||||
|
final double dy = min(tapDetails?.globalPosition.dy ?? MediaQuery.of(context).size.height,
|
||||||
|
MediaQuery.of(context).size.height - 320)
|
||||||
|
.toDouble();
|
||||||
final finalTapDetail = tapDetails != null
|
final finalTapDetail = tapDetails != null
|
||||||
? TapDownDetails(
|
? TapDownDetails(
|
||||||
globalPosition: Offset(dx, dy),
|
globalPosition: Offset(dx, dy),
|
||||||
)
|
)
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
initTools(context: c, model: model, isShowMoreSticker: isShowMoreSticker, details: finalTapDetail, theme: theme, isFromWideToolTip: isFromWideTooltip);
|
initTools(
|
||||||
|
context: c,
|
||||||
|
model: model,
|
||||||
|
isShowMoreSticker: isShowMoreSticker,
|
||||||
|
details: finalTapDetail,
|
||||||
|
theme: theme,
|
||||||
|
isFromWideToolTip: isFromWideTooltip);
|
||||||
tooltip!.show(c, targetCenter: finalTapDetail?.globalPosition);
|
tooltip!.show(c, targetCenter: finalTapDetail?.globalPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -760,7 +788,14 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
initTools({BuildContext? context, bool isLongMessage = false, required TUIChatSeparateViewModel model, TUITheme? theme, bool? isShowMoreSticker, TapDownDetails? details, bool? isFromWideToolTip}) {
|
initTools(
|
||||||
|
{BuildContext? context,
|
||||||
|
bool isLongMessage = false,
|
||||||
|
required TUIChatSeparateViewModel model,
|
||||||
|
TUITheme? theme,
|
||||||
|
bool? isShowMoreSticker,
|
||||||
|
TapDownDetails? details,
|
||||||
|
bool? isFromWideToolTip}) {
|
||||||
final isUseMessageReaction = widget.message.elemType == 2 ? false : model.chatConfig.isUseMessageReaction;
|
final isUseMessageReaction = widget.message.elemType == 2 ? false : model.chatConfig.isUseMessageReaction;
|
||||||
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
final isSelf = widget.message.isSelf ?? true;
|
final isSelf = widget.message.isSelf ?? true;
|
||||||
|
|
@ -846,7 +881,8 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
showCloseButton: ShowCloseButton.none,
|
showCloseButton: ShowCloseButton.none,
|
||||||
touchThroughAreaShape: ClipAreaShape.rectangle,
|
touchThroughAreaShape: ClipAreaShape.rectangle,
|
||||||
content: TIMUIKitMessageTooltip(
|
content: TIMUIKitMessageTooltip(
|
||||||
iSUseDefaultHoverBar: model.chatConfig.isUseMessageHoverBarOnDesktop && widget.customMessageHoverBarOnDesktop == null,
|
iSUseDefaultHoverBar:
|
||||||
|
model.chatConfig.isUseMessageHoverBarOnDesktop && widget.customMessageHoverBarOnDesktop == null,
|
||||||
model: model,
|
model: model,
|
||||||
groupMemberInfo: widget.groupMemberInfo,
|
groupMemberInfo: widget.groupMemberInfo,
|
||||||
isShowMoreSticker: isShowMoreSticker ?? false,
|
isShowMoreSticker: isShowMoreSticker ?? false,
|
||||||
|
|
@ -933,10 +969,12 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
model.repliedMessage = widget.message;
|
model.repliedMessage = widget.message;
|
||||||
final isSelf = widget.message.isSelf ?? true;
|
final isSelf = widget.message.isSelf ?? true;
|
||||||
final isGroup = TencentUtils.checkString(widget.message.groupID) != null;
|
final isGroup = TencentUtils.checkString(widget.message.groupID) != null;
|
||||||
final isAtWhenReply = !isSelf && isGroup && widget.allowAtUserWhenReply && widget.onLongPressForOthersHeadPortrait != null;
|
final isAtWhenReply =
|
||||||
|
!isSelf && isGroup && widget.allowAtUserWhenReply && widget.onLongPressForOthersHeadPortrait != null;
|
||||||
|
|
||||||
/// If replying to a self message, do not add a at tag, only requestFocus.
|
/// If replying to a self message, do not add a at tag, only requestFocus.
|
||||||
widget.onLongPressForOthersHeadPortrait!(!isAtWhenReply ? null : widget.message.sender, !isAtWhenReply ? null : widget.message.nickName);
|
widget.onLongPressForOthersHeadPortrait!(
|
||||||
|
!isAtWhenReply ? null : widget.message.sender, !isAtWhenReply ? null : widget.message.nickName);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if ((widget.toolTipsConfig?.showForwardMessage ?? true) && !model.isVoteMessage(widget.message))
|
if ((widget.toolTipsConfig?.showForwardMessage ?? true) && !model.isVoteMessage(widget.message))
|
||||||
|
|
@ -989,13 +1027,18 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
_onMsgSendFailIconTap(V2TimMessage message, TUIChatSeparateViewModel model) {
|
_onMsgSendFailIconTap(V2TimMessage message, TUIChatSeparateViewModel model) {
|
||||||
final convID = model.conversationID;
|
final convID = model.conversationID;
|
||||||
final convType = model.conversationType;
|
final convType = model.conversationType;
|
||||||
MessageUtils.handleMessageError(model.reSendFailMessage(message: message, convType: convType ?? ConvType.c2c, convID: convID), context);
|
MessageUtils.handleMessageError(
|
||||||
|
model.reSendFailMessage(message: message, convType: convType ?? ConvType.c2c, convID: convID), context);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget renderHoverTipAndReadStatus(TUIChatSeparateViewModel model, bool isSelf, V2TimMessage message, bool isPeerRead, TUITheme theme, bool isDownloadWaiting) {
|
Widget renderHoverTipAndReadStatus(TUIChatSeparateViewModel model, bool isSelf, V2TimMessage message, bool isPeerRead,
|
||||||
|
TUITheme theme, bool isDownloadWaiting) {
|
||||||
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
final customHoverBar = widget.customMessageHoverBarOnDesktop != null ? widget.customMessageHoverBarOnDesktop!(message) : null;
|
final customHoverBar =
|
||||||
final wideHoverTipList = (model.chatConfig.isUseMessageHoverBarOnDesktop && customHoverBar == null) ? getWideMessageHoverControlBar(model, theme) : [];
|
widget.customMessageHoverBarOnDesktop != null ? widget.customMessageHoverBarOnDesktop!(message) : null;
|
||||||
|
final wideHoverTipList = (model.chatConfig.isUseMessageHoverBarOnDesktop && customHoverBar == null)
|
||||||
|
? getWideMessageHoverControlBar(model, theme)
|
||||||
|
: [];
|
||||||
final lastItemName = wideHoverTipList.isNotEmpty ? wideHoverTipList.last.name : "";
|
final lastItemName = wideHoverTipList.isNotEmpty ? wideHoverTipList.last.name : "";
|
||||||
|
|
||||||
// 满足条件延迟 1 秒渲染,否则立即渲染
|
// 满足条件延迟 1 秒渲染,否则立即渲染
|
||||||
|
|
@ -1011,9 +1054,13 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
if (isDesktopScreen && isShowWideToolTip && customHoverBar == null && !((widget.message.elemType == 6 && isDownloadWaiting)))
|
if (isDesktopScreen &&
|
||||||
|
isShowWideToolTip &&
|
||||||
|
customHoverBar == null &&
|
||||||
|
!((widget.message.elemType == 6 && isDownloadWaiting)))
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(4), border: Border.all(color: hexToColor("d9dde0"), width: 1)),
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(4), border: Border.all(color: hexToColor("d9dde0"), width: 1)),
|
||||||
margin: const EdgeInsets.symmetric(horizontal: 4),
|
margin: const EdgeInsets.symmetric(horizontal: 4),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: wideHoverTipList
|
children: wideHoverTipList
|
||||||
|
|
@ -1046,7 +1093,8 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (isDesktopScreen && isShowWideToolTip && customHoverBar != null) customHoverBar,
|
if (isDesktopScreen && isShowWideToolTip && customHoverBar != null) customHoverBar,
|
||||||
if (!isDesktopScreen || (model.chatConfig.isUseMessageHoverBarOnDesktop && customHoverBar == null && !isShowWideToolTip))
|
if (!isDesktopScreen ||
|
||||||
|
(model.chatConfig.isUseMessageHoverBarOnDesktop && customHoverBar == null && !isShowWideToolTip))
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|
@ -1081,7 +1129,8 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (model.chatConfig.isShowReadingStatus &&
|
if (model.chatConfig.isShowReadingStatus &&
|
||||||
isSelf && message.status == MessageStatus.V2TIM_MSG_STATUS_SEND_SUCC &&
|
isSelf &&
|
||||||
|
message.status == MessageStatus.V2TIM_MSG_STATUS_SEND_SUCC &&
|
||||||
(message.needReadReceipt ?? false) &&
|
(message.needReadReceipt ?? false) &&
|
||||||
!model.isVoteMessage(widget.message))
|
!model.isVoteMessage(widget.message))
|
||||||
TIMUIKitMessageReadReceipt(
|
TIMUIKitMessageReadReceipt(
|
||||||
|
|
@ -1095,7 +1144,8 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final TUIChatSeparateViewModel model = Provider.of<TUIChatSeparateViewModel>(context);
|
final TUIChatSeparateViewModel model = Provider.of<TUIChatSeparateViewModel>(context);
|
||||||
final isDownloadWaiting = context.select<TUIChatGlobalModel, bool>((value) => value.isWaiting(widget.message.msgID ?? ""));
|
final isDownloadWaiting =
|
||||||
|
context.select<TUIChatGlobalModel, bool>((value) => value.isWaiting(widget.message.msgID ?? ""));
|
||||||
final TUITheme theme = value.theme;
|
final TUITheme theme = value.theme;
|
||||||
final message = widget.message;
|
final message = widget.message;
|
||||||
final msgType = message.elemType;
|
final msgType = message.elemType;
|
||||||
|
|
@ -1139,8 +1189,16 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRevokedMsg) {
|
if (isRevokedMsg) {
|
||||||
final displayName = isAdminRevoke ? TIM_t("管理员") : (isSelf ? TIM_t("您") : TencentUtils.checkString(message.nickName) ?? TencentUtils.checkString(message.sender) ?? message.userID);
|
final displayName = isAdminRevoke
|
||||||
return isSelf && isRevokeEditable && isRevocable(message.timestamp!) ? _selfRevokeEditMessageBuilder(theme, model) : _revokedMessageBuilder(theme, displayName ?? "");
|
? TIM_t("管理员")
|
||||||
|
: (isSelf
|
||||||
|
? TIM_t("您")
|
||||||
|
: TencentUtils.checkString(message.nickName) ??
|
||||||
|
TencentUtils.checkString(message.sender) ??
|
||||||
|
message.userID);
|
||||||
|
return isSelf && isRevokeEditable && isRevocable(message.timestamp!)
|
||||||
|
? _selfRevokeEditMessageBuilder(theme, model)
|
||||||
|
: _revokedMessageBuilder(theme, displayName ?? "");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用自定义行
|
// 使用自定义行
|
||||||
|
|
@ -1159,226 +1217,243 @@ class _TIMUIKItHistoryMessageListItemState extends TIMUIKitState<TIMUIKitHistory
|
||||||
}
|
}
|
||||||
|
|
||||||
return VisibilityDetector(
|
return VisibilityDetector(
|
||||||
key: Key(message.id ?? message.msgID!),
|
key: Key(message.id ?? message.msgID!),
|
||||||
// 判断消息是否可见
|
// 判断消息是否可见
|
||||||
onVisibilityChanged: (visibilityInfo) {
|
onVisibilityChanged: (visibilityInfo) {
|
||||||
var visiblePercentage = visibilityInfo.visibleFraction * 100;
|
var visiblePercentage = visibilityInfo.visibleFraction * 100;
|
||||||
if (visiblePercentage > 50) {
|
if (visiblePercentage > 50) {
|
||||||
model.addToMessageReadReceiptList(message);
|
model.addToMessageReadReceiptList(message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (context, constraints) => Container(
|
builder: (context, constraints) => Container(
|
||||||
padding: EdgeInsets.only(left: isSelf ? 0 : 16, right: isSelf ? 16 : 0),
|
padding: EdgeInsets.only(left: isSelf ? 0 : 16, right: isSelf ? 16 : 0),
|
||||||
margin: widget.padding ?? const EdgeInsets.only(bottom: 20),
|
margin: widget.padding ?? const EdgeInsets.only(bottom: 20),
|
||||||
child: Row(
|
child: Row(
|
||||||
key: _key,
|
key: _key,
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (model.isMultiSelect)
|
if (model.isMultiSelect)
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(right: 12, top: 10, left: isSelf ? 16 : 0),
|
margin: EdgeInsets.only(right: 12, top: 10, left: isSelf ? 16 : 0),
|
||||||
child: CheckBoxButton(
|
child: CheckBoxButton(
|
||||||
isChecked: model.getSelectedMessageList().contains(message),
|
isChecked: model.getSelectedMessageList().contains(message),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
model.setMessageItemChecked(message, value);
|
model.setMessageItemChecked(message, value);
|
||||||
},
|
},
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Expanded(
|
),
|
||||||
child: MouseRegion(
|
Expanded(
|
||||||
onEnter: (_) {
|
child: MouseRegion(
|
||||||
if (isDesktopScreen && model.chatConfig.isUseMessageHoverBarOnDesktop) {
|
onEnter: (_) {
|
||||||
|
if (isDesktopScreen && model.chatConfig.isUseMessageHoverBarOnDesktop) {
|
||||||
|
setState(() {
|
||||||
|
isShowWideToolTip = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onExit: (_) {
|
||||||
|
if (isDesktopScreen && model.chatConfig.isUseMessageHoverBarOnDesktop) {
|
||||||
|
Tooltip.dismissAllToolTips();
|
||||||
|
Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
setState(() {
|
setState(() {
|
||||||
isShowWideToolTip = true;
|
isShowWideToolTip = false;
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: GestureDetector(
|
||||||
|
behavior: model.isMultiSelect ? HitTestBehavior.translucent : null,
|
||||||
|
onTap: () {
|
||||||
|
if (model.isMultiSelect) {
|
||||||
|
final checked = model.getSelectedMessageList().contains(message);
|
||||||
|
model.setMessageItemChecked(message, !checked);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onExit: (_) {
|
child: Row(
|
||||||
if (isDesktopScreen && model.chatConfig.isUseMessageHoverBarOnDesktop) {
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
Tooltip.dismissAllToolTips();
|
mainAxisAlignment: isSelf ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||||
Future.delayed(const Duration(milliseconds: 100), () {
|
children: [
|
||||||
setState(() {
|
if (!isSelf && widget.showAvatar)
|
||||||
isShowWideToolTip = false;
|
GestureDetector(
|
||||||
});
|
onLongPress: () {
|
||||||
});
|
if (widget.onLongPressForOthersHeadPortrait != null) {}
|
||||||
}
|
if (model.chatConfig.isAllowLongPressAvatarToAt) {
|
||||||
},
|
widget.onLongPressForOthersHeadPortrait!(message.sender, message.nickName);
|
||||||
child: GestureDetector(
|
}
|
||||||
behavior: model.isMultiSelect ? HitTestBehavior.translucent : null,
|
},
|
||||||
onTap: () {
|
onTapDown: isDesktopScreen
|
||||||
if (model.isMultiSelect) {
|
? (details) {
|
||||||
final checked = model.getSelectedMessageList().contains(message);
|
if (widget.onTapForOthersPortrait != null && widget.allowAvatarTap) {
|
||||||
model.setMessageItemChecked(message, !checked);
|
widget.onTapForOthersPortrait!(message.sender ?? "", details);
|
||||||
} else {
|
}
|
||||||
return;
|
}
|
||||||
}
|
: null,
|
||||||
},
|
onTap: isDesktopScreen
|
||||||
child: Row(
|
? null
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
: () {
|
||||||
mainAxisAlignment: isSelf ? MainAxisAlignment.end : MainAxisAlignment.start,
|
if (widget.onTapForOthersPortrait != null && widget.allowAvatarTap) {
|
||||||
children: [
|
widget.onTapForOthersPortrait!(message.sender ?? "", TapDownDetails());
|
||||||
if (!isSelf && widget.showAvatar)
|
}
|
||||||
GestureDetector(
|
},
|
||||||
onLongPress: () {
|
onSecondaryTap: isDesktopScreen
|
||||||
if (widget.onLongPressForOthersHeadPortrait != null) {}
|
? null
|
||||||
if (model.chatConfig.isAllowLongPressAvatarToAt) {
|
: () {
|
||||||
widget.onLongPressForOthersHeadPortrait!(message.sender, message.nickName);
|
if (widget.onSecondaryTapForOthersPortrait != null && widget.allowAvatarTap) {
|
||||||
}
|
widget.onSecondaryTapForOthersPortrait!(message.sender ?? "", TapDownDetails());
|
||||||
},
|
}
|
||||||
onTapDown: isDesktopScreen
|
},
|
||||||
? (details) {
|
onSecondaryTapDown: isDesktopScreen
|
||||||
|
? (details) {
|
||||||
|
if (widget.onSecondaryTapForOthersPortrait != null && widget.allowAvatarTap) {
|
||||||
|
widget.onSecondaryTapForOthersPortrait!(message.sender ?? "", details);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
child: widget.userAvatarBuilder != null
|
||||||
|
? widget.userAvatarBuilder!(context, message)
|
||||||
|
: Container(
|
||||||
|
margin: (isSelf && isShowNickNameForSelf) || (!isSelf && isShowNickNameForOthers)
|
||||||
|
? const EdgeInsets.only(top: 2)
|
||||||
|
: null,
|
||||||
|
child: SizedBox(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
child: Avatar(
|
||||||
|
faceUrl: message.faceUrl ?? "",
|
||||||
|
showName: MessageUtils.getDisplayName(message),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (isSelf && widget.message.elemType == 6 && isDownloadWaiting)
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(top: 46, right: 10),
|
||||||
|
child: LoadingAnimationWidget.threeArchedCircle(
|
||||||
|
color: theme.weakTextColor ?? Colors.grey,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
margin: widget.showAvatar
|
||||||
|
? (isSelf ? const EdgeInsets.only(right: 13) : const EdgeInsets.only(left: 13))
|
||||||
|
: null,
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: isSelf ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
if ((isSelf && isShowNickNameForSelf) || (!isSelf && isShowNickNameForOthers))
|
||||||
|
widget.topRowBuilder != null
|
||||||
|
? widget.topRowBuilder!(context, message)
|
||||||
|
: Container(
|
||||||
|
// margin: const EdgeInsets.only(bottom: 4),
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width / 1.7),
|
||||||
|
child: Text(
|
||||||
|
MessageUtils.getDisplayName(message),
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: widget.themeData?.nickNameTextStyle ??
|
||||||
|
TextStyle(fontSize: 12, color: theme.weakTextColor),
|
||||||
|
),
|
||||||
|
)),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
if (isSelf)
|
||||||
|
renderHoverTipAndReadStatus(
|
||||||
|
model, isSelf, message, isPeerRead, theme, isDownloadWaiting),
|
||||||
|
Container(
|
||||||
|
constraints: BoxConstraints(
|
||||||
|
maxWidth: constraints.maxWidth * 0.77,
|
||||||
|
),
|
||||||
|
child: Builder(builder: (context) {
|
||||||
|
return GestureDetector(
|
||||||
|
child: IgnorePointer(
|
||||||
|
ignoring: model.isMultiSelect,
|
||||||
|
child: _getMessageItemBuilder(message, message.status, model)),
|
||||||
|
onSecondaryTapDown: (details) {
|
||||||
|
if (widget.onLongPress != null) {
|
||||||
|
widget.onLongPress!(context, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!PlatformUtils().isMobile) {
|
||||||
|
if (widget.allowLongPress) {
|
||||||
|
_onOpenToolTip(context, message, model, theme, details, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLongPress: () {
|
||||||
|
if (widget.onLongPress != null) {
|
||||||
|
widget.onLongPress!(context, message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (widget.allowLongPress && !isDesktopScreen) {
|
||||||
|
_onOpenToolTip(context, message, model, theme, null, false, false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onTapDown: (details) {
|
||||||
|
_tapDetails = details;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
if (!isSelf &&
|
||||||
|
message.elemType == MessageElemType.V2TIM_ELEM_TYPE_SOUND &&
|
||||||
|
message.localCustomInt != null &&
|
||||||
|
message.localCustomInt != HistoryMessageDartConstant.read)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 5, bottom: 12),
|
||||||
|
child: Icon(Icons.circle, color: theme.cautionColor, size: 10)),
|
||||||
|
if (!isSelf)
|
||||||
|
renderHoverTipAndReadStatus(
|
||||||
|
model, isSelf, message, isPeerRead, theme, isDownloadWaiting),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
TIMUIKitTextTranslationElem(
|
||||||
|
message: message,
|
||||||
|
customEmojiStickerList: widget.customEmojiStickerList,
|
||||||
|
isFromSelf: message.isSelf ?? true,
|
||||||
|
isShowJump: false,
|
||||||
|
clearJump: () {},
|
||||||
|
chatModel: model),
|
||||||
|
if (widget.bottomRowBuilder != null) widget.bottomRowBuilder!(context, message)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (!isSelf && widget.message.elemType == 6 && isDownloadWaiting)
|
||||||
|
Container(
|
||||||
|
margin: const EdgeInsets.only(top: 46, left: 10),
|
||||||
|
child: LoadingAnimationWidget.threeArchedCircle(
|
||||||
|
color: theme.weakTextColor ?? Colors.grey,
|
||||||
|
size: 20,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
if (isSelf && widget.showAvatar)
|
||||||
|
widget.userAvatarBuilder != null
|
||||||
|
? widget.userAvatarBuilder!(context, message)
|
||||||
|
: SizedBox(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
child: InkWell(
|
||||||
|
onTapDown: (details) {
|
||||||
if (widget.onTapForOthersPortrait != null && widget.allowAvatarTap) {
|
if (widget.onTapForOthersPortrait != null && widget.allowAvatarTap) {
|
||||||
widget.onTapForOthersPortrait!(message.sender ?? "", details);
|
widget.onTapForOthersPortrait!(message.sender ?? "", details);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
: null,
|
|
||||||
onTap: isDesktopScreen
|
|
||||||
? null
|
|
||||||
: () {
|
|
||||||
if (widget.onTapForOthersPortrait != null && widget.allowAvatarTap) {
|
|
||||||
widget.onTapForOthersPortrait!(message.sender ?? "", TapDownDetails());
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onSecondaryTap: isDesktopScreen
|
child: Avatar(
|
||||||
? null
|
faceUrl: message.faceUrl ?? "", showName: MessageUtils.getDisplayName(message)),
|
||||||
: () {
|
|
||||||
if (widget.onSecondaryTapForOthersPortrait != null && widget.allowAvatarTap) {
|
|
||||||
widget.onSecondaryTapForOthersPortrait!(message.sender ?? "", TapDownDetails());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onSecondaryTapDown: isDesktopScreen
|
|
||||||
? (details) {
|
|
||||||
if (widget.onSecondaryTapForOthersPortrait != null && widget.allowAvatarTap) {
|
|
||||||
widget.onSecondaryTapForOthersPortrait!(message.sender ?? "", details);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
: null,
|
|
||||||
child: widget.userAvatarBuilder != null
|
|
||||||
? widget.userAvatarBuilder!(context, message)
|
|
||||||
: Container(
|
|
||||||
margin: (isSelf && isShowNickNameForSelf) || (!isSelf && isShowNickNameForOthers) ? const EdgeInsets.only(top: 2) : null,
|
|
||||||
child: SizedBox(
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
child: Avatar(
|
|
||||||
faceUrl: message.faceUrl ?? "",
|
|
||||||
showName: MessageUtils.getDisplayName(message),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (isSelf && widget.message.elemType == 6 && isDownloadWaiting)
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(top: 46, right: 10),
|
|
||||||
child: LoadingAnimationWidget.threeArchedCircle(
|
|
||||||
color: theme.weakTextColor ?? Colors.grey,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
Container(
|
|
||||||
margin: widget.showAvatar ? (isSelf ? const EdgeInsets.only(right: 13) : const EdgeInsets.only(left: 13)) : null,
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: isSelf ? CrossAxisAlignment.end : CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
if ((isSelf && isShowNickNameForSelf) || (!isSelf && isShowNickNameForOthers))
|
|
||||||
widget.topRowBuilder != null
|
|
||||||
? widget.topRowBuilder!(context, message)
|
|
||||||
: Container(
|
|
||||||
// margin: const EdgeInsets.only(bottom: 4),
|
|
||||||
child: ConstrainedBox(
|
|
||||||
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width / 1.7),
|
|
||||||
child: Text(
|
|
||||||
MessageUtils.getDisplayName(message),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: widget.themeData?.nickNameTextStyle ?? TextStyle(fontSize: 12, color: theme.weakTextColor),
|
|
||||||
),
|
|
||||||
)),
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.end,
|
|
||||||
children: [
|
|
||||||
if (isSelf) renderHoverTipAndReadStatus(model, isSelf, message, isPeerRead, theme, isDownloadWaiting),
|
|
||||||
Container(
|
|
||||||
constraints: BoxConstraints(
|
|
||||||
maxWidth: constraints.maxWidth * 0.77,
|
|
||||||
),
|
|
||||||
child: Builder(builder: (context) {
|
|
||||||
return GestureDetector(
|
|
||||||
child: IgnorePointer(ignoring: model.isMultiSelect, child: _getMessageItemBuilder(message, message.status, model)),
|
|
||||||
onSecondaryTapDown: (details) {
|
|
||||||
if (widget.onLongPress != null) {
|
|
||||||
widget.onLongPress!(context, message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!PlatformUtils().isMobile) {
|
|
||||||
if (widget.allowLongPress) {
|
|
||||||
_onOpenToolTip(context, message, model, theme, details, false, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLongPress: () {
|
|
||||||
if (widget.onLongPress != null) {
|
|
||||||
widget.onLongPress!(context, message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (widget.allowLongPress && !isDesktopScreen) {
|
|
||||||
_onOpenToolTip(context, message, model, theme, null, false, false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onTapDown: (details) {
|
|
||||||
_tapDetails = details;
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
if (!isSelf && message.elemType == MessageElemType.V2TIM_ELEM_TYPE_SOUND && message.localCustomInt != null && message.localCustomInt != HistoryMessageDartConstant.read)
|
|
||||||
Padding(padding: const EdgeInsets.only(left: 5, bottom: 12), child: Icon(Icons.circle, color: theme.cautionColor, size: 10)),
|
|
||||||
if (!isSelf) renderHoverTipAndReadStatus(model, isSelf, message, isPeerRead, theme, isDownloadWaiting),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
TIMUIKitTextTranslationElem(
|
|
||||||
message: message,
|
|
||||||
customEmojiStickerList: widget.customEmojiStickerList,
|
|
||||||
isFromSelf: message.isSelf ?? true,
|
|
||||||
isShowJump: false,
|
|
||||||
clearJump: () {},
|
|
||||||
chatModel: model),
|
|
||||||
if (widget.bottomRowBuilder != null) widget.bottomRowBuilder!(context, message)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (!isSelf && widget.message.elemType == 6 && isDownloadWaiting)
|
|
||||||
Container(
|
|
||||||
margin: const EdgeInsets.only(top: 46, left: 10),
|
|
||||||
child: LoadingAnimationWidget.threeArchedCircle(
|
|
||||||
color: theme.weakTextColor ?? Colors.grey,
|
|
||||||
size: 20,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (isSelf && widget.showAvatar)
|
|
||||||
widget.userAvatarBuilder != null
|
|
||||||
? widget.userAvatarBuilder!(context, message)
|
|
||||||
: SizedBox(
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
child: InkWell(
|
|
||||||
onTapDown: (details) {
|
|
||||||
if (widget.onTapForOthersPortrait != null && widget.allowAvatarTap) {
|
|
||||||
widget.onTapForOthersPortrait!(message.sender ?? "", details);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Avatar(faceUrl: message.faceUrl ?? "", showName: MessageUtils.getDisplayName(message)),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,10 @@ import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
|
|
@ -45,8 +47,7 @@ class TIMUIKitMessageTooltip extends StatefulWidget {
|
||||||
final bool allowAtUserWhenReply;
|
final bool allowAtUserWhenReply;
|
||||||
|
|
||||||
/// the callback for long press event, except myself avatar
|
/// the callback for long press event, except myself avatar
|
||||||
final Function(String? userId, String? nickName)?
|
final Function(String? userId, String? nickName)? onLongPressForOthersHeadPortrait;
|
||||||
onLongPressForOthersHeadPortrait;
|
|
||||||
|
|
||||||
final bool isUseMessageReaction;
|
final bool isUseMessageReaction;
|
||||||
|
|
||||||
|
|
@ -87,11 +88,9 @@ class TIMUIKitMessageTooltip extends StatefulWidget {
|
||||||
State<StatefulWidget> createState() => TIMUIKitMessageTooltipState();
|
State<StatefulWidget> createState() => TIMUIKitMessageTooltipState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class TIMUIKitMessageTooltipState
|
class TIMUIKitMessageTooltipState extends TIMUIKitState<TIMUIKitMessageTooltip> {
|
||||||
extends TIMUIKitState<TIMUIKitMessageTooltip> {
|
|
||||||
final TUIChatGlobalModel globalModal = serviceLocator<TUIChatGlobalModel>();
|
final TUIChatGlobalModel globalModal = serviceLocator<TUIChatGlobalModel>();
|
||||||
final TUISelfInfoViewModel selfInfoViewModel =
|
final TUISelfInfoViewModel selfInfoViewModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
bool isShowMoreSticker = false;
|
bool isShowMoreSticker = false;
|
||||||
bool fileBeenDownloaded = false;
|
bool fileBeenDownloaded = false;
|
||||||
String filePath = "";
|
String filePath = "";
|
||||||
|
|
@ -105,9 +104,7 @@ class TIMUIKitMessageTooltipState
|
||||||
|
|
||||||
hasFile() {
|
hasFile() {
|
||||||
if (PlatformUtils().isMobile ||
|
if (PlatformUtils().isMobile ||
|
||||||
(widget.message.fileElem == null &&
|
(widget.message.fileElem == null && widget.message.imageElem == null && widget.message.videoElem == null)) {
|
||||||
widget.message.imageElem == null &&
|
|
||||||
widget.message.videoElem == null)) {
|
|
||||||
fileBeenDownloaded = false;
|
fileBeenDownloaded = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -117,8 +114,7 @@ class TIMUIKitMessageTooltipState
|
||||||
}
|
}
|
||||||
if (PlatformUtils().isDesktop) {
|
if (PlatformUtils().isDesktop) {
|
||||||
if (widget.message.fileElem != null) {
|
if (widget.message.fileElem != null) {
|
||||||
String savePath = TencentUtils.checkString(
|
String savePath = TencentUtils.checkString(globalModal.getFileMessageLocation(widget.message.msgID)) ??
|
||||||
globalModal.getFileMessageLocation(widget.message.msgID)) ??
|
|
||||||
TencentUtils.checkString(widget.message.fileElem!.localUrl) ??
|
TencentUtils.checkString(widget.message.fileElem!.localUrl) ??
|
||||||
widget.message.fileElem?.path ??
|
widget.message.fileElem?.path ??
|
||||||
"";
|
"";
|
||||||
|
|
@ -129,17 +125,13 @@ class TIMUIKitMessageTooltipState
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (widget.message.imageElem != null) {
|
} else if (widget.message.imageElem != null) {
|
||||||
if (TencentUtils.checkString(
|
if (TencentUtils.checkString(widget.message.imageElem!.imageList![0]!.localUrl) != null &&
|
||||||
widget.message.imageElem!.imageList![0]!.localUrl) !=
|
File(widget.message.imageElem!.imageList![0]!.localUrl!).existsSync()) {
|
||||||
null &&
|
|
||||||
File(widget.message.imageElem!.imageList![0]!.localUrl!)
|
|
||||||
.existsSync()) {
|
|
||||||
fileBeenDownloaded = true;
|
fileBeenDownloaded = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (widget.message.videoElem != null) {
|
} else if (widget.message.videoElem != null) {
|
||||||
if (TencentUtils.checkString(widget.message.videoElem!.localVideoUrl) !=
|
if (TencentUtils.checkString(widget.message.videoElem!.localVideoUrl) != null &&
|
||||||
null &&
|
|
||||||
File(widget.message.videoElem!.localVideoUrl!).existsSync()) {
|
File(widget.message.videoElem!.localVideoUrl!).existsSync()) {
|
||||||
fileBeenDownloaded = true;
|
fileBeenDownloaded = true;
|
||||||
return;
|
return;
|
||||||
|
|
@ -150,8 +142,7 @@ class TIMUIKitMessageTooltipState
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRevocable(int timestamp, int upperTimeLimit) =>
|
bool isRevocable(int timestamp, int upperTimeLimit) =>
|
||||||
((DateTime.now().millisecondsSinceEpoch / 1000).ceil() - timestamp <
|
((DateTime.now().millisecondsSinceEpoch / 1000).ceil() - timestamp < upperTimeLimit) &&
|
||||||
upperTimeLimit) &&
|
|
||||||
(widget.message.isSelf ?? true);
|
(widget.message.isSelf ?? true);
|
||||||
|
|
||||||
Widget ItemInkWell({
|
Widget ItemInkWell({
|
||||||
|
|
@ -173,8 +164,7 @@ class TIMUIKitMessageTooltipState
|
||||||
|
|
||||||
bool isAdminCanRecall() {
|
bool isAdminCanRecall() {
|
||||||
if (widget.model.chatConfig.isGroupAdminRecallEnabled) {
|
if (widget.model.chatConfig.isGroupAdminRecallEnabled) {
|
||||||
final selfMemberInfo =
|
final selfMemberInfo = widget.groupMemberInfo ?? widget.model.selfMemberInfo;
|
||||||
widget.groupMemberInfo ?? widget.model.selfMemberInfo;
|
|
||||||
final selfRole = selfMemberInfo?.role;
|
final selfRole = selfMemberInfo?.role;
|
||||||
return selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN ||
|
return selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN ||
|
||||||
selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER;
|
selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER;
|
||||||
|
|
@ -183,36 +173,28 @@ class TIMUIKitMessageTooltipState
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildLongPressTipItem(
|
_buildLongPressTipItem(TUITheme theme, TUIChatSeparateViewModel model, V2TimMessage message) {
|
||||||
TUITheme theme, TUIChatSeparateViewModel model, V2TimMessage message) {
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
final isDesktopScreen =
|
final isCanRevokeSelf = isRevocable(widget.message.timestamp!, model.chatConfig.upperRecallTime);
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
final shouldShowRevokeAction =
|
||||||
final isCanRevokeSelf = isRevocable(
|
(isCanRevokeSelf || isAdminCanRecall()) && widget.message.status != MessageStatus.V2TIM_MSG_STATUS_SEND_FAIL;
|
||||||
widget.message.timestamp!, model.chatConfig.upperRecallTime);
|
final shouldShowReplyAction =
|
||||||
final shouldShowRevokeAction = (isCanRevokeSelf || isAdminCanRecall()) &&
|
!(widget.message.customElem?.data != null && MessageUtils.isCallingData(widget.message.customElem!.data!));
|
||||||
widget.message.status != MessageStatus.V2TIM_MSG_STATUS_SEND_FAIL;
|
final shouldShowForwardAction =
|
||||||
final shouldShowReplyAction = !(widget.message.customElem?.data != null &&
|
!(widget.message.customElem?.data != null && MessageUtils.isCallingData(widget.message.customElem!.data!));
|
||||||
MessageUtils.isCallingData(widget.message.customElem!.data!));
|
|
||||||
final shouldShowForwardAction = !(widget.message.customElem?.data != null &&
|
|
||||||
MessageUtils.isCallingData(widget.message.customElem!.data!));
|
|
||||||
final tooltipsConfig = widget.toolTipsConfig;
|
final tooltipsConfig = widget.toolTipsConfig;
|
||||||
final messageCanCopy = widget.message.elemType ==
|
final messageCanCopy = widget.message.elemType == MessageElemType.V2TIM_ELEM_TYPE_TEXT ||
|
||||||
MessageElemType.V2TIM_ELEM_TYPE_TEXT ||
|
(isDesktopScreen && widget.message.elemType == MessageElemType.V2TIM_ELEM_TYPE_IMAGE && fileBeenDownloaded);
|
||||||
(isDesktopScreen &&
|
|
||||||
widget.message.elemType == MessageElemType.V2TIM_ELEM_TYPE_IMAGE &&
|
|
||||||
fileBeenDownloaded);
|
|
||||||
bool showTranslation = true;
|
bool showTranslation = true;
|
||||||
if (widget.message.localCustomData != null) {
|
if (widget.message.localCustomData != null) {
|
||||||
final LocalCustomDataModel localCustomData = LocalCustomDataModel.fromMap(
|
final LocalCustomDataModel localCustomData =
|
||||||
json.decode(TencentUtils.checkString(widget.message.localCustomData) ?? "{}"));
|
LocalCustomDataModel.fromMap(json.decode(TencentUtils.checkString(widget.message.localCustomData) ?? "{}"));
|
||||||
if (localCustomData.translatedText != null && localCustomData.translatedText != "") {
|
if (localCustomData.translatedText != null && localCustomData.translatedText != "") {
|
||||||
showTranslation = false;
|
showTranslation = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final dynamicQuote = model.chatConfig.isAtWhenReplyDynamic?.call(widget.message);
|
||||||
final dynamicQuote =
|
|
||||||
model.chatConfig.isAtWhenReplyDynamic?.call(widget.message);
|
|
||||||
|
|
||||||
final List<MessageToolTipItem> defaultTipsList = [
|
final List<MessageToolTipItem> defaultTipsList = [
|
||||||
if (fileBeenDownloaded)
|
if (fileBeenDownloaded)
|
||||||
|
|
@ -241,8 +223,7 @@ class TIMUIKitMessageTooltipState
|
||||||
onClick: () => _onTap("forwardMessage", model)),
|
onClick: () => _onTap("forwardMessage", model)),
|
||||||
if (shouldShowReplyAction)
|
if (shouldShowReplyAction)
|
||||||
MessageToolTipItem(
|
MessageToolTipItem(
|
||||||
label: TIM_t(
|
label: TIM_t((dynamicQuote ?? model.chatConfig.isAtWhenReply) ? "回复" : "引用"),
|
||||||
(dynamicQuote ?? model.chatConfig.isAtWhenReply) ? "回复" : "引用"),
|
|
||||||
id: "replyMessage",
|
id: "replyMessage",
|
||||||
iconImageAsset: "images/reply_message.png",
|
iconImageAsset: "images/reply_message.png",
|
||||||
onClick: () => _onTap("replyMessage", model)),
|
onClick: () => _onTap("replyMessage", model)),
|
||||||
|
|
@ -278,12 +259,10 @@ class TIMUIKitMessageTooltipState
|
||||||
return tooltipsConfig.showCopyMessage;
|
return tooltipsConfig.showCopyMessage;
|
||||||
}
|
}
|
||||||
if (type == "forwardMessage") {
|
if (type == "forwardMessage") {
|
||||||
return tooltipsConfig.showForwardMessage &&
|
return tooltipsConfig.showForwardMessage && !(isDesktopScreen && widget.iSUseDefaultHoverBar);
|
||||||
!(isDesktopScreen && widget.iSUseDefaultHoverBar);
|
|
||||||
}
|
}
|
||||||
if (type == "replyMessage") {
|
if (type == "replyMessage") {
|
||||||
return tooltipsConfig.showReplyMessage &&
|
return tooltipsConfig.showReplyMessage && !(isDesktopScreen && widget.iSUseDefaultHoverBar);
|
||||||
!(isDesktopScreen && widget.iSUseDefaultHoverBar);
|
|
||||||
}
|
}
|
||||||
if (type == "delete") {
|
if (type == "delete") {
|
||||||
return (!PlatformUtils().isWeb) && tooltipsConfig.showDeleteMessage;
|
return (!PlatformUtils().isWeb) && tooltipsConfig.showDeleteMessage;
|
||||||
|
|
@ -296,18 +275,15 @@ class TIMUIKitMessageTooltipState
|
||||||
return tooltipsConfig.showRecallMessage;
|
return tooltipsConfig.showRecallMessage;
|
||||||
}
|
}
|
||||||
if (type == "translate") {
|
if (type == "translate") {
|
||||||
return tooltipsConfig.showTranslation &&
|
return tooltipsConfig.showTranslation && widget.message.elemType == MessageElemType.V2TIM_ELEM_TYPE_TEXT;
|
||||||
widget.message.elemType == MessageElemType.V2TIM_ELEM_TYPE_TEXT;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<MessageToolTipItem>? customList =
|
final List<MessageToolTipItem>? customList = widget.toolTipsConfig?.additionalMessageToolTips != null
|
||||||
widget.toolTipsConfig?.additionalMessageToolTips != null
|
? (widget.toolTipsConfig?.additionalMessageToolTips!(message, widget.onCloseTooltip))
|
||||||
? (widget.toolTipsConfig?.additionalMessageToolTips!(
|
: [];
|
||||||
message, widget.onCloseTooltip))
|
|
||||||
: [];
|
|
||||||
|
|
||||||
List<MessageToolTipItem> formattedTipsList = [
|
List<MessageToolTipItem> formattedTipsList = [
|
||||||
...defaultFormattedTipsList,
|
...defaultFormattedTipsList,
|
||||||
|
|
@ -331,9 +307,7 @@ class TIMUIKitMessageTooltipState
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
item.iconImageAsset,
|
item.iconImageAsset,
|
||||||
package: defaultTipsIds.contains(item.id)
|
package: defaultTipsIds.contains(item.id) ? 'tencent_cloud_chat_uikit' : null,
|
||||||
? 'tencent_cloud_chat_uikit'
|
|
||||||
: null,
|
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|
@ -370,9 +344,7 @@ class TIMUIKitMessageTooltipState
|
||||||
children: [
|
children: [
|
||||||
Image.asset(
|
Image.asset(
|
||||||
item.iconImageAsset,
|
item.iconImageAsset,
|
||||||
package: defaultTipsIds.contains(item.id)
|
package: defaultTipsIds.contains(item.id) ? 'tencent_cloud_chat_uikit' : null,
|
||||||
? 'tencent_cloud_chat_uikit'
|
|
||||||
: null,
|
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|
@ -419,19 +391,16 @@ class TIMUIKitMessageTooltipState
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case "open":
|
case "open":
|
||||||
if (widget.message.fileElem != null) {
|
if (widget.message.fileElem != null) {
|
||||||
_onOpenDesktop(TencentUtils.checkString(
|
_onOpenDesktop(TencentUtils.checkString(globalModal.getFileMessageLocation(widget.message.msgID)) ??
|
||||||
globalModal.getFileMessageLocation(widget.message.msgID)) ??
|
|
||||||
TencentUtils.checkString(widget.message.fileElem!.localUrl) ??
|
TencentUtils.checkString(widget.message.fileElem!.localUrl) ??
|
||||||
widget.message.fileElem?.path ??
|
widget.message.fileElem?.path ??
|
||||||
"");
|
"");
|
||||||
} else if (widget.message.imageElem != null) {
|
} else if (widget.message.imageElem != null) {
|
||||||
_onOpenDesktop(TencentUtils.checkString(
|
_onOpenDesktop(TencentUtils.checkString(widget.message.imageElem!.imageList?[0]?.localUrl) ??
|
||||||
widget.message.imageElem!.imageList?[0]?.localUrl) ??
|
|
||||||
TencentUtils.checkString(widget.message.imageElem?.path) ??
|
TencentUtils.checkString(widget.message.imageElem?.path) ??
|
||||||
"");
|
"");
|
||||||
} else if (widget.message.videoElem != null) {
|
} else if (widget.message.videoElem != null) {
|
||||||
_onOpenDesktop(TencentUtils.checkString(
|
_onOpenDesktop(TencentUtils.checkString(widget.message.videoElem!.localVideoUrl) ??
|
||||||
widget.message.videoElem!.localVideoUrl) ??
|
|
||||||
TencentUtils.checkString(widget.message.videoElem?.videoPath) ??
|
TencentUtils.checkString(widget.message.videoElem?.videoPath) ??
|
||||||
"");
|
"");
|
||||||
}
|
}
|
||||||
|
|
@ -439,19 +408,16 @@ class TIMUIKitMessageTooltipState
|
||||||
case "finder":
|
case "finder":
|
||||||
String savePath = "";
|
String savePath = "";
|
||||||
if (widget.message.fileElem != null) {
|
if (widget.message.fileElem != null) {
|
||||||
savePath = (TencentUtils.checkString(
|
savePath = (TencentUtils.checkString(globalModal.getFileMessageLocation(widget.message.msgID)) ??
|
||||||
globalModal.getFileMessageLocation(widget.message.msgID)) ??
|
|
||||||
TencentUtils.checkString(widget.message.fileElem!.localUrl) ??
|
TencentUtils.checkString(widget.message.fileElem!.localUrl) ??
|
||||||
widget.message.fileElem?.path ??
|
widget.message.fileElem?.path ??
|
||||||
"");
|
"");
|
||||||
} else if (widget.message.imageElem != null) {
|
} else if (widget.message.imageElem != null) {
|
||||||
savePath = (TencentUtils.checkString(
|
savePath = (TencentUtils.checkString(widget.message.imageElem!.imageList?[0]?.localUrl) ??
|
||||||
widget.message.imageElem!.imageList?[0]?.localUrl) ??
|
|
||||||
TencentUtils.checkString(widget.message.imageElem?.path) ??
|
TencentUtils.checkString(widget.message.imageElem?.path) ??
|
||||||
"");
|
"");
|
||||||
} else if (widget.message.videoElem != null) {
|
} else if (widget.message.videoElem != null) {
|
||||||
savePath = (TencentUtils.checkString(
|
savePath = (TencentUtils.checkString(widget.message.videoElem!.localVideoUrl) ??
|
||||||
widget.message.videoElem!.localVideoUrl) ??
|
|
||||||
TencentUtils.checkString(widget.message.videoElem?.videoPath) ??
|
TencentUtils.checkString(widget.message.videoElem?.videoPath) ??
|
||||||
"");
|
"");
|
||||||
}
|
}
|
||||||
|
|
@ -462,10 +428,7 @@ class TIMUIKitMessageTooltipState
|
||||||
model.deleteMsg(msgID, webMessageInstance: messageItem.messageFromWeb);
|
model.deleteMsg(msgID, webMessageInstance: messageItem.messageFromWeb);
|
||||||
break;
|
break;
|
||||||
case "revoke":
|
case "revoke":
|
||||||
model.revokeMsg(
|
model.revokeMsg(msgID, !isRevocable(widget.message.timestamp!, model.chatConfig.upperRecallTime),
|
||||||
msgID,
|
|
||||||
!isRevocable(
|
|
||||||
widget.message.timestamp!, model.chatConfig.upperRecallTime),
|
|
||||||
messageItem.messageFromWeb);
|
messageItem.messageFromWeb);
|
||||||
break;
|
break;
|
||||||
case 'translate':
|
case 'translate':
|
||||||
|
|
@ -488,23 +451,17 @@ class TIMUIKitMessageTooltipState
|
||||||
case "copyMessage":
|
case "copyMessage":
|
||||||
if (widget.message.elemType == MessageElemType.V2TIM_ELEM_TYPE_TEXT) {
|
if (widget.message.elemType == MessageElemType.V2TIM_ELEM_TYPE_TEXT) {
|
||||||
try {
|
try {
|
||||||
await Clipboard.setData(
|
await Clipboard.setData(ClipboardData(text: widget.message.textElem?.text ?? ""));
|
||||||
ClipboardData(text: widget.message.textElem?.text ?? ""));
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("已复制"), infoCode: 6660408));
|
||||||
onTIMCallback(TIMCallback(
|
|
||||||
type: TIMCallbackType.INFO,
|
|
||||||
infoRecommendText: TIM_t("已复制"),
|
|
||||||
infoCode: 6660408));
|
|
||||||
// ignore: empty_catches
|
// ignore: empty_catches
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "replyMessage":
|
case "replyMessage":
|
||||||
model.repliedMessage = widget.message;
|
model.repliedMessage = widget.message;
|
||||||
final dynamicQuote =
|
final dynamicQuote = model.chatConfig.isAtWhenReplyDynamic?.call(widget.message);
|
||||||
model.chatConfig.isAtWhenReplyDynamic?.call(widget.message);
|
|
||||||
final isSelf = widget.message.isSelf ?? true;
|
final isSelf = widget.message.isSelf ?? true;
|
||||||
final isGroup =
|
final isGroup = TencentUtils.checkString(widget.message.groupID) != null;
|
||||||
TencentUtils.checkString(widget.message.groupID) != null;
|
|
||||||
final isAtWhenReply = !isSelf &&
|
final isAtWhenReply = !isSelf &&
|
||||||
isGroup &&
|
isGroup &&
|
||||||
(dynamicQuote ?? widget.allowAtUserWhenReply) &&
|
(dynamicQuote ?? widget.allowAtUserWhenReply) &&
|
||||||
|
|
@ -512,14 +469,10 @@ class TIMUIKitMessageTooltipState
|
||||||
|
|
||||||
/// If replying to a self message, do not add a at tag, only requestFocus.
|
/// If replying to a self message, do not add a at tag, only requestFocus.
|
||||||
widget.onLongPressForOthersHeadPortrait!(
|
widget.onLongPressForOthersHeadPortrait!(
|
||||||
!isAtWhenReply ? null : widget.message.sender,
|
!isAtWhenReply ? null : widget.message.sender, !isAtWhenReply ? null : widget.message.nickName);
|
||||||
!isAtWhenReply ? null : widget.message.nickName);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("暂未实现"), infoCode: 6660409));
|
||||||
type: TIMCallbackType.INFO,
|
|
||||||
infoRecommendText: TIM_t("暂未实现"),
|
|
||||||
infoCode: 6660409));
|
|
||||||
}
|
}
|
||||||
widget.onCloseTooltip();
|
widget.onCloseTooltip();
|
||||||
}
|
}
|
||||||
|
|
@ -527,20 +480,17 @@ class TIMUIKitMessageTooltipState
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final TUITheme theme = value.theme;
|
final TUITheme theme = value.theme;
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider.value(value: widget.model),
|
ChangeNotifierProvider.value(value: widget.model),
|
||||||
],
|
],
|
||||||
builder: (BuildContext context, Widget? w) {
|
builder: (BuildContext context, Widget? w) {
|
||||||
final TUIChatSeparateViewModel model =
|
final TUIChatSeparateViewModel model = Provider.of<TUIChatSeparateViewModel>(context);
|
||||||
Provider.of<TUIChatSeparateViewModel>(context);
|
final bool haveExtraTipsConfig =
|
||||||
final bool haveExtraTipsConfig = widget.toolTipsConfig != null &&
|
widget.toolTipsConfig != null && widget.toolTipsConfig?.additionalItemBuilder != null;
|
||||||
widget.toolTipsConfig?.additionalItemBuilder != null;
|
|
||||||
Widget? extraTipsActionItem = haveExtraTipsConfig
|
Widget? extraTipsActionItem = haveExtraTipsConfig
|
||||||
? widget.toolTipsConfig!.additionalItemBuilder!(
|
? widget.toolTipsConfig!.additionalItemBuilder!(widget.message, widget.onCloseTooltip, null, context)
|
||||||
widget.message, widget.onCloseTooltip, null, context)
|
|
||||||
: null;
|
: null;
|
||||||
final message = widget.message;
|
final message = widget.message;
|
||||||
return Container(
|
return Container(
|
||||||
|
|
@ -563,8 +513,7 @@ class TIMUIKitMessageTooltipState
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
color: isDesktopScreen ? null : Colors.white,
|
color: isDesktopScreen ? null : Colors.white,
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(horizontal: 8, vertical: isDesktopScreen ? 8 : 4),
|
||||||
horizontal: 8, vertical: isDesktopScreen ? 8 : 4),
|
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: min(MediaQuery.of(context).size.width * 0.75, 350),
|
maxWidth: min(MediaQuery.of(context).size.width * 0.75, 350),
|
||||||
|
|
@ -574,8 +523,7 @@ class TIMUIKitMessageTooltipState
|
||||||
children: [
|
children: [
|
||||||
if ((!isDesktopScreen || widget.isShowMoreSticker) &&
|
if ((!isDesktopScreen || widget.isShowMoreSticker) &&
|
||||||
widget.isUseMessageReaction &&
|
widget.isUseMessageReaction &&
|
||||||
widget.selectEmojiPanelPosition ==
|
widget.selectEmojiPanelPosition == SelectEmojiPanelPosition.up)
|
||||||
SelectEmojiPanelPosition.up)
|
|
||||||
TIMUIKitMessageReactionEmojiSelectPanel(
|
TIMUIKitMessageReactionEmojiSelectPanel(
|
||||||
isShowMoreSticker: isShowMoreSticker,
|
isShowMoreSticker: isShowMoreSticker,
|
||||||
onSelect: (int value) => widget.onSelectSticker(value),
|
onSelect: (int value) => widget.onSelectSticker(value),
|
||||||
|
|
@ -587,8 +535,7 @@ class TIMUIKitMessageTooltipState
|
||||||
),
|
),
|
||||||
if (!isDesktopScreen &&
|
if (!isDesktopScreen &&
|
||||||
widget.isUseMessageReaction &&
|
widget.isUseMessageReaction &&
|
||||||
widget.selectEmojiPanelPosition ==
|
widget.selectEmojiPanelPosition == SelectEmojiPanelPosition.up &&
|
||||||
SelectEmojiPanelPosition.up &&
|
|
||||||
isShowMoreSticker == false)
|
isShowMoreSticker == false)
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 6),
|
margin: const EdgeInsets.symmetric(vertical: 6),
|
||||||
|
|
@ -605,40 +552,31 @@ class TIMUIKitMessageTooltipState
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
alignment:
|
alignment: TUIKitScreenUtils.getFormFactor(context) == DeviceType.Mobile
|
||||||
TUIKitScreenUtils.getFormFactor(context) ==
|
? WrapAlignment.start
|
||||||
DeviceType.Mobile
|
: WrapAlignment.start,
|
||||||
? WrapAlignment.start
|
|
||||||
: WrapAlignment.start,
|
|
||||||
spacing: 12,
|
spacing: 12,
|
||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: [
|
children: [
|
||||||
..._buildLongPressTipItem(theme, model, message),
|
..._buildLongPressTipItem(theme, model, message),
|
||||||
if (extraTipsActionItem != null)
|
if (extraTipsActionItem != null) extraTipsActionItem
|
||||||
extraTipsActionItem
|
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
if (!isDesktopScreen && !widget.isUseMessageReaction)
|
if (!isDesktopScreen && !widget.isUseMessageReaction)
|
||||||
ConstrainedBox(
|
ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: min(
|
maxWidth: min(MediaQuery.of(context).size.width * 0.75, 350),
|
||||||
MediaQuery.of(context).size.width * 0.75,
|
|
||||||
350),
|
|
||||||
),
|
),
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
direction: Axis.horizontal,
|
direction: Axis.horizontal,
|
||||||
alignment:
|
alignment: TUIKitScreenUtils.getFormFactor(context) == DeviceType.Mobile
|
||||||
TUIKitScreenUtils.getFormFactor(context) ==
|
? WrapAlignment.spaceBetween
|
||||||
DeviceType.Mobile
|
: WrapAlignment.start,
|
||||||
? WrapAlignment.spaceBetween
|
|
||||||
: WrapAlignment.start,
|
|
||||||
spacing: 4,
|
spacing: 4,
|
||||||
runSpacing: 8,
|
runSpacing: 8,
|
||||||
children: [
|
children: [
|
||||||
..._buildLongPressTipItem(
|
..._buildLongPressTipItem(theme, model, message),
|
||||||
theme, model, message),
|
if (extraTipsActionItem != null) extraTipsActionItem
|
||||||
if (extraTipsActionItem != null)
|
|
||||||
extraTipsActionItem
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -646,15 +584,13 @@ class TIMUIKitMessageTooltipState
|
||||||
Table(columnWidths: const <int, TableColumnWidth>{
|
Table(columnWidths: const <int, TableColumnWidth>{
|
||||||
0: IntrinsicColumnWidth(),
|
0: IntrinsicColumnWidth(),
|
||||||
}, children: <TableRow>[
|
}, children: <TableRow>[
|
||||||
..._buildLongPressTipItem(theme, model, message)
|
..._buildLongPressTipItem(theme, model, message).map((e) => TableRow(children: <Widget>[e]))
|
||||||
.map((e) => TableRow(children: <Widget>[e]))
|
|
||||||
])
|
])
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (!isDesktopScreen &&
|
if (!isDesktopScreen &&
|
||||||
widget.isUseMessageReaction &&
|
widget.isUseMessageReaction &&
|
||||||
widget.selectEmojiPanelPosition ==
|
widget.selectEmojiPanelPosition == SelectEmojiPanelPosition.down &&
|
||||||
SelectEmojiPanelPosition.down &&
|
|
||||||
isShowMoreSticker == false)
|
isShowMoreSticker == false)
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.symmetric(vertical: 6),
|
margin: const EdgeInsets.symmetric(vertical: 6),
|
||||||
|
|
@ -665,8 +601,7 @@ class TIMUIKitMessageTooltipState
|
||||||
color: Colors.black12)),
|
color: Colors.black12)),
|
||||||
if ((!isDesktopScreen || widget.isShowMoreSticker) &&
|
if ((!isDesktopScreen || widget.isShowMoreSticker) &&
|
||||||
widget.isUseMessageReaction &&
|
widget.isUseMessageReaction &&
|
||||||
widget.selectEmojiPanelPosition ==
|
widget.selectEmojiPanelPosition == SelectEmojiPanelPosition.down)
|
||||||
SelectEmojiPanelPosition.down)
|
|
||||||
TIMUIKitMessageReactionEmojiSelectPanel(
|
TIMUIKitMessageReactionEmojiSelectPanel(
|
||||||
isShowMoreSticker: isShowMoreSticker,
|
isShowMoreSticker: isShowMoreSticker,
|
||||||
onSelect: (int value) => widget.onSelectSticker(value),
|
onSelect: (int value) => widget.onSelectSticker(value),
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,14 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_at_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/tim_uikit_text_field_controller.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/tim_uikit_text_field_controller.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
|
|
@ -31,8 +35,7 @@ class TIMUIKitHistoryMessageListContainer extends StatefulWidget {
|
||||||
final Widget Function(BuildContext, V2TimMessage?)? itemBuilder;
|
final Widget Function(BuildContext, V2TimMessage?)? itemBuilder;
|
||||||
final AutoScrollController? scrollController;
|
final AutoScrollController? scrollController;
|
||||||
final String conversationID;
|
final String conversationID;
|
||||||
final Function(String? userId, String? nickName)?
|
final Function(String? userId, String? nickName)? onLongPressForOthersHeadPortrait;
|
||||||
onLongPressForOthersHeadPortrait;
|
|
||||||
final List<V2TimGroupAtInfo?>? groupAtInfoList;
|
final List<V2TimGroupAtInfo?>? groupAtInfoList;
|
||||||
final V2TimMessage? initFindingMsg;
|
final V2TimMessage? initFindingMsg;
|
||||||
|
|
||||||
|
|
@ -43,14 +46,13 @@ class TIMUIKitHistoryMessageListContainer extends StatefulWidget {
|
||||||
final TIMUIKitInputTextFieldController? textFieldController;
|
final TIMUIKitInputTextFieldController? textFieldController;
|
||||||
|
|
||||||
/// the builder for avatar
|
/// the builder for avatar
|
||||||
final Widget Function(BuildContext context, V2TimMessage message)?
|
final Widget Function(BuildContext context, V2TimMessage message)? userAvatarBuilder;
|
||||||
userAvatarBuilder;
|
|
||||||
|
|
||||||
/// the builder for tongue
|
/// the builder for tongue
|
||||||
final TongueItemBuilder? tongueItemBuilder;
|
final TongueItemBuilder? tongueItemBuilder;
|
||||||
|
|
||||||
final Widget? Function(V2TimMessage message, Function() closeTooltip,
|
final Widget? Function(V2TimMessage message, Function() closeTooltip, [Key? key, BuildContext? context])?
|
||||||
[Key? key, BuildContext? context])? extraTipsActionItemBuilder;
|
extraTipsActionItemBuilder;
|
||||||
|
|
||||||
/// conversation type
|
/// conversation type
|
||||||
final ConvType conversationType;
|
final ConvType conversationType;
|
||||||
|
|
@ -59,8 +61,7 @@ class TIMUIKitHistoryMessageListContainer extends StatefulWidget {
|
||||||
final void Function(String userID, TapDownDetails tapDetails)? onTapAvatar;
|
final void Function(String userID, TapDownDetails tapDetails)? onTapAvatar;
|
||||||
|
|
||||||
/// Avatar and name in message reaction secondary tap callback.
|
/// Avatar and name in message reaction secondary tap callback.
|
||||||
final void Function(String userID, TapDownDetails tapDetails)?
|
final void Function(String userID, TapDownDetails tapDetails)? onSecondaryTapAvatar;
|
||||||
onSecondaryTapAvatar;
|
|
||||||
|
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
"Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
||||||
|
|
@ -114,37 +115,32 @@ class TIMUIKitHistoryMessageListContainer extends StatefulWidget {
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() =>
|
State<StatefulWidget> createState() => _TIMUIKitHistoryMessageListContainerState();
|
||||||
_TIMUIKitHistoryMessageListContainerState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TIMUIKitHistoryMessageListContainerState
|
class _TIMUIKitHistoryMessageListContainerState extends TIMUIKitState<TIMUIKitHistoryMessageListContainer> {
|
||||||
extends TIMUIKitState<TIMUIKitHistoryMessageListContainer> {
|
|
||||||
late TIMUIKitHistoryMessageListController _historyMessageListController;
|
late TIMUIKitHistoryMessageListController _historyMessageListController;
|
||||||
|
|
||||||
List<V2TimMessage?> historyMessageList = [];
|
List<V2TimMessage?> historyMessageList = [];
|
||||||
|
|
||||||
Future<bool> requestForData(String? lastMsgID, LoadDirection direction,
|
Future<bool> requestForData(String? lastMsgID, LoadDirection direction, TUIChatSeparateViewModel model,
|
||||||
TUIChatSeparateViewModel model,
|
|
||||||
[int? count, int? lastSeq]) async {
|
[int? count, int? lastSeq]) async {
|
||||||
if ((direction == LoadDirection.previous) ||
|
if ((direction == LoadDirection.previous) || (direction == LoadDirection.latest && model.haveMoreLatestData)) {
|
||||||
(direction == LoadDirection.latest && model.haveMoreLatestData)) {
|
|
||||||
return await model.loadChatRecord(
|
return await model.loadChatRecord(
|
||||||
direction: direction,
|
direction: direction,
|
||||||
count: count ?? (kIsWeb ? 15 : HistoryMessageDartConstant.getCount),
|
count: count ?? (kIsWeb ? 15 : HistoryMessageDartConstant.getCount),
|
||||||
lastMsgID: lastMsgID,
|
lastMsgID: lastMsgID,
|
||||||
lastMsgSeq: lastSeq ?? -1,);
|
lastMsgSeq: lastSeq ?? -1,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget Function(BuildContext, V2TimMessage)? _getTopRowBuilder(
|
Widget Function(BuildContext, V2TimMessage)? _getTopRowBuilder(TUIChatSeparateViewModel model) {
|
||||||
TUIChatSeparateViewModel model) {
|
|
||||||
if (widget.messageItemBuilder?.messageNickNameBuilder != null) {
|
if (widget.messageItemBuilder?.messageNickNameBuilder != null) {
|
||||||
return (BuildContext context, V2TimMessage message) {
|
return (BuildContext context, V2TimMessage message) {
|
||||||
return widget.messageItemBuilder!.messageNickNameBuilder!(
|
return widget.messageItemBuilder!.messageNickNameBuilder!(context, message, model);
|
||||||
context, message, model);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -153,15 +149,13 @@ class _TIMUIKitHistoryMessageListContainerState
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_historyMessageListController = TIMUIKitHistoryMessageListController(
|
_historyMessageListController = TIMUIKitHistoryMessageListController(scrollController: widget.scrollController);
|
||||||
scrollController: widget.scrollController);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final chatConfig = Provider.of<TIMUIKitChatConfig>(context);
|
final chatConfig = Provider.of<TIMUIKitChatConfig>(context);
|
||||||
final TUIChatSeparateViewModel model =
|
final TUIChatSeparateViewModel model = Provider.of<TUIChatSeparateViewModel>(context, listen: false);
|
||||||
Provider.of<TUIChatSeparateViewModel>(context, listen: false);
|
|
||||||
|
|
||||||
return TIMUIKitHistoryMessageListSelector(
|
return TIMUIKitHistoryMessageListSelector(
|
||||||
conversationID: model.conversationID,
|
conversationID: model.conversationID,
|
||||||
|
|
@ -175,27 +169,22 @@ class _TIMUIKitHistoryMessageListContainerState
|
||||||
mainHistoryListConfig: widget.mainHistoryListConfig,
|
mainHistoryListConfig: widget.mainHistoryListConfig,
|
||||||
itemBuilder: (context, message) {
|
itemBuilder: (context, message) {
|
||||||
return TIMUIKitHistoryMessageListItem(
|
return TIMUIKitHistoryMessageListItem(
|
||||||
customMessageHoverBarOnDesktop:
|
customMessageHoverBarOnDesktop: widget.customMessageHoverBarOnDesktop,
|
||||||
widget.customMessageHoverBarOnDesktop,
|
|
||||||
groupMemberInfo: widget.groupMemberInfo,
|
groupMemberInfo: widget.groupMemberInfo,
|
||||||
textFieldController: widget.textFieldController,
|
textFieldController: widget.textFieldController,
|
||||||
userAvatarBuilder: widget.userAvatarBuilder,
|
userAvatarBuilder: widget.userAvatarBuilder,
|
||||||
customEmojiStickerList: widget.customEmojiStickerList,
|
customEmojiStickerList: widget.customEmojiStickerList,
|
||||||
topRowBuilder: _getTopRowBuilder(model),
|
topRowBuilder: _getTopRowBuilder(model),
|
||||||
onScrollToIndex: _historyMessageListController.scrollToIndex,
|
onScrollToIndex: _historyMessageListController.scrollToIndex,
|
||||||
onScrollToIndexBegin:
|
onScrollToIndexBegin: _historyMessageListController.scrollToIndexBegin,
|
||||||
_historyMessageListController.scrollToIndexBegin,
|
toolTipsConfig:
|
||||||
toolTipsConfig: widget.toolTipsConfig ??
|
widget.toolTipsConfig ?? ToolTipsConfig(additionalItemBuilder: widget.extraTipsActionItemBuilder),
|
||||||
ToolTipsConfig(
|
|
||||||
additionalItemBuilder:
|
|
||||||
widget.extraTipsActionItemBuilder),
|
|
||||||
message: message!,
|
message: message!,
|
||||||
showAvatar: chatConfig.isShowAvatar,
|
showAvatar: chatConfig.isShowAvatar,
|
||||||
onSecondaryTapForOthersPortrait: widget.onSecondaryTapAvatar,
|
onSecondaryTapForOthersPortrait: widget.onSecondaryTapAvatar,
|
||||||
onTapForOthersPortrait: widget.onTapAvatar,
|
onTapForOthersPortrait: widget.onTapAvatar,
|
||||||
messageItemBuilder: widget.messageItemBuilder,
|
messageItemBuilder: widget.messageItemBuilder,
|
||||||
onLongPressForOthersHeadPortrait:
|
onLongPressForOthersHeadPortrait: widget.onLongPressForOthersHeadPortrait,
|
||||||
widget.onLongPressForOthersHeadPortrait,
|
|
||||||
allowAtUserWhenReply: chatConfig.isAtWhenReply,
|
allowAtUserWhenReply: chatConfig.isAtWhenReply,
|
||||||
allowAvatarTap: chatConfig.isAllowClickAvatar,
|
allowAvatarTap: chatConfig.isAllowClickAvatar,
|
||||||
allowLongPress: chatConfig.isAllowLongPressMessage,
|
allowLongPress: chatConfig.isAllowLongPressMessage,
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_receipt.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_receipt.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_receipt.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
||||||
|
|
@ -17,9 +19,7 @@ class TIMUIKitMessageReadReceipt extends TIMUIKitStatelessWidget {
|
||||||
final V2TimMessage messageItem;
|
final V2TimMessage messageItem;
|
||||||
final void Function(String, TapDownDetails tapDetails)? onTapAvatar;
|
final void Function(String, TapDownDetails tapDetails)? onTapAvatar;
|
||||||
|
|
||||||
TIMUIKitMessageReadReceipt(
|
TIMUIKitMessageReadReceipt({Key? key, this.onTapAvatar, required this.messageItem}) : super(key: key);
|
||||||
{Key? key, this.onTapAvatar, required this.messageItem})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
|
|
@ -47,7 +47,7 @@ class TIMUIKitMessageReadReceipt extends TIMUIKitStatelessWidget {
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if ((value?.readCount ?? 0) > 0) {
|
if ((value?.readCount ?? 0) > 0) {
|
||||||
if(isDesktopScreen){
|
if (isDesktopScreen) {
|
||||||
TUIKitWidePopup.showPopupWindow(
|
TUIKitWidePopup.showPopupWindow(
|
||||||
operationKey: TUIKitWideModalOperationKey.messageReadDetails,
|
operationKey: TUIKitWideModalOperationKey.messageReadDetails,
|
||||||
context: context,
|
context: context,
|
||||||
|
|
@ -59,8 +59,7 @@ class TIMUIKitMessageReadReceipt extends TIMUIKitStatelessWidget {
|
||||||
onTapAvatar: onTapAvatar,
|
onTapAvatar: onTapAvatar,
|
||||||
messageItem: messageItem,
|
messageItem: messageItem,
|
||||||
unreadCount: value?.unreadCount ?? 0,
|
unreadCount: value?.unreadCount ?? 0,
|
||||||
readCount: value?.readCount ?? 0)
|
readCount: value?.readCount ?? 0));
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
if (value?.unreadCount == 0) {
|
if (value?.unreadCount == 0) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -78,8 +77,7 @@ class TIMUIKitMessageReadReceipt extends TIMUIKitStatelessWidget {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(bottom: 3, right: 6, left: 6, top: isDesktopScreen ? 2 : 6),
|
||||||
bottom: 3, right: 6, left: 6, top: isDesktopScreen ? 2 : 6),
|
|
||||||
child: ((value?.unreadCount ?? 0) == 0 && (value?.readCount ?? 0) > 0)
|
child: ((value?.unreadCount ?? 0) == 0 && (value?.readCount ?? 0) > 0)
|
||||||
? Icon(
|
? Icon(
|
||||||
Icons.check_circle_outline,
|
Icons.check_circle_outline,
|
||||||
|
|
@ -94,15 +92,12 @@ class TIMUIKitMessageReadReceipt extends TIMUIKitStatelessWidget {
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
width: 1.3,
|
width: 1.3,
|
||||||
color: (value?.readCount ?? 0) > 0
|
color: (value?.readCount ?? 0) > 0 ? theme.primaryColor! : theme.weakTextColor!)),
|
||||||
? theme.primaryColor!
|
|
||||||
: theme.weakTextColor!)),
|
|
||||||
child: (value?.readCount ?? 0) > 0
|
child: (value?.readCount ?? 0) > 0
|
||||||
? Text(
|
? Text(
|
||||||
'${value?.readCount ?? 0}',
|
'${value?.readCount ?? 0}',
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 8, color: theme.primaryColor),
|
||||||
fontSize: 8, color: theme.primaryColor),
|
|
||||||
)
|
)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
|
||||||
class TIMUIKitChatUtils {
|
class TIMUIKitChatUtils {
|
||||||
static String? getMessageIDWithinIndex(
|
static String? getMessageIDWithinIndex(List<V2TimMessage?> messageList, int index) {
|
||||||
List<V2TimMessage?> messageList, int index) {
|
|
||||||
if (messageList[index]!.elemType == 11) {
|
if (messageList[index]!.elemType == 11) {
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
return getMessageIDWithinIndex(messageList, index - 1);
|
return getMessageIDWithinIndex(messageList, index - 1);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart';
|
||||||
|
|
@ -36,28 +37,21 @@ class TIMUIKitMessageReactionDetail extends StatefulWidget {
|
||||||
State<StatefulWidget> createState() => TIMUIKitMessageReactionDetailState();
|
State<StatefulWidget> createState() => TIMUIKitMessageReactionDetailState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class TIMUIKitMessageReactionDetailState
|
class TIMUIKitMessageReactionDetailState extends TIMUIKitState<TIMUIKitMessageReactionDetail>
|
||||||
extends TIMUIKitState<TIMUIKitMessageReactionDetail>
|
|
||||||
with TickerProviderStateMixin {
|
with TickerProviderStateMixin {
|
||||||
final TUISelfInfoViewModel selfInfoModel =
|
final TUISelfInfoViewModel selfInfoModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
|
|
||||||
Widget getUserItem(
|
Widget getUserItem(String userID, TUITheme theme, Function(String userID, TapDownDetails tapDetails)? onTapAvatar) {
|
||||||
String userID, TUITheme theme, Function(String userID, TapDownDetails tapDetails)? onTapAvatar) {
|
|
||||||
V2TimGroupMemberFullInfo? memberInfo;
|
V2TimGroupMemberFullInfo? memberInfo;
|
||||||
String showName = userID;
|
String showName = userID;
|
||||||
try {
|
try {
|
||||||
memberInfo =
|
memberInfo = widget.memberList?.firstWhere((element) => element?.userID == userID);
|
||||||
widget.memberList?.firstWhere((element) => element?.userID == userID);
|
|
||||||
if (memberInfo != null) {
|
if (memberInfo != null) {
|
||||||
if (memberInfo.friendRemark != null &&
|
if (memberInfo.friendRemark != null && memberInfo.friendRemark!.isNotEmpty) {
|
||||||
memberInfo.friendRemark!.isNotEmpty) {
|
|
||||||
showName = memberInfo.friendRemark!;
|
showName = memberInfo.friendRemark!;
|
||||||
} else if (memberInfo.nameCard != null &&
|
} else if (memberInfo.nameCard != null && memberInfo.nameCard!.isNotEmpty) {
|
||||||
memberInfo.nameCard!.isNotEmpty) {
|
|
||||||
showName = memberInfo.nameCard!;
|
showName = memberInfo.nameCard!;
|
||||||
} else if (memberInfo.nickName != null &&
|
} else if (memberInfo.nickName != null && memberInfo.nickName!.isNotEmpty) {
|
||||||
memberInfo.nickName!.isNotEmpty) {
|
|
||||||
showName = memberInfo.nickName!;
|
showName = memberInfo.nickName!;
|
||||||
} else {
|
} else {
|
||||||
showName = memberInfo.userID;
|
showName = memberInfo.userID;
|
||||||
|
|
@ -77,10 +71,7 @@ class TIMUIKitMessageReactionDetailState
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
bottom: BorderSide(
|
|
||||||
color: theme.weakDividerColor ??
|
|
||||||
CommonColor.weakDividerColor))),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
|
@ -168,14 +159,12 @@ class TIMUIKitMessageReactionDetailState
|
||||||
labelColor: theme.primaryColor,
|
labelColor: theme.primaryColor,
|
||||||
labelStyle: const TextStyle(fontWeight: FontWeight.bold),
|
labelStyle: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
unselectedLabelColor: hexToColor("62626b"),
|
unselectedLabelColor: hexToColor("62626b"),
|
||||||
unselectedLabelStyle:
|
unselectedLabelStyle: const TextStyle(fontWeight: FontWeight.normal),
|
||||||
const TextStyle(fontWeight: FontWeight.normal),
|
|
||||||
indicatorSize: TabBarIndicatorSize.label,
|
indicatorSize: TabBarIndicatorSize.label,
|
||||||
indicatorColor: theme.primaryColor ?? hexToColor("62626b"),
|
indicatorColor: theme.primaryColor ?? hexToColor("62626b"),
|
||||||
tabs: [
|
tabs: [
|
||||||
...widget.stickerList.map((element) {
|
...widget.stickerList.map((element) {
|
||||||
return stickerItem(element,
|
return stickerItem(element, widget.messageReaction[element.toString()].length);
|
||||||
widget.messageReaction[element.toString()].length);
|
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -183,8 +172,7 @@ class TIMUIKitMessageReactionDetailState
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TabBarView(
|
child: TabBarView(
|
||||||
children: widget.stickerList
|
children: widget.stickerList
|
||||||
.map((int sticker) => getStickerNameList(
|
.map((int sticker) => getStickerNameList(sticker, theme, widget.onTapAvatar))
|
||||||
sticker, theme, widget.onTapAvatar))
|
|
||||||
.toList()))
|
.toList()))
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,14 @@ import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_change_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
|
|
@ -45,8 +49,7 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget {
|
||||||
Key? key})
|
Key? key})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
final TUISelfInfoViewModel selfInfoModel =
|
final TUISelfInfoViewModel selfInfoModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
final MessageService _messageService = serviceLocator<MessageService>();
|
final MessageService _messageService = serviceLocator<MessageService>();
|
||||||
|
|
||||||
clickOnCurrentSticker() async {
|
clickOnCurrentSticker() async {
|
||||||
|
|
@ -68,22 +71,21 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget {
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final theme = value.theme;
|
final theme = value.theme;
|
||||||
final option1 = nameList.length;
|
final option1 = nameList.length;
|
||||||
final TUIChatSeparateViewModel model =
|
final TUIChatSeparateViewModel model = Provider.of<TUIChatSeparateViewModel>(context);
|
||||||
Provider.of<TUIChatSeparateViewModel>(context);
|
|
||||||
|
|
||||||
final List<String> userIDs = [];
|
final List<String> userIDs = [];
|
||||||
for (final user in nameList) {
|
for (final user in nameList) {
|
||||||
final V2TimGroupMemberFullInfo? memberInfo = memberList
|
final V2TimGroupMemberFullInfo? memberInfo =
|
||||||
.firstWhereOrNull((element) => element?.userID == user && TencentUtils.checkString(user) != null);
|
memberList.firstWhereOrNull((element) => element?.userID == user && TencentUtils.checkString(user) != null);
|
||||||
if((memberInfo == null || TencentUtils.checkString(memberInfo.userID) == null) && TencentUtils.checkString(user.toString()) != null){
|
if ((memberInfo == null || TencentUtils.checkString(memberInfo.userID) == null) &&
|
||||||
|
TencentUtils.checkString(user.toString()) != null) {
|
||||||
userIDs.add(user.toString());
|
userIDs.add(user.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(userIDs.isNotEmpty){
|
if (userIDs.isNotEmpty) {
|
||||||
model.getUserShowName(userIDs);
|
model.getUserShowName(userIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return LayoutBuilder(builder: (context, constraints) {
|
return LayoutBuilder(builder: (context, constraints) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.only(
|
||||||
|
|
@ -101,14 +103,11 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget {
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: clickOnCurrentSticker,
|
onTap: clickOnCurrentSticker,
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.only(
|
margin:
|
||||||
bottom: (!PlatformUtils().isIOS) ? 4 : 2,
|
EdgeInsets.only(bottom: (!PlatformUtils().isIOS) ? 4 : 2, top: (!PlatformUtils().isIOS) ? 4 : 0),
|
||||||
top: (!PlatformUtils().isIOS) ? 4 : 0),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
String.fromCharCode(sticker),
|
String.fromCharCode(sticker),
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: (!PlatformUtils().isIOS) ? 12 : 16, color: hexToColor("f9453d")),
|
||||||
fontSize: (!PlatformUtils().isIOS) ? 12 : 16,
|
|
||||||
color: hexToColor("f9453d")),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -135,8 +134,7 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget {
|
||||||
onShowDetail(sticker);
|
onShowDetail(sticker);
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t_para("...共{{option1}}人", "...共$option1人")(
|
TIM_t_para("...共{{option1}}人", "...共$option1人")(option1: option1),
|
||||||
option1: option1),
|
|
||||||
style: TextStyle(fontSize: 12, color: hexToColor("616669")),
|
style: TextStyle(fontSize: 12, color: hexToColor("616669")),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -145,36 +143,33 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget {
|
||||||
String showName = e;
|
String showName = e;
|
||||||
if (memberList.isNotEmpty) {
|
if (memberList.isNotEmpty) {
|
||||||
try {
|
try {
|
||||||
final V2TimGroupMemberFullInfo? memberInfo = memberList
|
final V2TimGroupMemberFullInfo? memberInfo =
|
||||||
.firstWhere((element) => element?.userID == e);
|
memberList.firstWhere((element) => element?.userID == e);
|
||||||
if (memberInfo != null) {
|
if (memberInfo != null) {
|
||||||
if (memberInfo.friendRemark != null &&
|
if (memberInfo.friendRemark != null && memberInfo.friendRemark!.isNotEmpty) {
|
||||||
memberInfo.friendRemark!.isNotEmpty) {
|
|
||||||
showName = memberInfo.friendRemark!;
|
showName = memberInfo.friendRemark!;
|
||||||
} else if (memberInfo.nameCard != null &&
|
} else if (memberInfo.nameCard != null && memberInfo.nameCard!.isNotEmpty) {
|
||||||
memberInfo.nameCard!.isNotEmpty) {
|
|
||||||
showName = memberInfo.nameCard!;
|
showName = memberInfo.nameCard!;
|
||||||
} else if (memberInfo.nickName != null &&
|
} else if (memberInfo.nickName != null && memberInfo.nickName!.isNotEmpty) {
|
||||||
memberInfo.nickName!.isNotEmpty) {
|
|
||||||
showName = memberInfo.nickName!;
|
showName = memberInfo.nickName!;
|
||||||
} else {
|
} else {
|
||||||
showName = memberInfo.userID;
|
showName = memberInfo.userID;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
final String? data = model.groupUserShowName[e];
|
final String? data = model.groupUserShowName[e];
|
||||||
if(TencentUtils.checkString(data) != null){
|
if (TencentUtils.checkString(data) != null) {
|
||||||
showName = data ?? e;
|
showName = data ?? e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
final String? data = model.groupUserShowName[e];
|
final String? data = model.groupUserShowName[e];
|
||||||
if(TencentUtils.checkString(data) != null){
|
if (TencentUtils.checkString(data) != null) {
|
||||||
showName = data ?? e;
|
showName = data ?? e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
final String? data = model.groupUserShowName[e];
|
final String? data = model.groupUserShowName[e];
|
||||||
if(TencentUtils.checkString(data) != null){
|
if (TencentUtils.checkString(data) != null) {
|
||||||
showName = data ?? e;
|
showName = data ?? e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -188,8 +183,7 @@ class TIMUIKitMessageReactionShowItem extends TIMUIKitStatelessWidget {
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
showName,
|
showName,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 12, color: hexToColor("616669")),
|
||||||
fontSize: 12, color: hexToColor("616669")),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
|
|
@ -20,21 +22,13 @@ class TIMUIKitMessageReactionShowPanel extends TIMUIKitStatelessWidget {
|
||||||
/// current message
|
/// current message
|
||||||
final V2TimMessage message;
|
final V2TimMessage message;
|
||||||
|
|
||||||
TIMUIKitMessageReactionShowPanel({required this.message, Key? key})
|
TIMUIKitMessageReactionShowPanel({required this.message, Key? key}) : super(key: key);
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
final TUISelfInfoViewModel selfInfoModel =
|
final TUISelfInfoViewModel selfInfoModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
|
|
||||||
void showMore(
|
void showMore(BuildContext context, List<V2TimGroupMemberFullInfo?>? memberList, Map<String, dynamic> messageReaction,
|
||||||
BuildContext context,
|
int currentSticker, List<int> stickerList, TUIChatSeparateViewModel model) async {
|
||||||
List<V2TimGroupMemberFullInfo?>? memberList,
|
_showCustomModalBottomSheet(context, memberList, messageReaction, currentSticker, stickerList, model);
|
||||||
Map<String, dynamic> messageReaction,
|
|
||||||
int currentSticker,
|
|
||||||
List<int> stickerList,
|
|
||||||
TUIChatSeparateViewModel model) async {
|
|
||||||
_showCustomModalBottomSheet(context, memberList, messageReaction,
|
|
||||||
currentSticker, stickerList, model);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Future<int?>> _showCustomModalBottomSheet(
|
Future<Future<int?>> _showCustomModalBottomSheet(
|
||||||
|
|
@ -71,8 +65,7 @@ class TIMUIKitMessageReactionShowPanel extends TIMUIKitStatelessWidget {
|
||||||
Center(
|
Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t("回应详情"),
|
TIM_t("回应详情"),
|
||||||
style: const TextStyle(
|
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16.0),
|
||||||
fontWeight: FontWeight.bold, fontSize: 16.0),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
|
|
@ -88,8 +81,7 @@ class TIMUIKitMessageReactionShowPanel extends TIMUIKitStatelessWidget {
|
||||||
child: TIMUIKitMessageReactionDetail(
|
child: TIMUIKitMessageReactionDetail(
|
||||||
onTapAvatar: model.onTapAvatar,
|
onTapAvatar: model.onTapAvatar,
|
||||||
stickerList: stickerList,
|
stickerList: stickerList,
|
||||||
currentStickerIndex: stickerList
|
currentStickerIndex: stickerList.indexWhere((element) => element == currentSticker),
|
||||||
.indexWhere((element) => element == currentSticker),
|
|
||||||
memberList: memberList,
|
memberList: memberList,
|
||||||
messageReaction: messageReaction,
|
messageReaction: messageReaction,
|
||||||
)),
|
)),
|
||||||
|
|
@ -102,12 +94,9 @@ class TIMUIKitMessageReactionShowPanel extends TIMUIKitStatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
Map<String, dynamic> messageReaction = {};
|
Map<String, dynamic> messageReaction = {};
|
||||||
CloudCustomData messageCloudCustomData =
|
CloudCustomData messageCloudCustomData = MessageReactionUtils.getCloudCustomData(message);
|
||||||
MessageReactionUtils.getCloudCustomData(message);
|
final TUIChatSeparateViewModel model = Provider.of<TUIChatSeparateViewModel>(context);
|
||||||
final TUIChatSeparateViewModel model =
|
if (messageCloudCustomData.messageReaction != null && messageCloudCustomData.messageReaction!.isNotEmpty) {
|
||||||
Provider.of<TUIChatSeparateViewModel>(context);
|
|
||||||
if (messageCloudCustomData.messageReaction != null &&
|
|
||||||
messageCloudCustomData.messageReaction!.isNotEmpty) {
|
|
||||||
messageReaction = messageCloudCustomData.messageReaction!;
|
messageReaction = messageCloudCustomData.messageReaction!;
|
||||||
} else {
|
} else {
|
||||||
return const SizedBox(width: 0, height: 0);
|
return const SizedBox(width: 0, height: 0);
|
||||||
|
|
@ -119,8 +108,7 @@ class TIMUIKitMessageReactionShowPanel extends TIMUIKitStatelessWidget {
|
||||||
messageReactionStickerList.add(int.parse(key));
|
messageReactionStickerList.add(int.parse(key));
|
||||||
});
|
});
|
||||||
|
|
||||||
final filteredMessageReactionStickerList =
|
final filteredMessageReactionStickerList = messageReactionStickerList.where((sticker) {
|
||||||
messageReactionStickerList.where((sticker) {
|
|
||||||
if (messageReaction[sticker.toString()] == null ||
|
if (messageReaction[sticker.toString()] == null ||
|
||||||
messageReaction[sticker.toString()] is! List ||
|
messageReaction[sticker.toString()] is! List ||
|
||||||
messageReaction[sticker.toString()].length == 0) {
|
messageReaction[sticker.toString()].length == 0) {
|
||||||
|
|
@ -160,8 +148,8 @@ class TIMUIKitMessageReactionShowPanel extends TIMUIKitStatelessWidget {
|
||||||
nameList: messageReaction[sticker.toString()],
|
nameList: messageReaction[sticker.toString()],
|
||||||
sticker: sticker,
|
sticker: sticker,
|
||||||
onShowDetail: (int sticker) {
|
onShowDetail: (int sticker) {
|
||||||
showMore(context, memberList, messageReaction, sticker,
|
showMore(
|
||||||
filteredMessageReactionStickerList, model);
|
context, memberList, messageReaction, sticker, filteredMessageReactionStickerList, model);
|
||||||
});
|
});
|
||||||
}).toList(),
|
}).toList(),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_change_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_change_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/message/message_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/message/message_services.dart';
|
||||||
|
|
@ -11,18 +14,14 @@ import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/tim_uikit_cloud_custom_data.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/tim_uikit_cloud_custom_data.dart';
|
||||||
|
|
||||||
class MessageReactionUtils {
|
class MessageReactionUtils {
|
||||||
static final TUISelfInfoViewModel selfInfoModel =
|
static final TUISelfInfoViewModel selfInfoModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
static final MessageService _messageService = serviceLocator<MessageService>();
|
||||||
static final MessageService _messageService =
|
|
||||||
serviceLocator<MessageService>();
|
|
||||||
|
|
||||||
static CloudCustomData getCloudCustomData(V2TimMessage message) {
|
static CloudCustomData getCloudCustomData(V2TimMessage message) {
|
||||||
CloudCustomData messageCloudCustomData;
|
CloudCustomData messageCloudCustomData;
|
||||||
try {
|
try {
|
||||||
messageCloudCustomData = CloudCustomData.fromJson(json.decode(
|
messageCloudCustomData = CloudCustomData.fromJson(
|
||||||
TencentUtils.checkString(message.cloudCustomData) != null
|
json.decode(TencentUtils.checkString(message.cloudCustomData) != null ? message.cloudCustomData! : "{}"));
|
||||||
? message.cloudCustomData!
|
|
||||||
: "{}"));
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
messageCloudCustomData = CloudCustomData();
|
messageCloudCustomData = CloudCustomData();
|
||||||
}
|
}
|
||||||
|
|
@ -34,11 +33,9 @@ class MessageReactionUtils {
|
||||||
return getCloudCustomData(message).messageReaction ?? {};
|
return getCloudCustomData(message).messageReaction ?? {};
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<V2TimValueCallback<V2TimMessageChangeInfo>> clickOnSticker(
|
static Future<V2TimValueCallback<V2TimMessageChangeInfo>> clickOnSticker(V2TimMessage message, int sticker) async {
|
||||||
V2TimMessage message, int sticker) async {
|
|
||||||
final CloudCustomData messageCloudCustomData = getCloudCustomData(message);
|
final CloudCustomData messageCloudCustomData = getCloudCustomData(message);
|
||||||
final Map<String, dynamic> messageReaction =
|
final Map<String, dynamic> messageReaction = messageCloudCustomData.messageReaction ?? {};
|
||||||
messageCloudCustomData.messageReaction ?? {};
|
|
||||||
List targetList = messageReaction["$sticker"] ?? [];
|
List targetList = messageReaction["$sticker"] ?? [];
|
||||||
if (targetList.contains(selfInfoModel.loginInfo!.userID!)) {
|
if (targetList.contains(selfInfoModel.loginInfo!.userID!)) {
|
||||||
targetList.remove(selfInfoModel.loginInfo!.userID!);
|
targetList.remove(selfInfoModel.loginInfo!.userID!);
|
||||||
|
|
@ -49,8 +46,7 @@ class MessageReactionUtils {
|
||||||
|
|
||||||
if (PlatformUtils().isWeb) {
|
if (PlatformUtils().isWeb) {
|
||||||
final decodedMessage = jsonDecode(message.messageFromWeb!);
|
final decodedMessage = jsonDecode(message.messageFromWeb!);
|
||||||
decodedMessage["cloudCustomData"] =
|
decodedMessage["cloudCustomData"] = jsonEncode(messageCloudCustomData.toMap());
|
||||||
jsonEncode(messageCloudCustomData.toMap());
|
|
||||||
message.messageFromWeb = jsonEncode(decodedMessage);
|
message.messageFromWeb = jsonEncode(decodedMessage);
|
||||||
} else {
|
} else {
|
||||||
message.cloudCustomData = json.encode(messageCloudCustomData.toMap());
|
message.cloudCustomData = json.encode(messageCloudCustomData.toMap());
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
|
|
@ -27,7 +28,7 @@ class TIMUIKitMessageReactionWrapper extends StatefulWidget {
|
||||||
this.clearJump,
|
this.clearJump,
|
||||||
required this.isFromSelf,
|
required this.isFromSelf,
|
||||||
this.backgroundColor,
|
this.backgroundColor,
|
||||||
required this.chatModel,
|
required this.chatModel,
|
||||||
required this.message,
|
required this.message,
|
||||||
this.borderRadius,
|
this.borderRadius,
|
||||||
required this.child,
|
required this.child,
|
||||||
|
|
@ -38,15 +39,13 @@ class TIMUIKitMessageReactionWrapper extends StatefulWidget {
|
||||||
State<StatefulWidget> createState() => _TIMUIKitMessageReactionWrapperState();
|
State<StatefulWidget> createState() => _TIMUIKitMessageReactionWrapperState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TIMUIKitMessageReactionWrapperState
|
class _TIMUIKitMessageReactionWrapperState extends TIMUIKitState<TIMUIKitMessageReactionWrapper> {
|
||||||
extends TIMUIKitState<TIMUIKitMessageReactionWrapper> {
|
|
||||||
bool isShowJumpState = false;
|
bool isShowJumpState = false;
|
||||||
bool isShining = false;
|
bool isShining = false;
|
||||||
bool isShowBorder = false;
|
bool isShowBorder = false;
|
||||||
|
|
||||||
_showJumpColor() {
|
_showJumpColor() {
|
||||||
if ((widget.chatModel.jumpMsgID != widget.message.msgID) &&
|
if ((widget.chatModel.jumpMsgID != widget.message.msgID) && (widget.message.msgID?.isNotEmpty ?? true)) {
|
||||||
(widget.message.msgID?.isNotEmpty ?? true)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isShining = true;
|
isShining = true;
|
||||||
|
|
@ -78,15 +77,12 @@ class _TIMUIKitMessageReactionWrapperState
|
||||||
CloudCustomData messageCloudCustomData;
|
CloudCustomData messageCloudCustomData;
|
||||||
try {
|
try {
|
||||||
messageCloudCustomData = CloudCustomData.fromJson(json.decode(
|
messageCloudCustomData = CloudCustomData.fromJson(json.decode(
|
||||||
TencentUtils.checkString(widget.message.cloudCustomData) != null
|
TencentUtils.checkString(widget.message.cloudCustomData) != null ? widget.message.cloudCustomData! : "{}"));
|
||||||
? widget.message.cloudCustomData!
|
|
||||||
: "{}"));
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
messageCloudCustomData = CloudCustomData();
|
messageCloudCustomData = CloudCustomData();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (messageCloudCustomData.messageReaction != null &&
|
if (messageCloudCustomData.messageReaction != null && messageCloudCustomData.messageReaction!.isNotEmpty) {
|
||||||
messageCloudCustomData.messageReaction!.isNotEmpty) {
|
|
||||||
messageReaction = messageCloudCustomData.messageReaction!;
|
messageReaction = messageCloudCustomData.messageReaction!;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -98,8 +94,7 @@ class _TIMUIKitMessageReactionWrapperState
|
||||||
messageReactionStickerList.add(int.parse(key));
|
messageReactionStickerList.add(int.parse(key));
|
||||||
});
|
});
|
||||||
|
|
||||||
final filteredMessageReactionStickerList =
|
final filteredMessageReactionStickerList = messageReactionStickerList.where((sticker) {
|
||||||
messageReactionStickerList.where((sticker) {
|
|
||||||
if (messageReaction[sticker.toString()] == null ||
|
if (messageReaction[sticker.toString()] == null ||
|
||||||
messageReaction[sticker.toString()] is! List ||
|
messageReaction[sticker.toString()] is! List ||
|
||||||
messageReaction[sticker.toString()].length == 0) {
|
messageReaction[sticker.toString()].length == 0) {
|
||||||
|
|
@ -135,29 +130,23 @@ class _TIMUIKitMessageReactionWrapperState
|
||||||
_showJumpColor();
|
_showJumpColor();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if ((widget.chatModel.jumpMsgID == widget.message.msgID) &&
|
if ((widget.chatModel.jumpMsgID == widget.message.msgID) && (widget.message.msgID?.isNotEmpty ?? false)) {
|
||||||
(widget.message.msgID?.isNotEmpty ?? false)) {
|
if (widget.clearJump != null) {
|
||||||
if(widget.clearJump != null){
|
|
||||||
widget.clearJump!();
|
widget.clearJump!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final defaultStyle = widget.isFromSelf
|
final defaultStyle = widget.isFromSelf ? theme.lightPrimaryMaterialColor.shade50 : theme.weakBackgroundColor;
|
||||||
? theme.lightPrimaryMaterialColor.shade50
|
final backgroundColor =
|
||||||
: theme.weakBackgroundColor;
|
isShowJumpState ? const Color.fromRGBO(245, 166, 35, 1) : (widget.backgroundColor ?? defaultStyle);
|
||||||
final backgroundColor = isShowJumpState
|
|
||||||
? const Color.fromRGBO(245, 166, 35, 1)
|
|
||||||
: (widget.backgroundColor ?? defaultStyle);
|
|
||||||
|
|
||||||
if (!widget.isShowMessageReaction || !isHaveMessageReaction()) {
|
if (!widget.isShowMessageReaction || !isHaveMessageReaction()) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
||||||
border: Border.all(
|
border: Border.all(color: Color.fromRGBO(245, 166, 35, (isShowBorder ? 1 : 0)), width: 2)),
|
||||||
color: Color.fromRGBO(245, 166, 35, (isShowBorder ? 1 : 0)),
|
|
||||||
width: 2)),
|
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -168,21 +157,17 @@ class _TIMUIKitMessageReactionWrapperState
|
||||||
color: backgroundColor,
|
color: backgroundColor,
|
||||||
borderRadius: widget.borderRadius ?? borderRadius,
|
borderRadius: widget.borderRadius ?? borderRadius,
|
||||||
),
|
),
|
||||||
constraints:
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.7),
|
||||||
BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.7),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
||||||
border: Border.all(
|
border: Border.all(color: Color.fromRGBO(245, 166, 35, (isShowBorder ? 1 : 0)), width: 2)),
|
||||||
color: Color.fromRGBO(245, 166, 35, (isShowBorder ? 1 : 0)),
|
|
||||||
width: 2)),
|
|
||||||
child: widget.child,
|
child: widget.child,
|
||||||
),
|
),
|
||||||
if (widget.isShowMessageReaction)
|
if (widget.isShowMessageReaction) TIMUIKitMessageReactionShowPanel(message: widget.message)
|
||||||
TIMUIKitMessageReactionShowPanel(message: widget.message)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_custom_elem.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_custom_elem.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_custom_elem.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
|
|
||||||
|
|
@ -43,9 +45,7 @@ class TIMUIKitCustomElem extends TIMUIKitStatelessWidget {
|
||||||
topRight: Radius.circular(10),
|
topRight: Radius.circular(10),
|
||||||
bottomLeft: Radius.circular(10),
|
bottomLeft: Radius.circular(10),
|
||||||
bottomRight: Radius.circular(10));
|
bottomRight: Radius.circular(10));
|
||||||
final backgroundColor = isFromSelf
|
final backgroundColor = isFromSelf ? theme.lightPrimaryMaterialColor.shade50 : theme.weakBackgroundColor;
|
||||||
? theme.lightPrimaryMaterialColor.shade50
|
|
||||||
: theme.weakBackgroundColor;
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: textPadding ?? const EdgeInsets.all(10),
|
padding: textPadding ?? const EdgeInsets.all(10),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
@ -54,9 +54,7 @@ class TIMUIKitCustomElem extends TIMUIKitStatelessWidget {
|
||||||
),
|
),
|
||||||
constraints: const BoxConstraints(maxWidth: 240),
|
constraints: const BoxConstraints(maxWidth: 240),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [Text(TIM_t("自定义消息"))],
|
||||||
Text(TIM_t("自定义消息"))
|
|
||||||
],
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
|
|
@ -29,7 +30,6 @@ class TIMUIKitFaceElem extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TIMUIKitTextElemState extends TIMUIKitState<TIMUIKitFaceElem> {
|
class _TIMUIKitTextElemState extends TIMUIKitState<TIMUIKitFaceElem> {
|
||||||
|
|
||||||
bool isFromNetwork() {
|
bool isFromNetwork() {
|
||||||
return widget.path.startsWith('http');
|
return widget.path.startsWith('http');
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,7 @@ class _TIMUIKitTextElemState extends TIMUIKitState<TIMUIKitFaceElem> {
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
return TIMUIKitMessageReactionWrapper(
|
return TIMUIKitMessageReactionWrapper(
|
||||||
chatModel: widget.model,
|
chatModel: widget.model,
|
||||||
isShowJump: widget.isShowJump,
|
isShowJump: widget.isShowJump,
|
||||||
isFromSelf: widget.message.isSelf ?? true,
|
isFromSelf: widget.message.isSelf ?? true,
|
||||||
clearJump: widget.clearJump,
|
clearJump: widget.clearJump,
|
||||||
|
|
@ -58,11 +58,8 @@ class _TIMUIKitTextElemState extends TIMUIKitState<TIMUIKitFaceElem> {
|
||||||
isShowMessageReaction: widget.isShowMessageReaction ?? true,
|
isShowMessageReaction: widget.isShowMessageReaction ?? true,
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.all(10),
|
padding: const EdgeInsets.all(10),
|
||||||
constraints:
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * (isDesktopScreen ? 0.1 : 0.3)),
|
||||||
BoxConstraints(maxWidth: MediaQuery.of(context).size.width * (isDesktopScreen ? 0.1 : 0.3)),
|
child: isFromNetwork() ? Image.network(widget.path) : Image.asset(createPathFromNative(widget.path)),
|
||||||
child: isFromNetwork()
|
|
||||||
? Image.network(widget.path)
|
|
||||||
: Image.asset(createPathFromNative(widget.path)),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,12 @@ import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||||
import 'package:open_file/open_file.dart';
|
import 'package:open_file/open_file.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/V2TimAdvancedMsgListener.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/V2TimAdvancedMsgListener.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_file_elem.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_file_elem.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_file_elem.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_download_progress.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_download_progress.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_download_progress.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
|
|
@ -70,9 +73,7 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
if (advancedMsgListener != null) {
|
if (advancedMsgListener != null) {
|
||||||
TencentImSDKPlugin.v2TIMManager
|
TencentImSDKPlugin.v2TIMManager.getMessageManager().removeAdvancedMsgListener(listener: advancedMsgListener);
|
||||||
.getMessageManager()
|
|
||||||
.removeAdvancedMsgListener(listener: advancedMsgListener);
|
|
||||||
advancedMsgListener = null;
|
advancedMsgListener = null;
|
||||||
}
|
}
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|
@ -89,12 +90,11 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> addAdvancedMsgListenerForDownload() async {
|
Future<bool> addAdvancedMsgListenerForDownload() async {
|
||||||
if(advancedMsgListener != null){
|
if (advancedMsgListener != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
advancedMsgListener = V2TimAdvancedMsgListener(
|
advancedMsgListener = V2TimAdvancedMsgListener(
|
||||||
onMessageDownloadProgressCallback:
|
onMessageDownloadProgressCallback: (V2TimMessageDownloadProgress messageProgress) async {
|
||||||
(V2TimMessageDownloadProgress messageProgress) async {
|
|
||||||
if (messageProgress.msgID == widget.message.msgID) {
|
if (messageProgress.msgID == widget.message.msgID) {
|
||||||
if (messageProgress.isError || messageProgress.errorCode != 0) {
|
if (messageProgress.isError || messageProgress.errorCode != 0) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -117,9 +117,7 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final currentProgress =
|
final currentProgress = (messageProgress.currentSize / messageProgress.totalSize * 100).floor();
|
||||||
(messageProgress.currentSize / messageProgress.totalSize * 100)
|
|
||||||
.floor();
|
|
||||||
if (mounted && currentProgress > downloadProgress) {
|
if (mounted && currentProgress > downloadProgress) {
|
||||||
setState(() {
|
setState(() {
|
||||||
downloadProgress = currentProgress;
|
downloadProgress = currentProgress;
|
||||||
|
|
@ -129,17 +127,14 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
await TencentImSDKPlugin.v2TIMManager
|
await TencentImSDKPlugin.v2TIMManager.getMessageManager().addAdvancedMsgListener(listener: advancedMsgListener!);
|
||||||
.getMessageManager()
|
|
||||||
.addAdvancedMsgListener(listener: advancedMsgListener!);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getSavePath() async {
|
Future<String> getSavePath() async {
|
||||||
String savePathWithAppPath =
|
String savePathWithAppPath = '/storage/emulated/0/Android/data/com.tencent.flutter.tuikit/cache/' +
|
||||||
'/storage/emulated/0/Android/data/com.tencent.flutter.tuikit/cache/' +
|
(widget.message.msgID ?? "") +
|
||||||
(widget.message.msgID ?? "") +
|
widget.fileElem!.fileName!;
|
||||||
widget.fileElem!.fileName!;
|
|
||||||
return savePathWithAppPath;
|
return savePathWithAppPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,8 +142,7 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
if (PlatformUtils().isWeb) {
|
if (PlatformUtils().isWeb) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String savePath = TencentUtils.checkString(
|
String savePath = TencentUtils.checkString(model.getFileMessageLocation(widget.messageID)) ??
|
||||||
model.getFileMessageLocation(widget.messageID)) ??
|
|
||||||
TencentUtils.checkString(widget.message.fileElem!.localUrl) ??
|
TencentUtils.checkString(widget.message.fileElem!.localUrl) ??
|
||||||
widget.message.fileElem?.path ??
|
widget.message.fileElem?.path ??
|
||||||
'';
|
'';
|
||||||
|
|
@ -166,9 +160,7 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
model.setMessageProgress(widget.messageID!, 100);
|
model.setMessageProgress(widget.messageID!, 100);
|
||||||
}
|
}
|
||||||
if (advancedMsgListener != null) {
|
if (advancedMsgListener != null) {
|
||||||
TencentImSDKPlugin.v2TIMManager
|
TencentImSDKPlugin.v2TIMManager.getMessageManager().removeAdvancedMsgListener(listener: advancedMsgListener);
|
||||||
.getMessageManager()
|
|
||||||
.removeAdvancedMsgListener(listener: advancedMsgListener);
|
|
||||||
advancedMsgListener = null;
|
advancedMsgListener = null;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -216,8 +208,7 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
downloadFile(TUITheme theme) async {
|
downloadFile(TUITheme theme) async {
|
||||||
if (PlatformUtils().isMobile) {
|
if (PlatformUtils().isMobile) {
|
||||||
if (PlatformUtils().isIOS) {
|
if (PlatformUtils().isIOS) {
|
||||||
if (!await Permissions.checkPermission(
|
if (!await Permissions.checkPermission(context, Permission.photosAddOnly.value, theme, false)) {
|
||||||
context, Permission.photosAddOnly.value, theme, false)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -249,18 +240,13 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
tryOpenFile(context, theme) async {
|
tryOpenFile(context, theme) async {
|
||||||
if (!PlatformUtils().isWeb &&
|
if (!PlatformUtils().isWeb && (await hasZeroSize(filePath) || widget.message.status == 3)) {
|
||||||
(await hasZeroSize(filePath) || widget.message.status == 3)) {
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: "不支持 0KB 文件的传输", infoCode: 6660417));
|
||||||
onTIMCallback(TIMCallback(
|
|
||||||
type: TIMCallbackType.INFO,
|
|
||||||
infoRecommendText: "不支持 0KB 文件的传输",
|
|
||||||
infoCode: 6660417));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PlatformUtils().isMobile) {
|
if (PlatformUtils().isMobile) {
|
||||||
if (PlatformUtils().isIOS) {
|
if (PlatformUtils().isIOS) {
|
||||||
if (!await Permissions.checkPermission(
|
if (!await Permissions.checkPermission(context, Permission.photosAddOnly.value, theme!, false)) {
|
||||||
context, Permission.photosAddOnly.value, theme!, false)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -304,8 +290,7 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
headers: {'Content-Type': 'application/x-www-form-urlencoded'},
|
||||||
);
|
);
|
||||||
|
|
||||||
final html.AnchorElement downloadAnchor =
|
final html.AnchorElement downloadAnchor = html.document.createElement('a') as html.AnchorElement;
|
||||||
html.document.createElement('a') as html.AnchorElement;
|
|
||||||
|
|
||||||
final html.Blob blob = html.Blob([response.bodyBytes]);
|
final html.Blob blob = html.Blob([response.bodyBytes]);
|
||||||
|
|
||||||
|
|
@ -317,8 +302,7 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
html.AnchorElement(
|
html.AnchorElement(
|
||||||
href: widget.fileElem?.path ?? "",
|
href: widget.fileElem?.path ?? "",
|
||||||
)
|
)
|
||||||
..setAttribute(
|
..setAttribute("download", widget.message.fileElem?.fileName ?? fileName)
|
||||||
"download", widget.message.fileElem?.fileName ?? fileName)
|
|
||||||
..setAttribute("target", '_blank')
|
..setAttribute("target", '_blank')
|
||||||
..style.display = "none"
|
..style.display = "none"
|
||||||
..click();
|
..click();
|
||||||
|
|
@ -348,13 +332,11 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
bottomLeft: Radius.circular(10),
|
bottomLeft: Radius.circular(10),
|
||||||
bottomRight: Radius.circular(10));
|
bottomRight: Radius.circular(10));
|
||||||
String? fileFormat;
|
String? fileFormat;
|
||||||
if (widget.fileElem?.fileName != null &&
|
if (widget.fileElem?.fileName != null && widget.fileElem!.fileName!.isNotEmpty) {
|
||||||
widget.fileElem!.fileName!.isNotEmpty) {
|
|
||||||
final String fileName = widget.fileElem!.fileName!;
|
final String fileName = widget.fileElem!.fileName!;
|
||||||
fileFormat = fileName.split(".")[max(fileName.split(".").length - 1, 0)];
|
fileFormat = fileName.split(".")[max(fileName.split(".").length - 1, 0)];
|
||||||
}
|
}
|
||||||
final RenderBox? containerRenderBox =
|
final RenderBox? containerRenderBox = containerKey.currentContext?.findRenderObject() as RenderBox?;
|
||||||
containerKey.currentContext?.findRenderObject() as RenderBox?;
|
|
||||||
if (containerRenderBox != null) {
|
if (containerRenderBox != null) {
|
||||||
containerHeight = containerRenderBox.size.height;
|
containerHeight = containerRenderBox.size.height;
|
||||||
}
|
}
|
||||||
|
|
@ -406,19 +388,15 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
if (checkIsWaiting()) {
|
if (checkIsWaiting()) {
|
||||||
onTIMCallback(
|
onTIMCallback(
|
||||||
TIMCallback(
|
TIMCallback(
|
||||||
type: TIMCallbackType.INFO,
|
type: TIMCallbackType.INFO, infoRecommendText: TIM_t("已加入待下载队列,其他文件下载中"), infoCode: 6660413),
|
||||||
infoRecommendText: TIM_t("已加入待下载队列,其他文件下载中"),
|
|
||||||
infoCode: 6660413),
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
await addUrlToWaitingPath(theme);
|
await addUrlToWaitingPath(theme);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(
|
||||||
type: TIMCallbackType.INFO,
|
TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: "文件处理异常", infoCode: 6660416));
|
||||||
infoRecommendText: "文件处理异常",
|
|
||||||
infoCode: 6660416));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: ConstrainedBox(
|
child: ConstrainedBox(
|
||||||
|
|
@ -427,8 +405,7 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
width: 170,
|
width: 170,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: theme.weakDividerColor ??
|
color: theme.weakDividerColor ?? CommonColor.weakDividerColor,
|
||||||
CommonColor.weakDividerColor,
|
|
||||||
),
|
),
|
||||||
borderRadius: borderRadius),
|
borderRadius: borderRadius),
|
||||||
child: Stack(children: [
|
child: Stack(children: [
|
||||||
|
|
@ -437,28 +414,21 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
child: LinearProgressIndicator(
|
child: LinearProgressIndicator(
|
||||||
minHeight: ((containerHeight) ?? 72) - 6,
|
minHeight: ((containerHeight) ?? 72) - 6,
|
||||||
value: (received == 100 ? 0 : received) / 100,
|
value: (received == 100 ? 0 : received) / 100,
|
||||||
backgroundColor: received == 100
|
backgroundColor: received == 100 ? theme.weakBackgroundColor : Colors.white,
|
||||||
? theme.weakBackgroundColor
|
valueColor: AlwaysStoppedAnimation(theme.lightPrimaryMaterialColor.shade50),
|
||||||
: Colors.white,
|
|
||||||
valueColor: AlwaysStoppedAnimation(
|
|
||||||
theme.lightPrimaryMaterialColor.shade50),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
|
||||||
vertical: 8, horizontal: 12),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: widget.isSelf
|
mainAxisAlignment: widget.isSelf ? MainAxisAlignment.end : MainAxisAlignment.start,
|
||||||
? MainAxisAlignment.end
|
|
||||||
: MainAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
constraints:
|
constraints: const BoxConstraints(maxWidth: 160),
|
||||||
const BoxConstraints(maxWidth: 160),
|
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(
|
||||||
builder: (buildContext, boxConstraints) {
|
builder: (buildContext, boxConstraints) {
|
||||||
return CustomText(
|
return CustomText(
|
||||||
|
|
@ -476,9 +446,7 @@ class _TIMUIKitFileElemState extends TIMUIKitState<TIMUIKitFileElem> {
|
||||||
if (fileSize != null)
|
if (fileSize != null)
|
||||||
Text(
|
Text(
|
||||||
showFileSize(fileSize),
|
showFileSize(fileSize),
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 14, color: theme.weakTextColor),
|
||||||
fontSize: 14,
|
|
||||||
color: theme.weakTextColor),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_tips_elem.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_tips_elem.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_tips_elem.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/message.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
|
|
@ -11,15 +13,13 @@ class TIMUIKitGroupTipsElem extends StatefulWidget {
|
||||||
final V2TimGroupTipsElem groupTipsElem;
|
final V2TimGroupTipsElem groupTipsElem;
|
||||||
final List<V2TimGroupMemberFullInfo?> groupMemberList;
|
final List<V2TimGroupMemberFullInfo?> groupMemberList;
|
||||||
|
|
||||||
const TIMUIKitGroupTipsElem({Key? key, required this.groupMemberList, required this.groupTipsElem})
|
const TIMUIKitGroupTipsElem({Key? key, required this.groupMemberList, required this.groupTipsElem}) : super(key: key);
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<TIMUIKitGroupTipsElem> createState() => _TIMUIKitGroupTipsElemState();
|
State<TIMUIKitGroupTipsElem> createState() => _TIMUIKitGroupTipsElemState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TIMUIKitGroupTipsElemState extends TIMUIKitState<TIMUIKitGroupTipsElem> {
|
class _TIMUIKitGroupTipsElemState extends TIMUIKitState<TIMUIKitGroupTipsElem> {
|
||||||
|
|
||||||
String groupTipsAbstractText = "";
|
String groupTipsAbstractText = "";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -45,10 +45,7 @@ class _TIMUIKitGroupTipsElemState extends TIMUIKitState<TIMUIKitGroupTipsElem> {
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w400, color: hexToColor("888888")),
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: FontWeight.w400,
|
|
||||||
color: hexToColor("888888")),
|
|
||||||
),
|
),
|
||||||
theme);
|
theme);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,10 @@ import 'package:open_file/open_file.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_image.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_image.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_image.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
|
|
@ -77,9 +79,8 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
|
|
||||||
String getOriginImgURL() {
|
String getOriginImgURL() {
|
||||||
// 实际拿的是原图
|
// 实际拿的是原图
|
||||||
V2TimImage? img = MessageUtils.getImageFromImgList(
|
V2TimImage? img =
|
||||||
widget.message.imageElem!.imageList,
|
MessageUtils.getImageFromImgList(widget.message.imageElem!.imageList, HistoryMessageDartConstant.oriImgPrior);
|
||||||
HistoryMessageDartConstant.oriImgPrior);
|
|
||||||
return img == null ? widget.message.imageElem!.path! : img.url!;
|
return img == null ? widget.message.imageElem!.path! : img.url!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,8 +129,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
final http.Response r = await http.get(Uri.parse(imageUrl));
|
final http.Response r = await http.get(Uri.parse(imageUrl));
|
||||||
final data = r.bodyBytes;
|
final data = r.bodyBytes;
|
||||||
final base64data = base64Encode(data);
|
final base64data = base64Encode(data);
|
||||||
final a =
|
final a = html.AnchorElement(href: 'data:image/jpeg;base64,$base64data');
|
||||||
html.AnchorElement(href: 'data:image/jpeg;base64,$base64data');
|
|
||||||
a.download = md5.convert(utf8.encode(imageUrl)).toString();
|
a.download = md5.convert(utf8.encode(imageUrl)).toString();
|
||||||
a.click();
|
a.click();
|
||||||
a.remove();
|
a.remove();
|
||||||
|
|
@ -140,8 +140,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PlatformUtils().isIOS) {
|
if (PlatformUtils().isIOS) {
|
||||||
if (!await Permissions.checkPermission(
|
if (!await Permissions.checkPermission(context, Permission.photosAddOnly.value, theme!, false)) {
|
||||||
context, Permission.photosAddOnly.value, theme!, false)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -177,7 +176,8 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
if (model.getMessageProgress(widget.message.msgID) == 100) {
|
if (model.getMessageProgress(widget.message.msgID) == 100) {
|
||||||
String savePath;
|
String savePath;
|
||||||
if (widget.message.imageElem!.path != null &&
|
if (widget.message.imageElem!.path != null &&
|
||||||
widget.message.imageElem!.path != '' && File(widget.message.imageElem!.path!).existsSync()) {
|
widget.message.imageElem!.path != '' &&
|
||||||
|
File(widget.message.imageElem!.path!).existsSync()) {
|
||||||
savePath = widget.message.imageElem!.path!;
|
savePath = widget.message.imageElem!.path!;
|
||||||
} else {
|
} else {
|
||||||
savePath = model.getFileMessageLocation(widget.message.msgID);
|
savePath = model.getFileMessageLocation(widget.message.msgID);
|
||||||
|
|
@ -188,36 +188,26 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
|
|
||||||
if (PlatformUtils().isIOS) {
|
if (PlatformUtils().isIOS) {
|
||||||
if (result['isSuccess']) {
|
if (result['isSuccess']) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(
|
||||||
type: TIMCallbackType.INFO,
|
TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("图片保存成功"), infoCode: 6660406));
|
||||||
infoRecommendText: TIM_t("图片保存成功"),
|
|
||||||
infoCode: 6660406));
|
|
||||||
} else {
|
} else {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(
|
||||||
type: TIMCallbackType.INFO,
|
TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("图片保存失败"), infoCode: 6660407));
|
||||||
infoRecommendText: TIM_t("图片保存失败"),
|
|
||||||
infoCode: 6660407));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(
|
||||||
type: TIMCallbackType.INFO,
|
TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("图片保存成功"), infoCode: 6660406));
|
||||||
infoRecommendText: TIM_t("图片保存成功"),
|
|
||||||
infoCode: 6660406));
|
|
||||||
} else {
|
} else {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(
|
||||||
type: TIMCallbackType.INFO,
|
TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("图片保存失败"), infoCode: 6660407));
|
||||||
infoRecommendText: TIM_t("图片保存失败"),
|
|
||||||
infoCode: 6660407));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(
|
||||||
type: TIMCallbackType.INFO,
|
type: TIMCallbackType.INFO, infoRecommendText: TIM_t("the message is downloading"), infoCode: -1));
|
||||||
infoRecommendText: TIM_t("the message is downloading"),
|
|
||||||
infoCode: -1));
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -226,27 +216,15 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
|
|
||||||
if (PlatformUtils().isIOS) {
|
if (PlatformUtils().isIOS) {
|
||||||
if (result['isSuccess']) {
|
if (result['isSuccess']) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("图片保存成功"), infoCode: 6660406));
|
||||||
type: TIMCallbackType.INFO,
|
|
||||||
infoRecommendText: TIM_t("图片保存成功"),
|
|
||||||
infoCode: 6660406));
|
|
||||||
} else {
|
} else {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("图片保存失败"), infoCode: 6660407));
|
||||||
type: TIMCallbackType.INFO,
|
|
||||||
infoRecommendText: TIM_t("图片保存失败"),
|
|
||||||
infoCode: 6660407));
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("图片保存成功"), infoCode: 6660406));
|
||||||
type: TIMCallbackType.INFO,
|
|
||||||
infoRecommendText: TIM_t("图片保存成功"),
|
|
||||||
infoCode: 6660406));
|
|
||||||
} else {
|
} else {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("图片保存失败"), infoCode: 6660407));
|
||||||
type: TIMCallbackType.INFO,
|
|
||||||
infoRecommendText: TIM_t("图片保存失败"),
|
|
||||||
infoCode: 6660407));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -267,8 +245,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
if (!isWeb && filePath != null && File(filePath).existsSync()) {
|
if (!isWeb && filePath != null && File(filePath).existsSync()) {
|
||||||
imageUrl = filePath;
|
imageUrl = filePath;
|
||||||
isAssetBool = true;
|
isAssetBool = true;
|
||||||
} else if (localUrl != null &&
|
} else if (localUrl != null && (!isWeb && File(localUrl).existsSync())) {
|
||||||
(!isWeb && File(localUrl).existsSync())) {
|
|
||||||
imageUrl = localUrl;
|
imageUrl = localUrl;
|
||||||
isAssetBool = true;
|
isAssetBool = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -286,19 +263,14 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(infoCode: 6660414, infoRecommendText: TIM_t("正在下载中"), type: TIMCallbackType.INFO));
|
||||||
infoCode: 6660414,
|
|
||||||
infoRecommendText: TIM_t("正在下载中"),
|
|
||||||
type: TIMCallbackType.INFO));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
V2TimImage? getImageFromList(V2TimImageTypesEnum imgType) {
|
V2TimImage? getImageFromList(V2TimImageTypesEnum imgType) {
|
||||||
V2TimImage? img = MessageUtils.getImageFromImgList(
|
V2TimImage? img = MessageUtils.getImageFromImgList(widget.message.imageElem!.imageList,
|
||||||
widget.message.imageElem!.imageList,
|
HistoryMessageDartConstant.imgPriorMap[imgType] ?? HistoryMessageDartConstant.oriImgPrior);
|
||||||
HistoryMessageDartConstant.imgPriorMap[imgType] ??
|
|
||||||
HistoryMessageDartConstant.oriImgPrior);
|
|
||||||
|
|
||||||
return img;
|
return img;
|
||||||
}
|
}
|
||||||
|
|
@ -322,26 +294,21 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
));
|
));
|
||||||
|
|
||||||
bool checkIfDownloadSuccess() {
|
bool checkIfDownloadSuccess() {
|
||||||
final localUrl = TencentUtils.checkString(
|
final localUrl = TencentUtils.checkString(model.getFileMessageLocation(widget.message.msgID)) ??
|
||||||
model.getFileMessageLocation(widget.message.msgID)) ??
|
|
||||||
widget.message.imageElem!.imageList![0]!.localUrl;
|
widget.message.imageElem!.imageList![0]!.localUrl;
|
||||||
return TencentUtils.checkString(localUrl) != null &&
|
return TencentUtils.checkString(localUrl) != null && File(localUrl!).existsSync();
|
||||||
File(localUrl!).existsSync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onClickOpenImageInNewWindow() {
|
_onClickOpenImageInNewWindow() {
|
||||||
final localUrl = TencentUtils.checkString(
|
final localUrl = TencentUtils.checkString(model.getFileMessageLocation(widget.message.msgID)) ??
|
||||||
model.getFileMessageLocation(widget.message.msgID)) ??
|
|
||||||
widget.message.imageElem!.imageList![0]!.localUrl;
|
widget.message.imageElem!.imageList![0]!.localUrl;
|
||||||
Future.delayed(const Duration(milliseconds: 0), () async {
|
Future.delayed(const Duration(milliseconds: 0), () async {
|
||||||
final isDownloaded = checkIfDownloadSuccess();
|
final isDownloaded = checkIfDownloadSuccess();
|
||||||
if (isDownloaded) {
|
if (isDownloaded) {
|
||||||
launchDesktopFile(localUrl ?? "");
|
launchDesktopFile(localUrl ?? "");
|
||||||
} else {
|
} else {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(
|
||||||
infoCode: 6660414,
|
TIMCallback(infoCode: 6660414, infoRecommendText: TIM_t("正在下载原始资源,请稍候..."), type: TIMCallbackType.INFO));
|
||||||
infoRecommendText: TIM_t("正在下载原始资源,请稍候..."),
|
|
||||||
type: TIMCallbackType.INFO));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -350,8 +317,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
double? positionRadio,
|
double? positionRadio,
|
||||||
String? originImgUrl,
|
String? originImgUrl,
|
||||||
}) {
|
}) {
|
||||||
final localUrl = TencentUtils.checkString(
|
final localUrl = TencentUtils.checkString(model.getFileMessageLocation(widget.message.msgID)) ??
|
||||||
model.getFileMessageLocation(widget.message.msgID)) ??
|
|
||||||
widget.message.imageElem!.imageList![0]!.localUrl;
|
widget.message.imageElem!.imageList![0]!.localUrl;
|
||||||
if (checkIfDownloadSuccess()) {
|
if (checkIfDownloadSuccess()) {
|
||||||
TUIKitWidePopup.showMedia(
|
TUIKitWidePopup.showMedia(
|
||||||
|
|
@ -367,10 +333,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
mediaURL: originImgUrl,
|
mediaURL: originImgUrl,
|
||||||
onClickOrigin: () => _onClickOpenImageInNewWindow());
|
onClickOrigin: () => _onClickOpenImageInNewWindow());
|
||||||
} else {
|
} else {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(infoCode: 6660414, infoRecommendText: TIM_t("正在下载中"), type: TIMCallbackType.INFO));
|
||||||
infoCode: 6660414,
|
|
||||||
infoRecommendText: TIM_t("正在下载中"),
|
|
||||||
type: TIMCallbackType.INFO));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -438,9 +401,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
} else {
|
} else {
|
||||||
if (PlatformUtils().isDesktop) {
|
if (PlatformUtils().isDesktop) {
|
||||||
TUIKitWidePopup.showMedia(
|
TUIKitWidePopup.showMedia(
|
||||||
mediaLocalPath: imgPath,
|
mediaLocalPath: imgPath, context: context, onClickOrigin: () => launchDesktopFile(imgPath ?? ""));
|
||||||
context: context,
|
|
||||||
onClickOrigin: () => launchDesktopFile(imgPath ?? ""));
|
|
||||||
} else {
|
} else {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
PageRouteBuilder(
|
PageRouteBuilder(
|
||||||
|
|
@ -473,26 +434,19 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
return Hero(
|
return Hero(
|
||||||
tag: heroTag,
|
tag: heroTag,
|
||||||
child: PlatformUtils().isWeb
|
child: PlatformUtils().isWeb
|
||||||
? Image.network(webPath ?? smallImg?.url ?? originalImg!.url!,
|
? Image.network(webPath ?? smallImg?.url ?? originalImg!.url!, fit: BoxFit.contain)
|
||||||
fit: BoxFit.contain)
|
|
||||||
: CachedNetworkImage(
|
: CachedNetworkImage(
|
||||||
alignment: Alignment.topCenter,
|
alignment: Alignment.topCenter,
|
||||||
imageUrl: webPath ?? smallImg?.url ?? originalImg!.url!,
|
imageUrl: webPath ?? smallImg?.url ?? originalImg!.url!,
|
||||||
errorWidget: (context, error, stackTrace) =>
|
errorWidget: (context, error, stackTrace) => errorPage(theme),
|
||||||
errorPage(theme),
|
|
||||||
fit: BoxFit.contain,
|
fit: BoxFit.contain,
|
||||||
cacheKey: smallImg?.uuid ?? originalImg!.uuid,
|
cacheKey: smallImg?.uuid ?? originalImg!.uuid,
|
||||||
placeholder: (context, url) =>
|
placeholder: (context, url) => Image(image: MemoryImage(kTransparentImage)),
|
||||||
Image(image: MemoryImage(kTransparentImage)),
|
|
||||||
fadeInDuration: const Duration(milliseconds: 0),
|
fadeInDuration: const Duration(milliseconds: 0),
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
final imgPath = (TencentUtils.checkString(smallLocalPath) != null
|
final imgPath = (TencentUtils.checkString(smallLocalPath) != null ? smallLocalPath : originLocalPath)!;
|
||||||
? smallLocalPath
|
return Hero(tag: heroTag, child: Image.file(File(imgPath), fit: BoxFit.contain));
|
||||||
: originLocalPath)!;
|
|
||||||
return Hero(
|
|
||||||
tag: heroTag,
|
|
||||||
child: Image.file(File(imgPath), fit: BoxFit.contain));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -522,10 +476,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
heroTag: heroTag,
|
heroTag: heroTag,
|
||||||
isNetworkImage: isNetworkImage,
|
isNetworkImage: isNetworkImage,
|
||||||
imgUrl: webPath ?? smallImg?.url ?? originalImg?.url ?? "",
|
imgUrl: webPath ?? smallImg?.url ?? originalImg?.url ?? "",
|
||||||
imgPath: (TencentUtils.checkString(originLocalPath) != null
|
imgPath: (TencentUtils.checkString(originLocalPath) != null ? originLocalPath : smallLocalPath) ?? ""),
|
||||||
? originLocalPath
|
|
||||||
: smallLocalPath) ??
|
|
||||||
""),
|
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
if (positionRadio != null)
|
if (positionRadio != null)
|
||||||
|
|
@ -542,50 +493,29 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initImages() async {
|
void initImages() async {
|
||||||
final zeroImageLocal = TencentUtils.checkString(widget
|
final zeroImageLocal = TencentUtils.checkString(
|
||||||
.message.imageElem?.imageList
|
widget.message.imageElem?.imageList?.firstWhereOrNull((element) => element?.type == 0)?.localUrl);
|
||||||
?.firstWhereOrNull((element) => element?.type == 0)
|
final oneImageLocal = TencentUtils.checkString(
|
||||||
?.localUrl);
|
widget.message.imageElem?.imageList?.firstWhereOrNull((element) => element?.type == 1)?.localUrl);
|
||||||
final oneImageLocal = TencentUtils.checkString(widget
|
final twoImageLocal = TencentUtils.checkString(
|
||||||
.message.imageElem?.imageList
|
widget.message.imageElem?.imageList?.firstWhereOrNull((element) => element?.type == 2)?.localUrl);
|
||||||
?.firstWhereOrNull((element) => element?.type == 1)
|
|
||||||
?.localUrl);
|
|
||||||
final twoImageLocal = TencentUtils.checkString(widget
|
|
||||||
.message.imageElem?.imageList
|
|
||||||
?.firstWhereOrNull((element) => element?.type == 2)
|
|
||||||
?.localUrl);
|
|
||||||
|
|
||||||
if (!PlatformUtils().isWeb &&
|
if (!PlatformUtils().isWeb && TencentUtils.checkString(widget.message.msgID) != null) {
|
||||||
TencentUtils.checkString(widget.message.msgID) != null) {
|
if ((widget.message.imageElem?.imageList) == null || widget.message.imageElem!.imageList!.isEmpty) {
|
||||||
if ((widget.message.imageElem?.imageList) == null ||
|
final response = await _messageService.getMessageOnlineUrl(msgID: widget.message.msgID!);
|
||||||
widget.message.imageElem!.imageList!.isEmpty) {
|
|
||||||
final response = await _messageService.getMessageOnlineUrl(
|
|
||||||
msgID: widget.message.msgID!);
|
|
||||||
final elem = response.data;
|
final elem = response.data;
|
||||||
if (elem != null && elem.imageElem != null) {
|
if (elem != null && elem.imageElem != null) {
|
||||||
widget.message.imageElem = elem.imageElem;
|
widget.message.imageElem = elem.imageElem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (oneImageLocal == null || !File(oneImageLocal).existsSync()) {
|
if (oneImageLocal == null || !File(oneImageLocal).existsSync()) {
|
||||||
_messageService.downloadMessage(
|
_messageService.downloadMessage(msgID: widget.message.msgID!, messageType: 3, imageType: 1, isSnapshot: false);
|
||||||
msgID: widget.message.msgID!,
|
|
||||||
messageType: 3,
|
|
||||||
imageType: 1,
|
|
||||||
isSnapshot: false);
|
|
||||||
}
|
}
|
||||||
if (twoImageLocal == null || !File(twoImageLocal).existsSync()) {
|
if (twoImageLocal == null || !File(twoImageLocal).existsSync()) {
|
||||||
_messageService.downloadMessage(
|
_messageService.downloadMessage(msgID: widget.message.msgID!, messageType: 3, imageType: 2, isSnapshot: false);
|
||||||
msgID: widget.message.msgID!,
|
|
||||||
messageType: 3,
|
|
||||||
imageType: 2,
|
|
||||||
isSnapshot: false);
|
|
||||||
}
|
}
|
||||||
if (zeroImageLocal == null || !File(zeroImageLocal).existsSync()) {
|
if (zeroImageLocal == null || !File(zeroImageLocal).existsSync()) {
|
||||||
_messageService.downloadMessage(
|
_messageService.downloadMessage(msgID: widget.message.msgID!, messageType: 3, imageType: 0, isSnapshot: false);
|
||||||
msgID: widget.message.msgID!,
|
|
||||||
messageType: 3,
|
|
||||||
imageType: 0,
|
|
||||||
isSnapshot: false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -596,14 +526,9 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
initImages();
|
initImages();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget? _renderImage(dynamic heroTag, TUITheme theme,
|
Widget? _renderImage(dynamic heroTag, TUITheme theme, {V2TimImage? originalImg, V2TimImage? smallImg}) {
|
||||||
{V2TimImage? originalImg, V2TimImage? smallImg}) {
|
|
||||||
|
|
||||||
double positionRadio = 1.0;
|
double positionRadio = 1.0;
|
||||||
if (smallImg?.width != null &&
|
if (smallImg?.width != null && smallImg?.height != null && smallImg?.width != 0 && smallImg?.height != 0) {
|
||||||
smallImg?.height != null &&
|
|
||||||
smallImg?.width != 0 &&
|
|
||||||
smallImg?.height != 0) {
|
|
||||||
positionRadio = (smallImg!.width! / smallImg.height!);
|
positionRadio = (smallImg!.width! / smallImg.height!);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -637,10 +562,8 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ((TencentUtils.checkString(smallImg?.localUrl) != null &&
|
if ((TencentUtils.checkString(smallImg?.localUrl) != null && File((smallImg?.localUrl!)!).existsSync()) ||
|
||||||
File((smallImg?.localUrl!)!).existsSync()) ||
|
(TencentUtils.checkString(originalImg?.localUrl) != null && File((originalImg?.localUrl!)!).existsSync())) {
|
||||||
(TencentUtils.checkString(originalImg?.localUrl) != null &&
|
|
||||||
File((originalImg?.localUrl!)!).existsSync())) {
|
|
||||||
return _renderAllImage(
|
return _renderAllImage(
|
||||||
smallLocalPath: smallImg?.localUrl ?? "",
|
smallLocalPath: smallImg?.localUrl ?? "",
|
||||||
heroTag: heroTag,
|
heroTag: heroTag,
|
||||||
|
|
@ -660,8 +583,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
originalImg: originalImg);
|
originalImg: originalImg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((smallImg?.url ?? originalImg?.url) != null &&
|
if ((smallImg?.url ?? originalImg?.url) != null && (smallImg?.url ?? originalImg?.url)!.isNotEmpty) {
|
||||||
(smallImg?.url ?? originalImg?.url)!.isNotEmpty) {
|
|
||||||
return _renderAllImage(
|
return _renderAllImage(
|
||||||
heroTag: heroTag,
|
heroTag: heroTag,
|
||||||
theme: theme,
|
theme: theme,
|
||||||
|
|
@ -677,8 +599,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final theme = value.theme;
|
final theme = value.theme;
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
final heroTag =
|
final heroTag =
|
||||||
"${widget.message.msgID ?? widget.message.id ?? widget.message.timestamp ?? DateTime.now().millisecondsSinceEpoch}${widget.isFrom}";
|
"${widget.message.msgID ?? widget.message.id ?? widget.message.timestamp ?? DateTime.now().millisecondsSinceEpoch}${widget.isFrom}";
|
||||||
|
|
||||||
|
|
@ -691,16 +612,14 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
isFromSelf: widget.message.isSelf ?? true,
|
isFromSelf: widget.message.isSelf ?? true,
|
||||||
isShowMessageReaction: widget.isShowMessageReaction ?? true,
|
isShowMessageReaction: widget.isShowMessageReaction ?? true,
|
||||||
message: widget.message,
|
message: widget.message,
|
||||||
child: LayoutBuilder(
|
child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
|
||||||
return ConstrainedBox(
|
return ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: constraints.maxWidth * (isDesktopScreen ? 0.4 : 0.5),
|
maxWidth: constraints.maxWidth * (isDesktopScreen ? 0.4 : 0.5),
|
||||||
minWidth: 64,
|
minWidth: 64,
|
||||||
maxHeight: 256,
|
maxHeight: 256,
|
||||||
),
|
),
|
||||||
child: _renderImage(heroTag, theme,
|
child: _renderImage(heroTag, theme, originalImg: originalImg, smallImg: smallImg),
|
||||||
originalImg: originalImg, smallImg: smallImg),
|
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
@ -709,9 +628,7 @@ class _TIMUIKitImageElem extends TIMUIKitState<TIMUIKitImageElem> {
|
||||||
class ImageClipper extends CustomClipper<RRect> {
|
class ImageClipper extends CustomClipper<RRect> {
|
||||||
@override
|
@override
|
||||||
RRect getClip(Size size) {
|
RRect getClip(Size size) {
|
||||||
return RRect.fromRectAndRadius(
|
return RRect.fromRectAndRadius(Rect.fromLTWH(0, 0, size.width, min(size.height, 256)), const Radius.circular(5));
|
||||||
Rect.fromLTWH(0, 0, size.width, min(size.height, 256)),
|
|
||||||
const Radius.circular(5));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_model_tools.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_model_tools.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/common_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/platform.dart';
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@ import 'dart:math';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:just_audio/just_audio.dart';
|
import 'package:just_audio/just_audio.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_sound_elem.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_sound_elem.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_sound_elem.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
|
|
@ -95,7 +97,8 @@ class _TIMUIKitSoundElemState extends TIMUIKitState<TIMUIKitSoundElem> {
|
||||||
}
|
}
|
||||||
if (!PlatformUtils().isWeb) {
|
if (!PlatformUtils().isWeb) {
|
||||||
if (widget.message.soundElem!.localUrl == null || widget.message.soundElem!.localUrl == '') {
|
if (widget.message.soundElem!.localUrl == null || widget.message.soundElem!.localUrl == '') {
|
||||||
_messageService.downloadMessage(msgID: widget.message.msgID!, messageType: 4, imageType: 0, isSnapshot: false);
|
_messageService.downloadMessage(
|
||||||
|
msgID: widget.message.msgID!, messageType: 4, imageType: 0, isSnapshot: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -172,11 +175,21 @@ class _TIMUIKitSoundElemState extends TIMUIKitState<TIMUIKitSoundElem> {
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final theme = value.theme;
|
final theme = value.theme;
|
||||||
|
|
||||||
final backgroundColor = widget.isFromSelf ? (theme.chatMessageItemFromSelfBgColor ?? theme.lightPrimaryMaterialColor.shade50) : (theme.chatMessageItemFromOthersBgColor);
|
final backgroundColor = widget.isFromSelf
|
||||||
|
? (theme.chatMessageItemFromSelfBgColor ?? theme.lightPrimaryMaterialColor.shade50)
|
||||||
|
: (theme.chatMessageItemFromOthersBgColor);
|
||||||
|
|
||||||
final borderRadius = widget.isFromSelf
|
final borderRadius = widget.isFromSelf
|
||||||
? const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(2), bottomLeft: Radius.circular(10), bottomRight: Radius.circular(10))
|
? const BorderRadius.only(
|
||||||
: const BorderRadius.only(topLeft: Radius.circular(2), topRight: Radius.circular(10), bottomLeft: Radius.circular(10), bottomRight: Radius.circular(10));
|
topLeft: Radius.circular(10),
|
||||||
|
topRight: Radius.circular(2),
|
||||||
|
bottomLeft: Radius.circular(10),
|
||||||
|
bottomRight: Radius.circular(10))
|
||||||
|
: const BorderRadius.only(
|
||||||
|
topLeft: Radius.circular(2),
|
||||||
|
topRight: Radius.circular(10),
|
||||||
|
bottomLeft: Radius.circular(10),
|
||||||
|
bottomRight: Radius.circular(10));
|
||||||
if (widget.isShowJump) {
|
if (widget.isShowJump) {
|
||||||
if (!isShining) {
|
if (!isShining) {
|
||||||
Future.delayed(Duration.zero, () {
|
Future.delayed(Duration.zero, () {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:extended_text/extended_text.dart';
|
import 'package:extended_text/extended_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:extended_text/extended_text.dart';
|
import 'package:extended_text/extended_text.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||||
import 'package:open_file/open_file.dart';
|
import 'package:open_file/open_file.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_video_elem.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_video_elem.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_video_elem.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
|
|
@ -80,21 +82,18 @@ class _TIMUIKitVideoElemState extends TIMUIKitState<TIMUIKitVideoElem> {
|
||||||
final current = (DateTime.now().millisecondsSinceEpoch / 1000).ceil();
|
final current = (DateTime.now().millisecondsSinceEpoch / 1000).ceil();
|
||||||
final timeStamp = widget.message.timestamp ?? current;
|
final timeStamp = widget.message.timestamp ?? current;
|
||||||
if (current - timeStamp < 300) {
|
if (current - timeStamp < 300) {
|
||||||
if (stateElement.snapshotPath != null &&
|
if (stateElement.snapshotPath != null && stateElement.snapshotPath != '') {
|
||||||
stateElement.snapshotPath != '') {
|
|
||||||
File imgF = File(stateElement.snapshotPath!);
|
File imgF = File(stateElement.snapshotPath!);
|
||||||
bool isExist = imgF.existsSync();
|
bool isExist = imgF.existsSync();
|
||||||
if (isExist) {
|
if (isExist) {
|
||||||
return Image.file(File(stateElement.snapshotPath!),
|
return Image.file(File(stateElement.snapshotPath!), fit: BoxFit.fitWidth);
|
||||||
fit: BoxFit.fitWidth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((stateElement.snapshotUrl == null || stateElement.snapshotUrl == '') &&
|
if ((stateElement.snapshotUrl == null || stateElement.snapshotUrl == '') &&
|
||||||
(stateElement.snapshotPath == null ||
|
(stateElement.snapshotPath == null || stateElement.snapshotPath == '')) {
|
||||||
stateElement.snapshotPath == '')) {
|
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
||||||
|
|
@ -120,22 +119,16 @@ class _TIMUIKitVideoElemState extends TIMUIKitState<TIMUIKitVideoElem> {
|
||||||
widget.message.status == MessageStatus.V2TIM_MSG_STATUS_SENDING)
|
widget.message.status == MessageStatus.V2TIM_MSG_STATUS_SENDING)
|
||||||
? (stateElement.snapshotPath!.isNotEmpty
|
? (stateElement.snapshotPath!.isNotEmpty
|
||||||
? Image.file(File(stateElement.snapshotPath!), fit: BoxFit.fitWidth)
|
? Image.file(File(stateElement.snapshotPath!), fit: BoxFit.fitWidth)
|
||||||
: Image.file(File(stateElement.localSnapshotUrl!),
|
: Image.file(File(stateElement.localSnapshotUrl!), fit: BoxFit.fitWidth))
|
||||||
fit: BoxFit.fitWidth))
|
: (PlatformUtils().isWeb || stateElement.localSnapshotUrl == null || stateElement.localSnapshotUrl == "")
|
||||||
: (PlatformUtils().isWeb ||
|
|
||||||
stateElement.localSnapshotUrl == null ||
|
|
||||||
stateElement.localSnapshotUrl == "")
|
|
||||||
? Image.network(stateElement.snapshotUrl!, fit: BoxFit.fitWidth)
|
? Image.network(stateElement.snapshotUrl!, fit: BoxFit.fitWidth)
|
||||||
: Image.file(File(stateElement.localSnapshotUrl!),
|
: Image.file(File(stateElement.localSnapshotUrl!), fit: BoxFit.fitWidth);
|
||||||
fit: BoxFit.fitWidth);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadMessageDetailAndSave() async {
|
downloadMessageDetailAndSave() async {
|
||||||
if (TencentUtils.checkString(widget.message.msgID) != null) {
|
if (TencentUtils.checkString(widget.message.msgID) != null) {
|
||||||
if (TencentUtils.checkString(widget.message.videoElem!.videoUrl) ==
|
if (TencentUtils.checkString(widget.message.videoElem!.videoUrl) == null) {
|
||||||
null) {
|
final response = await _messageService.getMessageOnlineUrl(msgID: widget.message.msgID!);
|
||||||
final response = await _messageService.getMessageOnlineUrl(
|
|
||||||
msgID: widget.message.msgID!);
|
|
||||||
if (response.data != null) {
|
if (response.data != null) {
|
||||||
widget.message.videoElem = response.data!.videoElem;
|
widget.message.videoElem = response.data!.videoElem;
|
||||||
Future.delayed(const Duration(microseconds: 10), () {
|
Future.delayed(const Duration(microseconds: 10), () {
|
||||||
|
|
@ -144,24 +137,14 @@ class _TIMUIKitVideoElemState extends TIMUIKitState<TIMUIKitVideoElem> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!PlatformUtils().isWeb) {
|
if (!PlatformUtils().isWeb) {
|
||||||
if (TencentUtils.checkString(widget.message.videoElem!.localVideoUrl) ==
|
if (TencentUtils.checkString(widget.message.videoElem!.localVideoUrl) == null ||
|
||||||
null ||
|
|
||||||
!File(widget.message.videoElem!.localVideoUrl!).existsSync()) {
|
!File(widget.message.videoElem!.localVideoUrl!).existsSync()) {
|
||||||
_messageService.downloadMessage(
|
_messageService.downloadMessage(
|
||||||
msgID: widget.message.msgID!,
|
msgID: widget.message.msgID!, messageType: 5, imageType: 0, isSnapshot: false);
|
||||||
messageType: 5,
|
|
||||||
imageType: 0,
|
|
||||||
isSnapshot: false);
|
|
||||||
}
|
}
|
||||||
if (TencentUtils.checkString(
|
if (TencentUtils.checkString(widget.message.videoElem!.localSnapshotUrl) == null ||
|
||||||
widget.message.videoElem!.localSnapshotUrl) ==
|
|
||||||
null ||
|
|
||||||
!File(widget.message.videoElem!.localSnapshotUrl!).existsSync()) {
|
!File(widget.message.videoElem!.localSnapshotUrl!).existsSync()) {
|
||||||
_messageService.downloadMessage(
|
_messageService.downloadMessage(msgID: widget.message.msgID!, messageType: 5, imageType: 0, isSnapshot: true);
|
||||||
msgID: widget.message.msgID!,
|
|
||||||
messageType: 5,
|
|
||||||
imageType: 0,
|
|
||||||
isSnapshot: true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -181,7 +164,6 @@ class _TIMUIKitVideoElemState extends TIMUIKitState<TIMUIKitVideoElem> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final theme = value.theme;
|
final theme = value.theme;
|
||||||
|
|
@ -196,16 +178,15 @@ class _TIMUIKitVideoElemState extends TIMUIKitState<TIMUIKitVideoElem> {
|
||||||
context: context,
|
context: context,
|
||||||
mediaURL: url,
|
mediaURL: url,
|
||||||
onClickOrigin: () => launchUrl(
|
onClickOrigin: () => launchUrl(
|
||||||
Uri.parse(url),
|
Uri.parse(url),
|
||||||
mode: LaunchMode.externalApplication,
|
mode: LaunchMode.externalApplication,
|
||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (PlatformUtils().isDesktop) {
|
if (PlatformUtils().isDesktop) {
|
||||||
final videoElem = widget.message.videoElem;
|
final videoElem = widget.message.videoElem;
|
||||||
if (videoElem != null) {
|
if (videoElem != null) {
|
||||||
final localVideoUrl =
|
final localVideoUrl = TencentUtils.checkString(videoElem.localVideoUrl);
|
||||||
TencentUtils.checkString(videoElem.localVideoUrl);
|
|
||||||
final videoPath = TencentUtils.checkString(videoElem.videoPath);
|
final videoPath = TencentUtils.checkString(videoElem.videoPath);
|
||||||
final videoUrl = videoElem.videoUrl;
|
final videoUrl = videoElem.videoUrl;
|
||||||
if (localVideoUrl != null) {
|
if (localVideoUrl != null) {
|
||||||
|
|
@ -223,10 +204,8 @@ class _TIMUIKitVideoElemState extends TIMUIKitState<TIMUIKitVideoElem> {
|
||||||
// mediaPath: videoPath,
|
// mediaPath: videoPath,
|
||||||
// onClickOrigin: () => launchDesktopFile(videoPath));
|
// onClickOrigin: () => launchDesktopFile(videoPath));
|
||||||
} else if (TencentUtils.isTextNotEmpty(videoUrl)) {
|
} else if (TencentUtils.isTextNotEmpty(videoUrl)) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(
|
||||||
infoCode: 6660414,
|
TIMCallback(infoCode: 6660414, infoRecommendText: TIM_t("正在下载中"), type: TIMCallbackType.INFO));
|
||||||
infoRecommendText: TIM_t("正在下载中"),
|
|
||||||
type: TIMCallbackType.INFO));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -253,67 +232,50 @@ class _TIMUIKitVideoElemState extends TIMUIKitState<TIMUIKitVideoElem> {
|
||||||
isFromSelf: widget.message.isSelf ?? true,
|
isFromSelf: widget.message.isSelf ?? true,
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
borderRadius: const BorderRadius.all(Radius.circular(5)),
|
||||||
child: LayoutBuilder(builder:
|
child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
(BuildContext context, BoxConstraints constraints) {
|
|
||||||
double? positionRadio;
|
double? positionRadio;
|
||||||
if ((stateElement.snapshotWidth) != null &&
|
if ((stateElement.snapshotWidth) != null &&
|
||||||
stateElement.snapshotHeight != null &&
|
stateElement.snapshotHeight != null &&
|
||||||
stateElement.snapshotWidth != 0 &&
|
stateElement.snapshotWidth != 0 &&
|
||||||
stateElement.snapshotHeight != 0) {
|
stateElement.snapshotHeight != 0) {
|
||||||
positionRadio = (stateElement.snapshotWidth! /
|
positionRadio = (stateElement.snapshotWidth! / stateElement.snapshotHeight!);
|
||||||
stateElement.snapshotHeight!);
|
|
||||||
}
|
}
|
||||||
return ConstrainedBox(
|
return ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: PlatformUtils().isWeb
|
maxWidth: PlatformUtils().isWeb ? 300 : constraints.maxWidth * 0.5,
|
||||||
? 300
|
|
||||||
: constraints.maxWidth * 0.5,
|
|
||||||
maxHeight: min(constraints.maxHeight * 0.8, 300),
|
maxHeight: min(constraints.maxHeight * 0.8, 300),
|
||||||
minHeight: 20,
|
minHeight: 20,
|
||||||
minWidth: 20),
|
minWidth: 20),
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (positionRadio != null &&
|
if (positionRadio != null &&
|
||||||
(stateElement.snapshotUrl != null ||
|
(stateElement.snapshotUrl != null || stateElement.snapshotUrl != null))
|
||||||
stateElement.snapshotUrl != null))
|
|
||||||
AspectRatio(
|
AspectRatio(
|
||||||
aspectRatio: positionRadio,
|
aspectRatio: positionRadio,
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(color: Colors.transparent),
|
||||||
color: Colors.transparent),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [Expanded(child: generateSnapshot(theme, stateElement.snapshotHeight ?? 100))],
|
||||||
Expanded(
|
|
||||||
child: generateSnapshot(theme,
|
|
||||||
stateElement.snapshotHeight ?? 100))
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
if (widget.message.status !=
|
if (widget.message.status != MessageStatus.V2TIM_MSG_STATUS_SENDING &&
|
||||||
MessageStatus.V2TIM_MSG_STATUS_SENDING &&
|
(stateElement.snapshotUrl != null || stateElement.snapshotPath != null) &&
|
||||||
(stateElement.snapshotUrl != null ||
|
|
||||||
stateElement.snapshotPath != null) &&
|
|
||||||
stateElement.videoPath != null ||
|
stateElement.videoPath != null ||
|
||||||
stateElement.videoUrl != null)
|
stateElement.videoUrl != null)
|
||||||
Positioned.fill(
|
Positioned.fill(
|
||||||
// alignment: Alignment.center,
|
// alignment: Alignment.center,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Image.asset('images/play.png',
|
child:
|
||||||
package: 'tencent_cloud_chat_uikit',
|
Image.asset('images/play.png', package: 'tencent_cloud_chat_uikit', height: 64)),
|
||||||
height: 64)),
|
|
||||||
),
|
),
|
||||||
if (widget.message.videoElem?.duration != null &&
|
if (widget.message.videoElem?.duration != null && widget.message.videoElem!.duration! > 0)
|
||||||
widget.message.videoElem!.duration! > 0)
|
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 10,
|
right: 10,
|
||||||
bottom: 10,
|
bottom: 10,
|
||||||
child: Text(
|
child: Text(
|
||||||
MessageUtils.formatVideoTime(widget
|
MessageUtils.formatVideoTime(widget.message.videoElem!.duration!).toString(),
|
||||||
.message.videoElem!.duration!)
|
style: const TextStyle(color: Colors.white, fontSize: 12))),
|
||||||
.toString(),
|
|
||||||
style: const TextStyle(
|
|
||||||
color: Colors.white, fontSize: 12))),
|
|
||||||
],
|
],
|
||||||
));
|
));
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,12 @@ import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:better_player_plus/better_player_plus.dart';
|
import 'package:better_player_plus/better_player_plus.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_online_url.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_online_url.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_online_url.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
|
|
||||||
|
|
@ -83,9 +86,9 @@ class TIMUIKitVideoPlayerState extends State<TIMUIKitVideoPlayer> {
|
||||||
enableProgressBar: true,
|
enableProgressBar: true,
|
||||||
enableProgressText: true,
|
enableProgressText: true,
|
||||||
showControlsOnInitialize: false,
|
showControlsOnInitialize: false,
|
||||||
enableMute:false,
|
enableMute: false,
|
||||||
enableOverflowMenu:false,
|
enableOverflowMenu: false,
|
||||||
enableSkips:false,
|
enableSkips: false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -95,8 +98,7 @@ class TIMUIKitVideoPlayerState extends State<TIMUIKitVideoPlayer> {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
@ -134,13 +136,15 @@ class TIMUIKitVideoPlayerState extends State<TIMUIKitVideoPlayer> {
|
||||||
// 先查本地发送的视频地址
|
// 先查本地发送的视频地址
|
||||||
if (File(widget.message.videoElem!.videoPath!).existsSync()) {
|
if (File(widget.message.videoElem!.videoPath!).existsSync()) {
|
||||||
console("video: local video path exists");
|
console("video: local video path exists");
|
||||||
return CurrentVideoInfo(path: widget.message.videoElem!.videoPath!, type: CurrentVideoType.local, aspectRatio: aspectRatio);
|
return CurrentVideoInfo(
|
||||||
|
path: widget.message.videoElem!.videoPath!, type: CurrentVideoType.local, aspectRatio: aspectRatio);
|
||||||
}
|
}
|
||||||
} else if (TencentUtils.checkString(widget.message.videoElem!.localVideoUrl) != null) {
|
} else if (TencentUtils.checkString(widget.message.videoElem!.localVideoUrl) != null) {
|
||||||
// 再查本地下载的视频地址
|
// 再查本地下载的视频地址
|
||||||
if (File(widget.message.videoElem!.localVideoUrl!).existsSync()) {
|
if (File(widget.message.videoElem!.localVideoUrl!).existsSync()) {
|
||||||
console("video: local url exists");
|
console("video: local url exists");
|
||||||
return CurrentVideoInfo(path: widget.message.videoElem!.localVideoUrl!, type: CurrentVideoType.local, aspectRatio: aspectRatio);
|
return CurrentVideoInfo(
|
||||||
|
path: widget.message.videoElem!.localVideoUrl!, type: CurrentVideoType.local, aspectRatio: aspectRatio);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 最后再查在线地址(todo 使用 getMessageOnlineUrl 查询)
|
// 最后再查在线地址(todo 使用 getMessageOnlineUrl 查询)
|
||||||
|
|
@ -155,12 +159,15 @@ class TIMUIKitVideoPlayerState extends State<TIMUIKitVideoPlayer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb) {
|
||||||
V2TimValueCallback<V2TimMessageOnlineUrl> urlres = await TencentImSDKPlugin.v2TIMManager.getMessageManager().getMessageOnlineUrl(msgID: widget.message.msgID ?? "");
|
V2TimValueCallback<V2TimMessageOnlineUrl> urlres = await TencentImSDKPlugin.v2TIMManager
|
||||||
|
.getMessageManager()
|
||||||
|
.getMessageOnlineUrl(msgID: widget.message.msgID ?? "");
|
||||||
if (urlres.data != null) {
|
if (urlres.data != null) {
|
||||||
if (urlres.data?.videoElem != null) {
|
if (urlres.data?.videoElem != null) {
|
||||||
if (TencentUtils.checkString(urlres.data?.videoElem?.videoUrl) != null) {
|
if (TencentUtils.checkString(urlres.data?.videoElem?.videoUrl) != null) {
|
||||||
console("view video online url ${urlres.data?.videoElem?.videoUrl}");
|
console("view video online url ${urlres.data?.videoElem?.videoUrl}");
|
||||||
return CurrentVideoInfo(path: urlres.data!.videoElem!.videoUrl!, type: CurrentVideoType.online, aspectRatio: aspectRatio);
|
return CurrentVideoInfo(
|
||||||
|
path: urlres.data!.videoElem!.videoUrl!, type: CurrentVideoType.online, aspectRatio: aspectRatio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -199,4 +206,4 @@ class TIMUIKitVideoPlayerState extends State<TIMUIKitVideoPlayer> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_merger_elem.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_merger_elem.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_merger_elem.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_wide_modal_operation_key.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/core/tim_uikit_wide_modal_operation_key.dart';
|
||||||
|
|
@ -81,8 +83,7 @@ class TIMUIKitMergerElemState extends TIMUIKitState<TIMUIKitMergerElem> {
|
||||||
_handleTap(BuildContext context, TUIChatSeparateViewModel model) async {
|
_handleTap(BuildContext context, TUIChatSeparateViewModel model) async {
|
||||||
try {
|
try {
|
||||||
if (widget.messageID != "") {
|
if (widget.messageID != "") {
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
|
|
||||||
if (isDesktopScreen) {
|
if (isDesktopScreen) {
|
||||||
TUIKitWidePopup.showPopupWindow(
|
TUIKitWidePopup.showPopupWindow(
|
||||||
|
|
@ -94,9 +95,7 @@ class TIMUIKitMergerElemState extends TIMUIKitState<TIMUIKitMergerElem> {
|
||||||
child: (onClose) => Scrollbar(
|
child: (onClose) => Scrollbar(
|
||||||
controller: _scrollController,
|
controller: _scrollController,
|
||||||
child: MergerMessageScreen(
|
child: MergerMessageScreen(
|
||||||
messageItemBuilder: widget.messageItemBuilder,
|
messageItemBuilder: widget.messageItemBuilder, model: model, msgID: widget.messageID),
|
||||||
model: model,
|
|
||||||
msgID: widget.messageID),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -104,17 +103,12 @@ class TIMUIKitMergerElemState extends TIMUIKitState<TIMUIKitMergerElem> {
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => MergerMessageScreen(
|
builder: (context) => MergerMessageScreen(
|
||||||
messageItemBuilder: widget.messageItemBuilder,
|
messageItemBuilder: widget.messageItemBuilder, model: model, msgID: widget.messageID),
|
||||||
model: model,
|
|
||||||
msgID: widget.messageID),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
onTIMCallback(TIMCallback(
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("无法定位到原消息"), infoCode: 6660401));
|
||||||
type: TIMCallbackType.INFO,
|
|
||||||
infoRecommendText: TIM_t("无法定位到原消息"),
|
|
||||||
infoCode: 6660401));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -134,12 +128,9 @@ class TIMUIKitMergerElemState extends TIMUIKitState<TIMUIKitMergerElem> {
|
||||||
_showJumpColor();
|
_showJumpColor();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
return Container(
|
return Container(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * (isDesktopScreen ? 0.3 : 0.6)),
|
||||||
maxWidth:
|
|
||||||
MediaQuery.of(context).size.width * (isDesktopScreen ? 0.3 : 0.6)),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
|
|
@ -221,8 +212,7 @@ class TIMUIKitMergerElemState extends TIMUIKitState<TIMUIKitMergerElem> {
|
||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.isShowMessageReaction ?? true)
|
if (widget.isShowMessageReaction ?? true) TIMUIKitMessageReactionShowPanel(message: widget.message)
|
||||||
TIMUIKitMessageReactionShowPanel(message: widget.message)
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
|
|
@ -39,8 +40,7 @@ class _AtMemberPanelState extends TIMUIKitState<AtMemberPanel> {
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final theme = value.theme;
|
final theme = value.theme;
|
||||||
final chatModal = Provider.of<TUIChatSeparateViewModel>(context);
|
final chatModal = Provider.of<TUIChatSeparateViewModel>(context);
|
||||||
final List<V2TimGroupMemberFullInfo?> groupMemberList =
|
final List<V2TimGroupMemberFullInfo?> groupMemberList = chatModal.showAtMemberList;
|
||||||
chatModal.showAtMemberList;
|
|
||||||
final double positionX = chatModal.atPositionX;
|
final double positionX = chatModal.atPositionX;
|
||||||
final double positionY = chatModal.atPositionY;
|
final double positionY = chatModal.atPositionY;
|
||||||
final int activeIndex = chatModal.activeAtIndex;
|
final int activeIndex = chatModal.activeAtIndex;
|
||||||
|
|
@ -67,10 +67,7 @@ class _AtMemberPanelState extends TIMUIKitState<AtMemberPanel> {
|
||||||
itemBuilder: ((context, index) {
|
itemBuilder: ((context, index) {
|
||||||
final memberItem = groupMemberList[index];
|
final memberItem = groupMemberList[index];
|
||||||
if (memberItem == null) {
|
if (memberItem == null) {
|
||||||
return AutoScrollTag(
|
return AutoScrollTag(key: ValueKey(index), controller: widget.atMemberPanelScroll, index: index);
|
||||||
key: ValueKey(index),
|
|
||||||
controller: widget.atMemberPanelScroll,
|
|
||||||
index: index);
|
|
||||||
}
|
}
|
||||||
final showName = _getShowName(memberItem);
|
final showName = _getShowName(memberItem);
|
||||||
final isAtAll = memberItem.userID == "__kImSDK_MesssageAtALL__";
|
final isAtAll = memberItem.userID == "__kImSDK_MesssageAtALL__";
|
||||||
|
|
@ -86,11 +83,8 @@ class _AtMemberPanelState extends TIMUIKitState<AtMemberPanel> {
|
||||||
widget.onSelectMember(memberItem);
|
widget.onSelectMember(memberItem);
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||||
horizontal: 8, vertical: 4),
|
color: activeIndex == index ? theme.weakBackgroundColor : theme.wideBackgroundColor,
|
||||||
color: activeIndex == index
|
|
||||||
? theme.weakBackgroundColor
|
|
||||||
: theme.wideBackgroundColor,
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
|
@ -98,28 +92,22 @@ class _AtMemberPanelState extends TIMUIKitState<AtMemberPanel> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 24,
|
height: 24,
|
||||||
width: 24,
|
width: 24,
|
||||||
child: Avatar(
|
child: Avatar(faceUrl: memberItem.faceUrl ?? "", type: 1, showName: showName),
|
||||||
faceUrl: memberItem.faceUrl ?? "",
|
|
||||||
type: 1,
|
|
||||||
showName: showName),
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 8,
|
width: 8,
|
||||||
),
|
),
|
||||||
Expanded(child: Text(
|
Expanded(
|
||||||
isAtAll
|
child: Text(
|
||||||
? "$showName(${groupMemberList.length - 1})"
|
isAtAll ? "$showName(${groupMemberList.length - 1})" : showName,
|
||||||
: showName,
|
|
||||||
softWrap: false,
|
softWrap: false,
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
fontWeight: memberItem.role == 400 ||
|
fontWeight: memberItem.role == 400 || memberItem.role == 300
|
||||||
memberItem.role == 300
|
|
||||||
? FontWeight.w500
|
? FontWeight.w500
|
||||||
: FontWeight.normal,
|
: FontWeight.normal,
|
||||||
color: memberItem.role == 400 ||
|
color: memberItem.role == 400 || memberItem.role == 300
|
||||||
memberItem.role == 300
|
|
||||||
? theme.primaryColor
|
? theme.primaryColor
|
||||||
: theme.darkTextColor),
|
: theme.darkTextColor),
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,17 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_self_info_view_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart';
|
||||||
|
|
@ -78,8 +84,7 @@ class _AtTextState extends TIMUIKitState<AtText> {
|
||||||
|
|
||||||
Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMember(
|
Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMember(
|
||||||
V2TimGroupMemberSearchParam searchParam) async {
|
V2TimGroupMemberSearchParam searchParam) async {
|
||||||
final res =
|
final res = await _groupServices.searchGroupMembers(searchParam: searchParam);
|
||||||
await _groupServices.searchGroupMembers(searchParam: searchParam);
|
|
||||||
|
|
||||||
if (res.code == 0) {}
|
if (res.code == 0) {}
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -105,8 +110,7 @@ class _AtTextState extends TIMUIKitState<AtText> {
|
||||||
}
|
}
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
searchMemberList =
|
searchMemberList = isSearchTextExist(searchText) ? searchMemberList : groupMemberList;
|
||||||
isSearchTextExist(searchText) ? searchMemberList : groupMemberList;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -148,8 +152,7 @@ class _AtTextState extends TIMUIKitState<AtText> {
|
||||||
customTopArea: PlatformUtils().isWeb
|
customTopArea: PlatformUtils().isWeb
|
||||||
? null
|
? null
|
||||||
: GroupMemberSearchTextField(
|
: GroupMemberSearchTextField(
|
||||||
onTextChange: (text) =>
|
onTextChange: (text) => handleSearchGroupMembers(text, context),
|
||||||
handleSearchGroupMembers(text, context),
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,7 +199,7 @@ class _AtTextState extends TIMUIKitState<AtText> {
|
||||||
_submitAtMemberList();
|
_submitAtMemberList();
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t("确定"),
|
TIM_t("确定"),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: theme.appbarTextColor,
|
color: theme.appbarTextColor,
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,14 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_filter_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_filter_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_param.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_value_callback.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_value_callback.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/group/group_services.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
||||||
|
|
@ -56,16 +60,13 @@ class _SelectCallInviterState extends TIMUIKitState<SelectCallInviter> {
|
||||||
return searchText != null && searchText != "";
|
return searchText != null && searchText != "";
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _loadGroupMemberList(
|
Future<void> _loadGroupMemberList({required String groupID, int count = 100, String? seq}) async {
|
||||||
{required String groupID, int count = 100, String? seq}) async {
|
|
||||||
if (seq == null || seq == "" || seq == "0") {
|
if (seq == null || seq == "" || seq == "0") {
|
||||||
_groupMemberList = [];
|
_groupMemberList = [];
|
||||||
}
|
}
|
||||||
final String? nextSeq = await _loadGroupMemberListFunction(
|
final String? nextSeq = await _loadGroupMemberListFunction(groupID: groupID, seq: seq, count: count);
|
||||||
groupID: groupID, seq: seq, count: count);
|
|
||||||
if (nextSeq != null && nextSeq != "0" && nextSeq != "") {
|
if (nextSeq != null && nextSeq != "0" && nextSeq != "") {
|
||||||
return await _loadGroupMemberList(
|
return await _loadGroupMemberList(groupID: groupID, count: count, seq: nextSeq);
|
||||||
groupID: groupID, count: count, seq: nextSeq);
|
|
||||||
} else {
|
} else {
|
||||||
setState(() {
|
setState(() {
|
||||||
_groupMemberList = _groupMemberList;
|
_groupMemberList = _groupMemberList;
|
||||||
|
|
@ -75,8 +76,7 @@ class _SelectCallInviterState extends TIMUIKitState<SelectCallInviter> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> _loadGroupMemberListFunction(
|
Future<String?> _loadGroupMemberListFunction({required String groupID, int count = 100, String? seq}) async {
|
||||||
{required String groupID, int count = 100, String? seq}) async {
|
|
||||||
if (seq == "0") {
|
if (seq == "0") {
|
||||||
_groupMemberList?.clear();
|
_groupMemberList?.clear();
|
||||||
}
|
}
|
||||||
|
|
@ -96,8 +96,7 @@ class _SelectCallInviterState extends TIMUIKitState<SelectCallInviter> {
|
||||||
|
|
||||||
Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMember(
|
Future<V2TimValueCallback<V2GroupMemberInfoSearchResult>> searchGroupMember(
|
||||||
V2TimGroupMemberSearchParam searchParam) async {
|
V2TimGroupMemberSearchParam searchParam) async {
|
||||||
final res =
|
final res = await _groupServices.searchGroupMembers(searchParam: searchParam);
|
||||||
await _groupServices.searchGroupMembers(searchParam: searchParam);
|
|
||||||
|
|
||||||
if (res.code == 0) {}
|
if (res.code == 0) {}
|
||||||
return res;
|
return res;
|
||||||
|
|
@ -131,8 +130,7 @@ class _SelectCallInviterState extends TIMUIKitState<SelectCallInviter> {
|
||||||
}
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
loading = false;
|
loading = false;
|
||||||
searchMemberList =
|
searchMemberList = isSearchTextExist(searchText) ? currentGroupMember : _groupMemberList;
|
||||||
isSearchTextExist(searchText) ? currentGroupMember : _groupMemberList;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -146,8 +144,7 @@ class _SelectCallInviterState extends TIMUIKitState<SelectCallInviter> {
|
||||||
iconTheme: IconThemeData(
|
iconTheme: IconThemeData(
|
||||||
color: theme.appbarTextColor,
|
color: theme.appbarTextColor,
|
||||||
),
|
),
|
||||||
backgroundColor: theme.appbarBgColor ??
|
backgroundColor: theme.appbarBgColor ?? theme.primaryColor,
|
||||||
theme.primaryColor,
|
|
||||||
leading: TextButton(
|
leading: TextButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
@ -191,12 +188,10 @@ class _SelectCallInviterState extends TIMUIKitState<SelectCallInviter> {
|
||||||
customTopArea: PlatformUtils().isWeb
|
customTopArea: PlatformUtils().isWeb
|
||||||
? null
|
? null
|
||||||
: GroupMemberSearchTextField(
|
: GroupMemberSearchTextField(
|
||||||
onTextChange: (text) =>
|
onTextChange: (text) => handleSearchGroupMembers(text, context),
|
||||||
handleSearchGroupMembers(text, context),
|
|
||||||
),
|
),
|
||||||
memberList: (searchMemberList ?? [])
|
memberList: (searchMemberList ?? [])
|
||||||
.where((element) =>
|
.where((element) => element?.userID != _coreServicesImpl.loginInfo.userID)
|
||||||
element?.userID != _coreServicesImpl.loginInfo.userID)
|
|
||||||
.toList(),
|
.toList(),
|
||||||
canSlideDelete: false,
|
canSlideDelete: false,
|
||||||
canSelectMember: true,
|
canSelectMember: true,
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,8 @@ import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/tim_uikit_call_invite_list.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitChat/TIMUIKitTextField/tim_uikit_call_invite_list.dart';
|
||||||
import 'package:video_player/video_player.dart';
|
import 'package:video_player/video_player.dart';
|
||||||
|
|
@ -475,14 +476,12 @@ class _MorePanelState extends TIMUIKitState<MorePanel> {
|
||||||
final size = await originFile!.length();
|
final size = await originFile!.length();
|
||||||
if (!isVideo) {
|
if (!isVideo) {
|
||||||
if (size >= MorePanelConfig.IMAGE_MAX_SIZE) {
|
if (size >= MorePanelConfig.IMAGE_MAX_SIZE) {
|
||||||
onTIMCallback(
|
onTIMCallback(TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("文件大小超出了限制")));
|
||||||
TIMCallback(type: TIMCallbackType.INFO, infoRecommendText: TIM_t("文件大小超出了限制")));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageUtils.handleMessageError(
|
MessageUtils.handleMessageError(
|
||||||
model.sendImageMessage(imagePath: originFile.path, convID: convID, convType: convType),
|
model.sendImageMessage(imagePath: originFile.path, convID: convID, convType: convType), context);
|
||||||
context);
|
|
||||||
} else {
|
} else {
|
||||||
// 监听视频准备完成事件
|
// 监听视频准备完成事件
|
||||||
_betterPlayerController.addEventsListener((event) {
|
_betterPlayerController.addEventsListener((event) {
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,12 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
|
|
@ -167,7 +170,11 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
baseUrl: "assets/custom_face_resource/${tccEmojiSet.name}",
|
baseUrl: "assets/custom_face_resource/${tccEmojiSet.name}",
|
||||||
isEmoji: tccEmojiSet.isEmoji,
|
isEmoji: tccEmojiSet.isEmoji,
|
||||||
isDefaultEmoji: true,
|
isDefaultEmoji: true,
|
||||||
stickerList: tccEmojiSet.list.asMap().keys.map((idx) => CustomSticker(index: idx, name: tccEmojiSet.list[idx])).toList(),
|
stickerList: tccEmojiSet.list
|
||||||
|
.asMap()
|
||||||
|
.keys
|
||||||
|
.map((idx) => CustomSticker(index: idx, name: tccEmojiSet.list[idx]))
|
||||||
|
.toList(),
|
||||||
menuItem: CustomSticker(
|
menuItem: CustomSticker(
|
||||||
index: 0,
|
index: 0,
|
||||||
name: tccEmojiSet.icon,
|
name: tccEmojiSet.icon,
|
||||||
|
|
@ -181,7 +188,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
baseUrl: "assets/custom_face_resource/${qqEmojiSet.name}",
|
baseUrl: "assets/custom_face_resource/${qqEmojiSet.name}",
|
||||||
isEmoji: qqEmojiSet.isEmoji,
|
isEmoji: qqEmojiSet.isEmoji,
|
||||||
isDefaultEmoji: true,
|
isDefaultEmoji: true,
|
||||||
stickerList: qqEmojiSet.list.asMap().keys.map((idx) => CustomSticker(index: idx, name: qqEmojiSet.list[idx])).toList(),
|
stickerList:
|
||||||
|
qqEmojiSet.list.asMap().keys.map((idx) => CustomSticker(index: idx, name: qqEmojiSet.list[idx])).toList(),
|
||||||
menuItem: CustomSticker(
|
menuItem: CustomSticker(
|
||||||
index: 0,
|
index: 0,
|
||||||
name: qqEmojiSet.icon,
|
name: qqEmojiSet.icon,
|
||||||
|
|
@ -192,7 +200,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
final defEmojiList = TUIKitStickerConstData.defaultUnicodeEmojiList.map((emojiItem) {
|
final defEmojiList = TUIKitStickerConstData.defaultUnicodeEmojiList.map((emojiItem) {
|
||||||
return CustomSticker(index: 0, name: emojiItem.toString(), unicode: emojiItem);
|
return CustomSticker(index: 0, name: emojiItem.toString(), unicode: emojiItem);
|
||||||
}).toList();
|
}).toList();
|
||||||
stickerPackageList.add(CustomStickerPackage(name: "defaultEmoji", stickerList: defEmojiList, menuItem: defEmojiList[0]));
|
stickerPackageList
|
||||||
|
.add(CustomStickerPackage(name: "defaultEmoji", stickerList: defEmojiList, menuItem: defEmojiList[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
stickerPackageList.addAll(stickerConfig.customStickerPackages);
|
stickerPackageList.addAll(stickerConfig.customStickerPackages);
|
||||||
|
|
@ -242,7 +251,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
textEditingController.text = text;
|
textEditingController.text = text;
|
||||||
|
|
||||||
if (TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop) {
|
if (TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop) {
|
||||||
textEditingController.selection = TextSelection.fromPosition(TextPosition(offset: currentCursor ?? textEditingController.text.length));
|
textEditingController.selection =
|
||||||
|
TextSelection.fromPosition(TextPosition(offset: currentCursor ?? textEditingController.text.length));
|
||||||
focusNode.requestFocus();
|
focusNode.requestFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -273,7 +283,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop) {
|
if (TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop) {
|
||||||
textEditingController.selection = TextSelection.fromPosition(TextPosition(offset: currentCursor ?? textEditingController.text.length));
|
textEditingController.selection =
|
||||||
|
TextSelection.fromPosition(TextPosition(offset: currentCursor ?? textEditingController.text.length));
|
||||||
focusNode.requestFocus();
|
focusNode.requestFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -286,9 +297,18 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
String text = textEditingController.text;
|
String text = textEditingController.text;
|
||||||
String convID = id ?? widget.conversationID;
|
String convID = id ?? widget.conversationID;
|
||||||
final isTopic = convID.contains("@TOPIC#");
|
final isTopic = convID.contains("@TOPIC#");
|
||||||
String conversationID = isTopic ? convID : ((convType ?? widget.conversationType) == ConvType.c2c ? "${TUIConversationViewModel.conversationC2CPrefix}$convID" : "${TUIConversationViewModel.conversationGroupPrefix}$convID");
|
String conversationID = isTopic
|
||||||
|
? convID
|
||||||
|
: ((convType ?? widget.conversationType) == ConvType.c2c
|
||||||
|
? "${TUIConversationViewModel.conversationC2CPrefix}$convID"
|
||||||
|
: "${TUIConversationViewModel.conversationGroupPrefix}$convID");
|
||||||
String draftText = _filterU200b(text);
|
String draftText = _filterU200b(text);
|
||||||
return await conversationModel.setConversationDraft(groupID: groupID ?? widget.groupID, isTopic: isTopic, isAllowWeb: widget.model.chatConfig.isUseDraftOnWeb, conversationID: conversationID, draftText: draftText);
|
return await conversationModel.setConversationDraft(
|
||||||
|
groupID: groupID ?? widget.groupID,
|
||||||
|
isTopic: isTopic,
|
||||||
|
isAllowWeb: widget.model.chatConfig.isUseDraftOnWeb,
|
||||||
|
conversationID: conversationID,
|
||||||
|
draftText: draftText);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 和onSubmitted一样,只是保持焦点的不同
|
// 和onSubmitted一样,只是保持焦点的不同
|
||||||
|
|
@ -346,9 +366,13 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.model.repliedMessage != null) {
|
if (widget.model.repliedMessage != null) {
|
||||||
MessageUtils.handleMessageError(widget.model.sendFaceMessage(index: groupID, data: data, convID: widget.conversationID, convType: convType), context);
|
MessageUtils.handleMessageError(
|
||||||
|
widget.model.sendFaceMessage(index: groupID, data: data, convID: widget.conversationID, convType: convType),
|
||||||
|
context);
|
||||||
} else {
|
} else {
|
||||||
MessageUtils.handleMessageError(widget.model.sendFaceMessage(index: groupID, data: data, convID: widget.conversationID, convType: convType), context);
|
MessageUtils.handleMessageError(
|
||||||
|
widget.model.sendFaceMessage(index: groupID, data: data, convID: widget.conversationID, convType: convType),
|
||||||
|
context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,11 +392,22 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
final convType = widget.conversationType;
|
final convType = widget.conversationType;
|
||||||
if (text.isNotEmpty && text != zeroWidthSpace) {
|
if (text.isNotEmpty && text != zeroWidthSpace) {
|
||||||
if (widget.model.repliedMessage != null) {
|
if (widget.model.repliedMessage != null) {
|
||||||
MessageUtils.handleMessageError(widget.model.sendReplyMessage(text: text, convID: widget.conversationID, convType: convType, atUserIDList: getUserIdFromMemberInfoMap()), context);
|
MessageUtils.handleMessageError(
|
||||||
|
widget.model.sendReplyMessage(
|
||||||
|
text: text,
|
||||||
|
convID: widget.conversationID,
|
||||||
|
convType: convType,
|
||||||
|
atUserIDList: getUserIdFromMemberInfoMap()),
|
||||||
|
context);
|
||||||
} else if (mentionedMembersMap.isNotEmpty) {
|
} else if (mentionedMembersMap.isNotEmpty) {
|
||||||
widget.model.sendTextAtMessage(text: text, convType: widget.conversationType, convID: widget.conversationID, atUserList: getUserIdFromMemberInfoMap());
|
widget.model.sendTextAtMessage(
|
||||||
|
text: text,
|
||||||
|
convType: widget.conversationType,
|
||||||
|
convID: widget.conversationID,
|
||||||
|
atUserList: getUserIdFromMemberInfoMap());
|
||||||
} else {
|
} else {
|
||||||
MessageUtils.handleMessageError(widget.model.sendTextMessage(text: text, convID: widget.conversationID, convType: convType), context);
|
MessageUtils.handleMessageError(
|
||||||
|
widget.model.sendTextMessage(text: text, convID: widget.conversationID, convType: convType), context);
|
||||||
}
|
}
|
||||||
textEditingController.clear();
|
textEditingController.clear();
|
||||||
currentCursor = null;
|
currentCursor = null;
|
||||||
|
|
@ -414,7 +449,10 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getShowName(V2TimGroupMemberFullInfo? item) {
|
String _getShowName(V2TimGroupMemberFullInfo? item) {
|
||||||
return TencentUtils.checkStringWithoutSpace(item?.nameCard) ?? TencentUtils.checkStringWithoutSpace(item?.nickName) ?? TencentUtils.checkStringWithoutSpace(item?.userID) ?? "";
|
return TencentUtils.checkStringWithoutSpace(item?.nameCard) ??
|
||||||
|
TencentUtils.checkStringWithoutSpace(item?.nickName) ??
|
||||||
|
TencentUtils.checkStringWithoutSpace(item?.userID) ??
|
||||||
|
"";
|
||||||
}
|
}
|
||||||
|
|
||||||
mentionMemberInMessage(String? userID, String? nickName) {
|
mentionMemberInMessage(String? userID, String? nickName) {
|
||||||
|
|
@ -558,10 +596,10 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
}
|
}
|
||||||
|
|
||||||
final int selfRole = widget.model.selfMemberInfo?.role ?? 0;
|
final int selfRole = widget.model.selfMemberInfo?.role ?? 0;
|
||||||
final bool canAtAll = widget.model.chatConfig.isMemberCanAtAll ? true : (selfRole == GroupMemberRoleType
|
final bool canAtAll = widget.model.chatConfig.isMemberCanAtAll
|
||||||
.V2TIM_GROUP_MEMBER_ROLE_ADMIN || selfRole
|
? true
|
||||||
==
|
: (selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN ||
|
||||||
GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER);
|
selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER);
|
||||||
|
|
||||||
if (isDesktopScreen) {
|
if (isDesktopScreen) {
|
||||||
(int, String, bool)? changedCharacterRecord = findChangedCharacter(originalText, text);
|
(int, String, bool)? changedCharacterRecord = findChangedCharacter(originalText, text);
|
||||||
|
|
@ -598,7 +636,10 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
"")
|
"")
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
keyword ??= "";
|
keyword ??= "";
|
||||||
return element != null && showName.contains(keyword!.toLowerCase()) && TencentUtils.checkString(showName) != null && element.userID != widget.model.selfMemberInfo?.userID;
|
return element != null &&
|
||||||
|
showName.contains(keyword!.toLowerCase()) &&
|
||||||
|
TencentUtils.checkString(showName) != null &&
|
||||||
|
element.userID != widget.model.selfMemberInfo?.userID;
|
||||||
})
|
})
|
||||||
.whereType<V2TimGroupMemberFullInfo>()
|
.whereType<V2TimGroupMemberFullInfo>()
|
||||||
.toList();
|
.toList();
|
||||||
|
|
@ -626,7 +667,10 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
|
|
||||||
keyword ??= "";
|
keyword ??= "";
|
||||||
if (canAtAll && showAtMemberList.isNotEmpty && keyword!.isEmpty) {
|
if (canAtAll && showAtMemberList.isNotEmpty && keyword!.isEmpty) {
|
||||||
showAtMemberList = [V2TimGroupMemberFullInfo(userID: "__kImSDK_MesssageAtALL__", nickName: TIM_t("所有人")), ...showAtMemberList];
|
showAtMemberList = [
|
||||||
|
V2TimGroupMemberFullInfo(userID: "__kImSDK_MesssageAtALL__", nickName: TIM_t("所有人")),
|
||||||
|
...showAtMemberList
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
model.activeAtIndex = 0;
|
model.activeAtIndex = 0;
|
||||||
|
|
@ -642,7 +686,12 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
List<V2TimGroupMemberFullInfo> selectedAtMemberList = await Navigator.push(
|
List<V2TimGroupMemberFullInfo> selectedAtMemberList = await Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => AtText(groupMemberList: model.groupMemberList, groupInfo: model.groupInfo, groupID: groupID, canAtAll: canAtAll, groupType: widget.groupType),
|
builder: (context) => AtText(
|
||||||
|
groupMemberList: model.groupMemberList,
|
||||||
|
groupInfo: model.groupInfo,
|
||||||
|
groupID: groupID,
|
||||||
|
canAtAll: canAtAll,
|
||||||
|
groupType: widget.groupType),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -687,14 +736,16 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
KeyEventResult handleDesktopKeyEvent(FocusNode node, RawKeyEvent event) {
|
KeyEventResult handleDesktopKeyEvent(FocusNode node, RawKeyEvent event) {
|
||||||
final activeIndex = widget.model.activeAtIndex;
|
final activeIndex = widget.model.activeAtIndex;
|
||||||
final showMemberList = widget.model.showAtMemberList;
|
final showMemberList = widget.model.showAtMemberList;
|
||||||
final isPressEnter = (event.physicalKey == PhysicalKeyboardKey.enter) || (event.physicalKey == PhysicalKeyboardKey.numpadEnter);
|
final isPressEnter =
|
||||||
|
(event.physicalKey == PhysicalKeyboardKey.enter) || (event.physicalKey == PhysicalKeyboardKey.numpadEnter);
|
||||||
if (event.runtimeType == RawKeyDownEvent) {
|
if (event.runtimeType == RawKeyDownEvent) {
|
||||||
if (event.physicalKey == PhysicalKeyboardKey.backspace) {
|
if (event.physicalKey == PhysicalKeyboardKey.backspace) {
|
||||||
if (textEditingController.text.isEmpty && lastText.isEmpty) {
|
if (textEditingController.text.isEmpty && lastText.isEmpty) {
|
||||||
widget.model.repliedMessage = null;
|
widget.model.repliedMessage = null;
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
}
|
}
|
||||||
} else if ((event.isShiftPressed || event.isAltPressed || event.isControlPressed || event.isMetaPressed) && isPressEnter) {
|
} else if ((event.isShiftPressed || event.isAltPressed || event.isControlPressed || event.isMetaPressed) &&
|
||||||
|
isPressEnter) {
|
||||||
final offset = textEditingController.selection.baseOffset;
|
final offset = textEditingController.selection.baseOffset;
|
||||||
textEditingController.text = '${lastText.substring(0, offset)}\n${lastText.substring(offset)}';
|
textEditingController.text = '${lastText.substring(0, offset)}\n${lastText.substring(offset)}';
|
||||||
textEditingController.selection = TextSelection.fromPosition(TextPosition(offset: offset + 1));
|
textEditingController.selection = TextSelection.fromPosition(TextPosition(offset: offset + 1));
|
||||||
|
|
@ -766,7 +817,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
} else if (actionType == ActionType.setTextField) {
|
} else if (actionType == ActionType.setTextField) {
|
||||||
final newText = widget.controller?.inputText ?? "";
|
final newText = widget.controller?.inputText ?? "";
|
||||||
textEditingController.text = newText;
|
textEditingController.text = newText;
|
||||||
textEditingController.selection = TextSelection.fromPosition(TextPosition(offset: textEditingController.text.length));
|
textEditingController.selection =
|
||||||
|
TextSelection.fromPosition(TextPosition(offset: textEditingController.text.length));
|
||||||
lastText = textEditingController.text;
|
lastText = textEditingController.text;
|
||||||
focusNode.requestFocus();
|
focusNode.requestFocus();
|
||||||
return;
|
return;
|
||||||
|
|
@ -784,7 +836,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
if (widget.conversationID != oldWidget.conversationID) {
|
if (widget.conversationID != oldWidget.conversationID) {
|
||||||
mentionedMembersMap.clear();
|
mentionedMembersMap.clear();
|
||||||
handleSetDraftText(id: oldWidget.conversationID, convType: oldWidget.conversationType, groupID: oldWidget.groupID);
|
handleSetDraftText(
|
||||||
|
id: oldWidget.conversationID, convType: oldWidget.conversationType, groupID: oldWidget.groupID);
|
||||||
if (oldWidget.initText != widget.initText) {
|
if (oldWidget.initText != widget.initText) {
|
||||||
textEditingController.text = widget.initText ?? "";
|
textEditingController.text = widget.initText ?? "";
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -810,7 +863,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
Future<bool> getMemberMuteStatus(String userID) async {
|
Future<bool> getMemberMuteStatus(String userID) async {
|
||||||
// Get the mute state of the members recursively
|
// Get the mute state of the members recursively
|
||||||
if (widget.model.groupMemberList?.any((item) => (item?.userID == userID)) ?? false) {
|
if (widget.model.groupMemberList?.any((item) => (item?.userID == userID)) ?? false) {
|
||||||
final int muteUntil = widget.model.groupMemberList?.firstWhere((item) => (item?.userID == userID))?.muteUntil ?? 0;
|
final int muteUntil =
|
||||||
|
widget.model.groupMemberList?.firstWhere((item) => (item?.userID == userID))?.muteUntil ?? 0;
|
||||||
return muteUntil * 1000 > DateTime.now().millisecondsSinceEpoch;
|
return muteUntil * 1000 > DateTime.now().millisecondsSinceEpoch;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -823,7 +877,8 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
}
|
}
|
||||||
|
|
||||||
final int selfRole = widget.model.selfMemberInfo?.role ?? 0;
|
final int selfRole = widget.model.selfMemberInfo?.role ?? 0;
|
||||||
final bool willNotBeenMuted = (selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN || selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER);
|
final bool willNotBeenMuted = (selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN ||
|
||||||
|
selfRole == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER);
|
||||||
|
|
||||||
if (widget.conversationType == ConvType.group && !willNotBeenMuted) {
|
if (widget.conversationType == ConvType.group && !willNotBeenMuted) {
|
||||||
if ((model.groupInfo?.isAllMuted ?? false) && muteStatus != MuteStatus.all) {
|
if ((model.groupInfo?.isAllMuted ?? false) && muteStatus != MuteStatus.all) {
|
||||||
|
|
@ -832,13 +887,17 @@ class _InputTextFieldState extends TIMUIKitState<TIMUIKitInputTextField> {
|
||||||
muteStatus = MuteStatus.all;
|
muteStatus = MuteStatus.all;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (selfModel.loginInfo?.userID != null && await getMemberMuteStatus(selfModel.loginInfo!.userID!) && muteStatus != MuteStatus.me) {
|
} else if (selfModel.loginInfo?.userID != null &&
|
||||||
|
await getMemberMuteStatus(selfModel.loginInfo!.userID!) &&
|
||||||
|
muteStatus != MuteStatus.me) {
|
||||||
Future.delayed(const Duration(seconds: 0), () {
|
Future.delayed(const Duration(seconds: 0), () {
|
||||||
setState(() {
|
setState(() {
|
||||||
muteStatus = MuteStatus.me;
|
muteStatus = MuteStatus.me;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if (!(model.groupInfo?.isAllMuted ?? false) && !(selfModel.loginInfo?.userID != null && await getMemberMuteStatus(selfModel.loginInfo!.userID!)) && muteStatus != MuteStatus.none) {
|
} else if (!(model.groupInfo?.isAllMuted ?? false) &&
|
||||||
|
!(selfModel.loginInfo?.userID != null && await getMemberMuteStatus(selfModel.loginInfo!.userID!)) &&
|
||||||
|
muteStatus != MuteStatus.none) {
|
||||||
Future.delayed(const Duration(seconds: 0), () {
|
Future.delayed(const Duration(seconds: 0), () {
|
||||||
setState(() {
|
setState(() {
|
||||||
muteStatus = MuteStatus.none;
|
muteStatus = MuteStatus.none;
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
|
||||||
enum ActionType {
|
enum ActionType { hideAllPanel, longPressToAt, setTextField, requestFocus, handleAtMember }
|
||||||
hideAllPanel,
|
|
||||||
longPressToAt,
|
|
||||||
setTextField,
|
|
||||||
requestFocus,
|
|
||||||
handleAtMember
|
|
||||||
}
|
|
||||||
|
|
||||||
class TIMUIKitInputTextFieldController extends ChangeNotifier {
|
class TIMUIKitInputTextFieldController extends ChangeNotifier {
|
||||||
TextEditingController? textEditingController = TextEditingController();
|
TextEditingController? textEditingController = TextEditingController();
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_svg/svg.dart';
|
import 'package:flutter_svg/svg.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
|
|
@ -260,7 +261,10 @@ class _TIMUIKitTextFieldLayoutNarrowState extends TIMUIKitState<TIMUIKitTextFiel
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showMore) {
|
if (showMore) {
|
||||||
return MorePanel(morePanelConfig: widget.morePanelConfig, conversationID: widget.conversationID, conversationType: widget.conversationType);
|
return MorePanel(
|
||||||
|
morePanelConfig: widget.morePanelConfig,
|
||||||
|
conversationID: widget.conversationID,
|
||||||
|
conversationType: widget.conversationType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return const SizedBox(height: 0);
|
return const SizedBox(height: 0);
|
||||||
|
|
@ -335,7 +339,8 @@ class _TIMUIKitTextFieldLayoutNarrowState extends TIMUIKitState<TIMUIKitTextFiel
|
||||||
}
|
}
|
||||||
|
|
||||||
String getAbstractMessage(V2TimMessage message) {
|
String getAbstractMessage(V2TimMessage message) {
|
||||||
final String? customAbstractMessage = widget.model.abstractMessageBuilder != null ? widget.model.abstractMessageBuilder!(message) : null;
|
final String? customAbstractMessage =
|
||||||
|
widget.model.abstractMessageBuilder != null ? widget.model.abstractMessageBuilder!(message) : null;
|
||||||
return customAbstractMessage ?? MessageUtils.getAbstractMessageAsync(message, widget.model.groupMemberList ?? []);
|
return customAbstractMessage ?? MessageUtils.getAbstractMessageAsync(message, widget.model.groupMemberList ?? []);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -454,17 +459,19 @@ class _TIMUIKitTextFieldLayoutNarrowState extends TIMUIKitState<TIMUIKitTextFiel
|
||||||
width: 28,
|
width: 28,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 10,
|
width: 10,
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: showSendSoundText
|
child: showSendSoundText
|
||||||
? SendSoundMessage(onDownBottom: widget.goDownBottom, conversationID: widget.conversationID, conversationType: widget.conversationType)
|
? SendSoundMessage(
|
||||||
: Stack(
|
onDownBottom: widget.goDownBottom,
|
||||||
children: [
|
conversationID: widget.conversationID,
|
||||||
Center(
|
conversationType: widget.conversationType)
|
||||||
child: KeyboardVisibility(
|
: Stack(children: [
|
||||||
child: ExtendedTextField(
|
Center(
|
||||||
|
child: KeyboardVisibility(
|
||||||
|
child: ExtendedTextField(
|
||||||
maxLines: 4,
|
maxLines: 4,
|
||||||
minLines: 1,
|
minLines: 1,
|
||||||
focusNode: widget.focusNode,
|
focusNode: widget.focusNode,
|
||||||
|
|
@ -478,7 +485,9 @@ class _TIMUIKitTextFieldLayoutNarrowState extends TIMUIKitState<TIMUIKitTextFiel
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
keyboardType: TextInputType.multiline,
|
keyboardType: TextInputType.multiline,
|
||||||
textInputAction: PlatformUtils().isAndroid ? TextInputAction.newline : TextInputAction.send,
|
textInputAction: PlatformUtils().isAndroid
|
||||||
|
? TextInputAction.newline
|
||||||
|
: TextInputAction.send,
|
||||||
onEditingComplete: () {
|
onEditingComplete: () {
|
||||||
widget.onSubmitted();
|
widget.onSubmitted();
|
||||||
if (showKeyboard) {
|
if (showKeyboard) {
|
||||||
|
|
@ -505,38 +514,47 @@ class _TIMUIKitTextFieldLayoutNarrowState extends TIMUIKitState<TIMUIKitTextFiel
|
||||||
specialTextSpanBuilder: PlatformUtils().isWeb
|
specialTextSpanBuilder: PlatformUtils().isWeb
|
||||||
? null
|
? null
|
||||||
: DefaultSpecialTextSpanBuilder(
|
: DefaultSpecialTextSpanBuilder(
|
||||||
isUseQQPackage: widget.model.chatConfig.stickerPanelConfig?.useQQStickerPackage ?? true,
|
isUseQQPackage:
|
||||||
isUseTencentCloudChatPackage: widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackage ?? true,
|
widget.model.chatConfig.stickerPanelConfig?.useQQStickerPackage ??
|
||||||
isUseTencentCloudChatPackageOldKeys: widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackageOldKeys ?? false,
|
true,
|
||||||
|
isUseTencentCloudChatPackage: widget.model.chatConfig
|
||||||
|
.stickerPanelConfig?.useTencentCloudChatStickerPackage ??
|
||||||
|
true,
|
||||||
|
isUseTencentCloudChatPackageOldKeys: widget
|
||||||
|
.model
|
||||||
|
.chatConfig
|
||||||
|
.stickerPanelConfig
|
||||||
|
?.useTencentCloudChatStickerPackageOldKeys ??
|
||||||
|
false,
|
||||||
customEmojiStickerList: widget.customEmojiStickerList,
|
customEmojiStickerList: widget.customEmojiStickerList,
|
||||||
showAtBackground: true,
|
showAtBackground: true,
|
||||||
checkHttpLink: false,
|
checkHttpLink: false,
|
||||||
)),
|
)),
|
||||||
onChanged: (bool visibility) {
|
onChanged: (bool visibility) {
|
||||||
if (showKeyboard != visibility) {
|
if (showKeyboard != visibility) {
|
||||||
setState(() {
|
setState(() {
|
||||||
showKeyboard = visibility;
|
showKeyboard = visibility;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
RawKeyboardListener(
|
|
||||||
autofocus: true,
|
|
||||||
focusNode: FocusNode(),
|
|
||||||
onKey: (key) {
|
|
||||||
if (key is RawKeyDownEvent && key.logicalKey == LogicalKeyboardKey.backspace) {
|
|
||||||
if (widget.onDeleteText != null) {
|
|
||||||
widget.onDeleteText!(widget.textEditingController.text);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, child: Container(),
|
}),
|
||||||
),
|
|
||||||
]
|
|
||||||
),
|
),
|
||||||
),
|
RawKeyboardListener(
|
||||||
const SizedBox(
|
autofocus: true,
|
||||||
width: 10,
|
focusNode: FocusNode(),
|
||||||
),
|
onKey: (key) {
|
||||||
|
if (key is RawKeyDownEvent && key.logicalKey == LogicalKeyboardKey.backspace) {
|
||||||
|
if (widget.onDeleteText != null) {
|
||||||
|
widget.onDeleteText!(widget.textEditingController.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Container(),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 10,
|
||||||
|
),
|
||||||
if (widget.showSendEmoji)
|
if (widget.showSendEmoji)
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
@ -544,7 +562,8 @@ class _TIMUIKitTextFieldLayoutNarrowState extends TIMUIKitState<TIMUIKitTextFiel
|
||||||
widget.goDownBottom();
|
widget.goDownBottom();
|
||||||
},
|
},
|
||||||
child: PlatformUtils().isWeb
|
child: PlatformUtils().isWeb
|
||||||
? Icon(showEmojiPanel ? Icons.keyboard_alt_outlined : Icons.mood_outlined, color: hexToColor("5c6168"), size: 32)
|
? Icon(showEmojiPanel ? Icons.keyboard_alt_outlined : Icons.mood_outlined,
|
||||||
|
color: hexToColor("5c6168"), size: 32)
|
||||||
: SvgPicture.asset(
|
: SvgPicture.asset(
|
||||||
showEmojiPanel ? 'images/keyboard.svg' : 'images/face.svg',
|
showEmojiPanel ? 'images/keyboard.svg' : 'images/face.svg',
|
||||||
package: 'tencent_cloud_chat_uikit',
|
package: 'tencent_cloud_chat_uikit',
|
||||||
|
|
@ -553,9 +572,9 @@ class _TIMUIKitTextFieldLayoutNarrowState extends TIMUIKitState<TIMUIKitTextFiel
|
||||||
width: 28,
|
width: 28,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 10,
|
width: 10,
|
||||||
),
|
),
|
||||||
if (widget.showMorePanel && showMoreButton)
|
if (widget.showMorePanel && showMoreButton)
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,10 @@ import 'package:pasteboard/pasteboard.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
|
|
@ -933,56 +935,55 @@ class _TIMUIKitTextFieldLayoutWideState extends TIMUIKitState<TIMUIKitTextFieldL
|
||||||
children: [
|
children: [
|
||||||
_buildRepliedMessage(widget.repliedMessage),
|
_buildRepliedMessage(widget.repliedMessage),
|
||||||
SizedBox(height: 1, child: Container(color: theme.weakDividerColor ?? Colors.black12)),
|
SizedBox(height: 1, child: Container(color: theme.weakDividerColor ?? Colors.black12)),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
children: generateControlBar(widget.model, theme),
|
children: generateControlBar(widget.model, theme),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
),
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 6),
|
||||||
constraints: const BoxConstraints(minHeight: 50),
|
constraints: const BoxConstraints(minHeight: 50),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ExtendedTextField(
|
child: ExtendedTextField(
|
||||||
scrollController: _scrollController,
|
scrollController: _scrollController,
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
maxLines: widget.chatConfig.desktopMessageInputFieldLines,
|
maxLines: widget.chatConfig.desktopMessageInputFieldLines,
|
||||||
minLines: widget.chatConfig.desktopMessageInputFieldLines,
|
minLines: widget.chatConfig.desktopMessageInputFieldLines,
|
||||||
focusNode: widget.focusNode,
|
focusNode: widget.focusNode,
|
||||||
onChanged: debounceFunc,
|
onChanged: debounceFunc,
|
||||||
keyboardType: TextInputType.multiline,
|
keyboardType: TextInputType.multiline,
|
||||||
onEditingComplete: () {
|
onEditingComplete: () {
|
||||||
// // widget.onSubmitted();
|
// // widget.onSubmitted();
|
||||||
},
|
},
|
||||||
textAlignVertical: TextAlignVertical.top,
|
textAlignVertical: TextAlignVertical.top,
|
||||||
style: const TextStyle(fontSize: 14),
|
style: const TextStyle(fontSize: 14),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hoverColor: Colors.transparent,
|
hoverColor: Colors.transparent,
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
hintStyle: const TextStyle(
|
hintStyle: const TextStyle(
|
||||||
color: Color(0xffAEA4A3),
|
color: Color(0xffAEA4A3),
|
||||||
),
|
|
||||||
fillColor: widget.backgroundColor ??
|
|
||||||
theme.desktopChatMessageInputBgColor ??
|
|
||||||
hexToColor("fafafa"),
|
|
||||||
filled: true,
|
|
||||||
isDense: true,
|
|
||||||
hintText: widget.hintText ?? '',
|
|
||||||
),
|
),
|
||||||
controller: widget.textEditingController,
|
fillColor:
|
||||||
specialTextSpanBuilder: PlatformUtils().isWeb
|
widget.backgroundColor ?? theme.desktopChatMessageInputBgColor ?? hexToColor("fafafa"),
|
||||||
? null
|
filled: true,
|
||||||
: DefaultSpecialTextSpanBuilder(
|
isDense: true,
|
||||||
isUseTencentCloudChatPackage:
|
hintText: widget.hintText ?? '',
|
||||||
widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackage ??
|
),
|
||||||
true,
|
controller: widget.textEditingController,
|
||||||
customEmojiStickerList: widget.customEmojiStickerList,
|
specialTextSpanBuilder: PlatformUtils().isWeb
|
||||||
showAtBackground: true,
|
? null
|
||||||
)),
|
: DefaultSpecialTextSpanBuilder(
|
||||||
),
|
isUseTencentCloudChatPackage:
|
||||||
|
widget.model.chatConfig.stickerPanelConfig?.useTencentCloudChatStickerPackage ??
|
||||||
|
true,
|
||||||
|
customEmojiStickerList: widget.customEmojiStickerList,
|
||||||
|
showAtBackground: true,
|
||||||
|
)),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,16 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:provider/single_child_widget.dart';
|
import 'package:provider/single_child_widget.dart';
|
||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_application.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_at_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
|
|
@ -74,7 +79,8 @@ class TIMUIKitChat extends StatefulWidget {
|
||||||
/// Avatar and name in message reaction secondary tap callback.
|
/// Avatar and name in message reaction secondary tap callback.
|
||||||
final void Function(String userID, TapDownDetails tapDetails)? onSecondaryTapAvatar;
|
final void Function(String userID, TapDownDetails tapDetails)? onSecondaryTapAvatar;
|
||||||
|
|
||||||
@Deprecated("Nickname will not shows in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
@Deprecated(
|
||||||
|
"Nickname will not shows in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
||||||
|
|
||||||
/// Should show the nick name.
|
/// Should show the nick name.
|
||||||
final bool showNickName;
|
final bool showNickName;
|
||||||
|
|
@ -86,10 +92,12 @@ class TIMUIKitChat extends StatefulWidget {
|
||||||
final bool showTotalUnReadCount;
|
final bool showTotalUnReadCount;
|
||||||
|
|
||||||
/// Deprecated("Please use [extraTipsActionItemBuilder] instead")
|
/// Deprecated("Please use [extraTipsActionItemBuilder] instead")
|
||||||
final Widget? Function(V2TimMessage message, Function() closeTooltip, [Key? key, BuildContext? context])? exteraTipsActionItemBuilder;
|
final Widget? Function(V2TimMessage message, Function() closeTooltip, [Key? key, BuildContext? context])?
|
||||||
|
exteraTipsActionItemBuilder;
|
||||||
|
|
||||||
/// The builder for extra tips action.
|
/// The builder for extra tips action.
|
||||||
final Widget? Function(V2TimMessage message, Function() closeTooltip, [Key? key, BuildContext? context])? extraTipsActionItemBuilder;
|
final Widget? Function(V2TimMessage message, Function() closeTooltip, [Key? key, BuildContext? context])?
|
||||||
|
extraTipsActionItemBuilder;
|
||||||
|
|
||||||
/// The text of draft shows in TextField.
|
/// The text of draft shows in TextField.
|
||||||
/// [Recommend]: You can specify this field with the draftText from V2TimConversation.
|
/// [Recommend]: You can specify this field with the draftText from V2TimConversation.
|
||||||
|
|
@ -180,7 +188,9 @@ class TIMUIKitChat extends StatefulWidget {
|
||||||
this.conversationShowName,
|
this.conversationShowName,
|
||||||
this.abstractMessageBuilder,
|
this.abstractMessageBuilder,
|
||||||
this.onTapAvatar,
|
this.onTapAvatar,
|
||||||
@Deprecated("Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead") this.showNickName = false,
|
@Deprecated(
|
||||||
|
"Nickname will not show in one-to-one chat, if you tend to control it in group chat, please use `isShowSelfNameInGroup` and `isShowOthersNameInGroup` from `config: TIMUIKitChatConfig` instead")
|
||||||
|
this.showNickName = false,
|
||||||
this.showTotalUnReadCount = false,
|
this.showTotalUnReadCount = false,
|
||||||
this.messageItemBuilder,
|
this.messageItemBuilder,
|
||||||
@Deprecated("Please use [extraTipsActionItemBuilder] instead") this.exteraTipsActionItemBuilder,
|
@Deprecated("Please use [extraTipsActionItemBuilder] instead") this.exteraTipsActionItemBuilder,
|
||||||
|
|
@ -301,7 +311,9 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
updateDraft() async {
|
updateDraft() async {
|
||||||
final isTopic = widget.conversation.conversationID.contains("@TOPIC#");
|
final isTopic = widget.conversation.conversationID.contains("@TOPIC#");
|
||||||
if (isTopic) {
|
if (isTopic) {
|
||||||
final topicInfoList = await TencentImSDKPlugin.v2TIMManager.getGroupManager().getTopicInfoList(groupID: widget.groupID!, topicIDList: [widget.conversation.conversationID]);
|
final topicInfoList = await TencentImSDKPlugin.v2TIMManager
|
||||||
|
.getGroupManager()
|
||||||
|
.getTopicInfoList(groupID: widget.groupID!, topicIDList: [widget.conversation.conversationID]);
|
||||||
final topicInfo = topicInfoList.data?.first.topicInfo;
|
final topicInfo = topicInfoList.data?.first.topicInfo;
|
||||||
final draftText = topicInfo?.draftText;
|
final draftText = topicInfo?.draftText;
|
||||||
if (TencentUtils.checkString(draftText) != null) {
|
if (TencentUtils.checkString(draftText) != null) {
|
||||||
|
|
@ -349,7 +361,9 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
}
|
}
|
||||||
|
|
||||||
String _getConvID() {
|
String _getConvID() {
|
||||||
return TencentUtils.checkString(widget.conversationID) ?? (widget.conversation.type == 1 ? widget.conversation.userID : widget.conversation.groupID) ?? "";
|
return TencentUtils.checkString(widget.conversationID) ??
|
||||||
|
(widget.conversation.type == 1 ? widget.conversation.userID : widget.conversation.groupID) ??
|
||||||
|
"";
|
||||||
}
|
}
|
||||||
|
|
||||||
ConvType _getConvType() {
|
ConvType _getConvType() {
|
||||||
|
|
@ -361,8 +375,7 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final w = await TUICore.instance.raiseExtension(TUIExtensionID.joinInGroup, {GROUP_ID: widget.conversationID!});
|
final w = await TUICore.instance.raiseExtension(TUIExtensionID.joinInGroup, {GROUP_ID: widget.conversationID!});
|
||||||
if(w != _joinInGroupCallWidget){
|
if (w != _joinInGroupCallWidget) {
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_joinInGroupCallWidget = w;
|
_joinInGroupCallWidget = w;
|
||||||
});
|
});
|
||||||
|
|
@ -424,9 +437,16 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CustomEmojiFaceData> customImageSmallPngEmojiPackages = [];
|
List<CustomEmojiFaceData> customImageSmallPngEmojiPackages = [];
|
||||||
if (widget.config?.stickerPanelConfig?.customStickerPackages != null && widget.config!.stickerPanelConfig!.customStickerPackages.isNotEmpty) {
|
if (widget.config?.stickerPanelConfig?.customStickerPackages != null &&
|
||||||
customImageSmallPngEmojiPackages = widget.config!.stickerPanelConfig!.customStickerPackages.where((element) => element.isEmoji == true).map((e) {
|
widget.config!.stickerPanelConfig!.customStickerPackages.isNotEmpty) {
|
||||||
return CustomEmojiFaceData(name: e.name, isEmoji: true, icon: e.menuItem.url ?? "", list: e.stickerList.map((e) => e.url ?? "").toList());
|
customImageSmallPngEmojiPackages = widget.config!.stickerPanelConfig!.customStickerPackages
|
||||||
|
.where((element) => element.isEmoji == true)
|
||||||
|
.map((e) {
|
||||||
|
return CustomEmojiFaceData(
|
||||||
|
name: e.name,
|
||||||
|
isEmoji: true,
|
||||||
|
icon: e.menuItem.url ?? "",
|
||||||
|
list: e.stickerList.map((e) => e.url ?? "").toList());
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
if (customImageSmallPngEmojiPackages.isEmpty) {
|
if (customImageSmallPngEmojiPackages.isEmpty) {
|
||||||
|
|
@ -452,7 +472,13 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
onDragDone: (detail) {
|
onDragDone: (detail) {
|
||||||
setState(() {
|
setState(() {
|
||||||
_dragging = false;
|
_dragging = false;
|
||||||
sendFileWithConfirmation(files: detail.files, conversation: widget.conversation, conversationType: _getConvType(), model: model, theme: theme, context: context);
|
sendFileWithConfirmation(
|
||||||
|
files: detail.files,
|
||||||
|
conversation: widget.conversation,
|
||||||
|
conversationType: _getConvType(),
|
||||||
|
model: model,
|
||||||
|
theme: theme,
|
||||||
|
context: context);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onDragEntered: (detail) {
|
onDragEntered: (detail) {
|
||||||
|
|
@ -471,7 +497,8 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
if (widget.customAppBar != null) widget.customAppBar!,
|
if (widget.customAppBar != null) widget.customAppBar!,
|
||||||
if (filteredApplicationList.isNotEmpty) _renderJoinGroupApplication(filteredApplicationList.length, theme),
|
if (filteredApplicationList.isNotEmpty)
|
||||||
|
_renderJoinGroupApplication(filteredApplicationList.length, theme),
|
||||||
if (widget.topFixWidget != null) widget.topFixWidget!,
|
if (widget.topFixWidget != null) widget.topFixWidget!,
|
||||||
if (_joinInGroupCallWidget != null) Center(child: _joinInGroupCallWidget!),
|
if (_joinInGroupCallWidget != null) Center(child: _joinInGroupCallWidget!),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
@ -484,7 +511,8 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
child: TIMUIKitHistoryMessageListContainer(
|
child: TIMUIKitHistoryMessageListContainer(
|
||||||
customMessageHoverBarOnDesktop: widget.customMessageHoverBarOnDesktop,
|
customMessageHoverBarOnDesktop: widget.customMessageHoverBarOnDesktop,
|
||||||
conversation: widget.conversation,
|
conversation: widget.conversation,
|
||||||
groupMemberInfo: model.groupMemberList?.firstWhere((element) => element?.userID == selfUserID, orElse: () => null),
|
groupMemberInfo: model.groupMemberList
|
||||||
|
?.firstWhere((element) => element?.userID == selfUserID, orElse: () => null),
|
||||||
textFieldController: textFieldController,
|
textFieldController: textFieldController,
|
||||||
customEmojiStickerList: widget.customEmojiStickerList,
|
customEmojiStickerList: widget.customEmojiStickerList,
|
||||||
key: listContainerKey,
|
key: listContainerKey,
|
||||||
|
|
@ -498,7 +526,8 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
},
|
},
|
||||||
mainHistoryListConfig: widget.mainHistoryListConfig,
|
mainHistoryListConfig: widget.mainHistoryListConfig,
|
||||||
initFindingMsg: widget.initFindingMsg,
|
initFindingMsg: widget.initFindingMsg,
|
||||||
extraTipsActionItemBuilder: widget.extraTipsActionItemBuilder ?? widget.exteraTipsActionItemBuilder,
|
extraTipsActionItemBuilder:
|
||||||
|
widget.extraTipsActionItemBuilder ?? widget.exteraTipsActionItemBuilder,
|
||||||
conversationType: _getConvType(),
|
conversationType: _getConvType(),
|
||||||
scrollController: autoController,
|
scrollController: autoController,
|
||||||
onSecondaryTapAvatar: widget.onSecondaryTapAvatar,
|
onSecondaryTapAvatar: widget.onSecondaryTapAvatar,
|
||||||
|
|
@ -535,7 +564,8 @@ class _TUIChatState extends TIMUIKitState<TIMUIKitChat> {
|
||||||
conversationType: _getConvType(),
|
conversationType: _getConvType(),
|
||||||
initText: TencentUtils.checkString(widget.draftText) ??
|
initText: TencentUtils.checkString(widget.draftText) ??
|
||||||
(PlatformUtils().isWeb
|
(PlatformUtils().isWeb
|
||||||
? TencentUtils.checkString(conversationViewModel.getWebDraft(conversationID: widget.conversation.conversationID))
|
? TencentUtils.checkString(conversationViewModel.getWebDraft(
|
||||||
|
conversationID: widget.conversation.conversationID))
|
||||||
: TencentUtils.checkString(widget.conversation.draftText)),
|
: TencentUtils.checkString(widget.conversation.draftText)),
|
||||||
hintText: widget.textFieldHintText,
|
hintText: widget.textFieldHintText,
|
||||||
showMorePanel: widget.config?.isAllowShowMorePanel ?? true,
|
showMorePanel: widget.config?.isAllowShowMorePanel ?? true,
|
||||||
|
|
@ -644,7 +674,8 @@ class TIMUIKitChatProviderScope extends StatelessWidget {
|
||||||
preGroupMemberList: groupMemberList,
|
preGroupMemberList: groupMemberList,
|
||||||
groupID: groupID,
|
groupID: groupID,
|
||||||
);
|
);
|
||||||
model?.showC2cMessageEditStatus = (conversationType == ConvType.c2c ? config?.showC2cMessageEditStatus ?? true : false);
|
model?.showC2cMessageEditStatus =
|
||||||
|
(conversationType == ConvType.c2c ? config?.showC2cMessageEditStatus ?? true : false);
|
||||||
loadData();
|
loadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/offlinePushInfo.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
|
|
||||||
|
|
@ -130,8 +131,7 @@ class TIMUIKitChatConfig {
|
||||||
|
|
||||||
/// Configuration for offline push.
|
/// Configuration for offline push.
|
||||||
/// If this field is specified, `notificationTitle`, `notificationOPPOChannelID`, `notificationIOSSound`, `notificationAndroidSound`, `notificationBody` and `notificationExt` will not work.
|
/// If this field is specified, `notificationTitle`, `notificationOPPOChannelID`, `notificationIOSSound`, `notificationAndroidSound`, `notificationBody` and `notificationExt` will not work.
|
||||||
final OfflinePushInfo? Function(
|
final OfflinePushInfo? Function(V2TimMessage message, String convID, ConvType convType)? offlinePushInfo;
|
||||||
V2TimMessage message, String convID, ConvType convType)? offlinePushInfo;
|
|
||||||
|
|
||||||
/// The title shows in push notification
|
/// The title shows in push notification
|
||||||
final String notificationTitle;
|
final String notificationTitle;
|
||||||
|
|
@ -151,13 +151,11 @@ class TIMUIKitChatConfig {
|
||||||
|
|
||||||
/// The body content shows in push notification.
|
/// The body content shows in push notification.
|
||||||
/// Returning `null` means using default body in this case.
|
/// Returning `null` means using default body in this case.
|
||||||
final String? Function(
|
final String? Function(V2TimMessage message, String convID, ConvType convType)? notificationBody;
|
||||||
V2TimMessage message, String convID, ConvType convType)? notificationBody;
|
|
||||||
|
|
||||||
/// External information (String) for notification message, recommend used for jumping to target conversation with JSON format,
|
/// External information (String) for notification message, recommend used for jumping to target conversation with JSON format,
|
||||||
/// Returning `null` means using default ext in this case.
|
/// Returning `null` means using default ext in this case.
|
||||||
final String? Function(
|
final String? Function(V2TimMessage message, String convID, ConvType convType)? notificationExt;
|
||||||
V2TimMessage message, String convID, ConvType convType)? notificationExt;
|
|
||||||
|
|
||||||
/// The type of URL preview level, none preview, only hyperlink in text, or shows a preview card for website.
|
/// The type of URL preview level, none preview, only hyperlink in text, or shows a preview card for website.
|
||||||
/// [Default]: UrlPreviewType.previewCardAndHyperlink.
|
/// [Default]: UrlPreviewType.previewCardAndHyperlink.
|
||||||
|
|
@ -277,10 +275,9 @@ class TIMUIKitChatConfig {
|
||||||
this.isUseMessageReaction = true,
|
this.isUseMessageReaction = true,
|
||||||
this.isShowAvatar = true,
|
this.isShowAvatar = true,
|
||||||
this.isShowSelfNameInGroup = false,
|
this.isShowSelfNameInGroup = false,
|
||||||
this.isAtWhenReplyDynamic,
|
this.isAtWhenReplyDynamic,
|
||||||
this.offlinePushInfo,
|
this.offlinePushInfo,
|
||||||
@Deprecated("Please use [isShowReadingStatus] instead")
|
@Deprecated("Please use [isShowReadingStatus] instead") this.isShowGroupMessageReadReceipt = true,
|
||||||
this.isShowGroupMessageReadReceipt = true,
|
|
||||||
this.upperRecallTime = 120,
|
this.upperRecallTime = 120,
|
||||||
this.isShowOthersNameInGroup = true,
|
this.isShowOthersNameInGroup = true,
|
||||||
this.urlPreviewType = UrlPreviewType.onlyHyperlink,
|
this.urlPreviewType = UrlPreviewType.onlyHyperlink,
|
||||||
|
|
@ -289,10 +286,8 @@ class TIMUIKitChatConfig {
|
||||||
this.notificationTitle = "",
|
this.notificationTitle = "",
|
||||||
this.notificationIOSSound = "",
|
this.notificationIOSSound = "",
|
||||||
this.isAllowSoundMessage = true,
|
this.isAllowSoundMessage = true,
|
||||||
@Deprecated("not support")
|
@Deprecated("not support") this.groupReadReceiptPermisionList,
|
||||||
this.groupReadReceiptPermisionList,
|
@Deprecated("not support") this.groupReadReceiptPermissionList,
|
||||||
@Deprecated("not support")
|
|
||||||
this.groupReadReceiptPermissionList,
|
|
||||||
this.isAllowEmojiPanel = true,
|
this.isAllowEmojiPanel = true,
|
||||||
this.isAllowShowMorePanel = true,
|
this.isAllowShowMorePanel = true,
|
||||||
this.isShowReadingStatus = true,
|
this.isShowReadingStatus = true,
|
||||||
|
|
@ -303,8 +298,7 @@ class TIMUIKitChatConfig {
|
||||||
this.isEnableTextSelection,
|
this.isEnableTextSelection,
|
||||||
this.additionalDesktopMessageHoverBarItem,
|
this.additionalDesktopMessageHoverBarItem,
|
||||||
this.isShowGroupReadingStatus = true,
|
this.isShowGroupReadingStatus = true,
|
||||||
@Deprecated("Please use [isShowReadingStatus] instead")
|
@Deprecated("Please use [isShowReadingStatus] instead") this.isReportGroupReadingStatus = true,
|
||||||
this.isReportGroupReadingStatus = true,
|
|
||||||
this.showC2cMessageEditStatus = true,
|
this.showC2cMessageEditStatus = true,
|
||||||
this.additionalDesktopControlBarItems,
|
this.additionalDesktopControlBarItems,
|
||||||
this.isAllowLongPressAvatarToAt = true,
|
this.isAllowLongPressAvatarToAt = true,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import 'dart:io';
|
||||||
import 'package:dotted_border/dotted_border.dart';
|
import 'package:dotted_border/dotted_border.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_chat_separate_view_model.dart';
|
||||||
|
|
@ -18,10 +19,7 @@ import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
||||||
import 'TIMUIKitMessageItem/tim_uikit_chat_file_icon.dart';
|
import 'TIMUIKitMessageItem/tim_uikit_chat_file_icon.dart';
|
||||||
|
|
||||||
String _getConvID(V2TimConversation conversation) {
|
String _getConvID(V2TimConversation conversation) {
|
||||||
return (conversation.type == 1
|
return (conversation.type == 1 ? conversation.userID : conversation.groupID) ?? "";
|
||||||
? conversation.userID
|
|
||||||
: conversation.groupID) ??
|
|
||||||
"";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendFileWithConfirmation(
|
sendFileWithConfirmation(
|
||||||
|
|
@ -65,8 +63,7 @@ sendFileWithConfirmation(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final option1 = conversation.showName ??
|
final option1 = conversation.showName ?? (conversationType == ConvType.group ? TIM_t("群聊") : TIM_t("对方"));
|
||||||
(conversationType == ConvType.group ? TIM_t("群聊") : TIM_t("对方"));
|
|
||||||
TUIKitWidePopup.showPopupWindow(
|
TUIKitWidePopup.showPopupWindow(
|
||||||
operationKey: TUIKitWideModalOperationKey.beforeSendScreenShot,
|
operationKey: TUIKitWideModalOperationKey.beforeSendScreenShot,
|
||||||
context: context,
|
context: context,
|
||||||
|
|
@ -85,9 +82,7 @@ sendFileWithConfirmation(
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
final file = files[index];
|
final file = files[index];
|
||||||
final fileName = PlatformUtils().isWeb
|
final fileName = PlatformUtils().isWeb ? file.name : path.basename(file.path);
|
||||||
? file.name
|
|
||||||
: path.basename(file.path);
|
|
||||||
return Material(
|
return Material(
|
||||||
color: theme.wideBackgroundColor,
|
color: theme.wideBackgroundColor,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
|
|
@ -95,22 +90,18 @@ sendFileWithConfirmation(
|
||||||
launchUrl(Uri.file(file.path));
|
launchUrl(Uri.file(file.path));
|
||||||
},
|
},
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(vertical: 6, horizontal: 20),
|
||||||
vertical: 6, horizontal: 20),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
TIMUIKitFileIcon(
|
TIMUIKitFileIcon(
|
||||||
size: 44,
|
size: 44,
|
||||||
fileFormat: fileName.split(
|
fileFormat: fileName.split(".")[fileName.split(".").length - 1],
|
||||||
".")[fileName.split(".").length - 1],
|
|
||||||
),
|
),
|
||||||
const SizedBox(width: 16),
|
const SizedBox(width: 16),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
fileName,
|
fileName,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 16, color: theme.darkTextColor),
|
||||||
fontSize: 16,
|
|
||||||
color: theme.darkTextColor),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
@ -146,8 +137,7 @@ sendFileWithConfirmation(
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
sendFiles(files, model, conversation,
|
sendFiles(files, model, conversation, conversationType, context);
|
||||||
conversationType, context);
|
|
||||||
closeFunc();
|
closeFunc();
|
||||||
},
|
},
|
||||||
child: Text(TIM_t("发送")))
|
child: Text(TIM_t("发送")))
|
||||||
|
|
@ -159,21 +149,14 @@ sendFileWithConfirmation(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> sendFiles(
|
Future<void> sendFiles(List<XFile> files, TUIChatSeparateViewModel model, V2TimConversation conversation,
|
||||||
List<XFile> files,
|
ConvType conversationType, BuildContext context) async {
|
||||||
TUIChatSeparateViewModel model,
|
|
||||||
V2TimConversation conversation,
|
|
||||||
ConvType conversationType,
|
|
||||||
BuildContext context) async {
|
|
||||||
for (final file in files) {
|
for (final file in files) {
|
||||||
final fileName = file.name;
|
final fileName = file.name;
|
||||||
final filePath = file.path;
|
final filePath = file.path;
|
||||||
await MessageUtils.handleMessageError(
|
await MessageUtils.handleMessageError(
|
||||||
model.sendFileMessage(
|
model.sendFileMessage(
|
||||||
fileName: fileName,
|
fileName: fileName, filePath: filePath, convID: _getConvID(conversation), convType: conversationType),
|
||||||
filePath: filePath,
|
|
||||||
convID: _getConvID(conversation),
|
|
||||||
convType: conversationType),
|
|
||||||
context);
|
context);
|
||||||
await Future.delayed(const Duration(microseconds: 300));
|
await Future.delayed(const Duration(microseconds: 300));
|
||||||
}
|
}
|
||||||
|
|
@ -188,8 +171,7 @@ class TIMUIKitSendFile extends TIMUIKitStatelessWidget {
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final theme = value.theme;
|
final theme = value.theme;
|
||||||
final conversationType = conversation.type;
|
final conversationType = conversation.type;
|
||||||
final option1 = conversation.showName ??
|
final option1 = conversation.showName ?? (conversationType == 2 ? TIM_t("群聊") : TIM_t("会话"));
|
||||||
(conversationType == 2 ? TIM_t("群聊") : TIM_t("会话"));
|
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
|
@ -222,12 +204,8 @@ class TIMUIKitSendFile extends TIMUIKitStatelessWidget {
|
||||||
height: 40,
|
height: 40,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
TIM_t_para("发送给{{option1}}", "发送给$option1")(
|
TIM_t_para("发送给{{option1}}", "发送给$option1")(option1: option1),
|
||||||
option1: option1),
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: theme.darkTextColor),
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: theme.darkTextColor),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/friend_list_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/friend_list_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_friendship_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_friendship_view_model.dart';
|
||||||
|
|
@ -48,7 +49,6 @@ class _TIMUIKitContactState extends TIMUIKitState<TIMUIKitContact> {
|
||||||
final TUIFriendShipViewModel model = serviceLocator<TUIFriendShipViewModel>();
|
final TUIFriendShipViewModel model = serviceLocator<TUIFriendShipViewModel>();
|
||||||
String currentItem = "";
|
String currentItem = "";
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
|
|
@ -72,13 +72,13 @@ class _TIMUIKitContactState extends TIMUIKitState<TIMUIKitContact> {
|
||||||
emptyBuilder: widget.emptyBuilder,
|
emptyBuilder: widget.emptyBuilder,
|
||||||
isShowOnlineStatus: widget.isShowOnlineStatus,
|
isShowOnlineStatus: widget.isShowOnlineStatus,
|
||||||
contactList: memberList,
|
contactList: memberList,
|
||||||
onTapItem: (item){
|
onTapItem: (item) {
|
||||||
if(isDesktopScreen){
|
if (isDesktopScreen) {
|
||||||
setState(() {
|
setState(() {
|
||||||
currentItem = item.userID;
|
currentItem = item.userID;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(widget.onTapItem != null){
|
if (widget.onTapItem != null) {
|
||||||
widget.onTapItem!(item);
|
widget.onTapItem!(item);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,10 @@ import 'package:flutter_slidable_plus_plus/flutter_slidable_plus_plus.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:scroll_to_index/scroll_to_index.dart';
|
import 'package:scroll_to_index/scroll_to_index.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_status.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
|
|
@ -32,7 +34,8 @@ typedef ConversationItemBuilder = Widget Function(V2TimConversation conversation
|
||||||
|
|
||||||
typedef ConversationItemSlideBuilder = List<ConversationItemSlidePanel> Function(V2TimConversation conversationItem);
|
typedef ConversationItemSlideBuilder = List<ConversationItemSlidePanel> Function(V2TimConversation conversationItem);
|
||||||
|
|
||||||
typedef ConversationItemSecondaryMenuBuilder = Widget Function(V2TimConversation conversationItem, VoidCallback onClose);
|
typedef ConversationItemSecondaryMenuBuilder = Widget Function(
|
||||||
|
V2TimConversation conversationItem, VoidCallback onClose);
|
||||||
|
|
||||||
class TIMUIKitConversation extends StatefulWidget {
|
class TIMUIKitConversation extends StatefulWidget {
|
||||||
/// the callback after clicking conversation item
|
/// the callback after clicking conversation item
|
||||||
|
|
@ -178,7 +181,8 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
_pinConversation(V2TimConversation conversation) {
|
_pinConversation(V2TimConversation conversation) {
|
||||||
_timuiKitConversationController.pinConversation(conversationID: conversation.conversationID, isPinned: !conversation.isPinned!);
|
_timuiKitConversationController.pinConversation(
|
||||||
|
conversationID: conversation.conversationID, isPinned: !conversation.isPinned!);
|
||||||
}
|
}
|
||||||
|
|
||||||
_deleteConversation(V2TimConversation conversation) {
|
_deleteConversation(V2TimConversation conversation) {
|
||||||
|
|
@ -186,7 +190,8 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<V2TimConversation?> getFilteredConversation() {
|
List<V2TimConversation?> getFilteredConversation() {
|
||||||
List<V2TimConversation?> filteredConversationList = model.conversationList.where((element) => (element?.groupID != null || element?.userID != null)).toList();
|
List<V2TimConversation?> filteredConversationList =
|
||||||
|
model.conversationList.where((element) => (element?.groupID != null || element?.userID != null)).toList();
|
||||||
if (widget.conversationCollector != null) {
|
if (widget.conversationCollector != null) {
|
||||||
filteredConversationList = filteredConversationList.where(widget.conversationCollector!).toList();
|
filteredConversationList = filteredConversationList.where(widget.conversationCollector!).toList();
|
||||||
}
|
}
|
||||||
|
|
@ -300,7 +305,8 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider.value(value: model),
|
ChangeNotifierProvider.value(value: model),
|
||||||
ChangeNotifierProvider.value(value: friendShipViewModel),
|
ChangeNotifierProvider.value(value: friendShipViewModel),
|
||||||
ChangeNotifierProvider.value(value: groupListenerModel)],
|
ChangeNotifierProvider.value(value: groupListenerModel)
|
||||||
|
],
|
||||||
builder: (BuildContext context, Widget? w) {
|
builder: (BuildContext context, Widget? w) {
|
||||||
final _model = Provider.of<TUIConversationViewModel>(context);
|
final _model = Provider.of<TUIConversationViewModel>(context);
|
||||||
bool haveMoreData = _model.haveMoreData;
|
bool haveMoreData = _model.haveMoreData;
|
||||||
|
|
@ -346,7 +352,9 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
|
|
||||||
final conversationItem = filteredConversationList[index];
|
final conversationItem = filteredConversationList[index];
|
||||||
|
|
||||||
final V2TimUserStatus? onlineStatus = _friendShipViewModel.userStatusList.firstWhere((item) => item.userID == conversationItem?.userID, orElse: () => V2TimUserStatus(statusType: 0));
|
final V2TimUserStatus? onlineStatus = _friendShipViewModel.userStatusList.firstWhere(
|
||||||
|
(item) => item.userID == conversationItem?.userID,
|
||||||
|
orElse: () => V2TimUserStatus(statusType: 0));
|
||||||
|
|
||||||
if (widget.itemBuilder != null) {
|
if (widget.itemBuilder != null) {
|
||||||
return widget.itemBuilder!(conversationItem!, onlineStatus);
|
return widget.itemBuilder!(conversationItem!, onlineStatus);
|
||||||
|
|
@ -371,14 +379,18 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
lastMessageBuilder: widget.lastMessageBuilder,
|
lastMessageBuilder: widget.lastMessageBuilder,
|
||||||
faceUrl: conversationItem.faceUrl ?? "",
|
faceUrl: conversationItem.faceUrl ?? "",
|
||||||
nickName: conversationItem.showName ?? "",
|
nickName: conversationItem.showName ?? "",
|
||||||
isDisturb: (conversationItem.groupType == "Meeting" ? false : conversationItem
|
isDisturb:
|
||||||
.recvOpt != 0),
|
(conversationItem.groupType == "Meeting" ? false : conversationItem.recvOpt != 0),
|
||||||
lastMsg: conversationItem.lastMessage,
|
lastMsg: conversationItem.lastMessage,
|
||||||
isPined: isPined,
|
isPined: isPined,
|
||||||
groupAtInfoList: conversationItem.groupAtInfoList ?? [],
|
groupAtInfoList: conversationItem.groupAtInfoList ?? [],
|
||||||
unreadCount: conversationItem.unreadCount ?? 0,
|
unreadCount: conversationItem.unreadCount ?? 0,
|
||||||
draftText: conversationItem.draftText,
|
draftText: conversationItem.draftText,
|
||||||
onlineStatus: (widget.isShowOnlineStatus && conversationItem.userID != null && conversationItem.userID!.isNotEmpty) ? onlineStatus : null,
|
onlineStatus: (widget.isShowOnlineStatus &&
|
||||||
|
conversationItem.userID != null &&
|
||||||
|
conversationItem.userID!.isNotEmpty)
|
||||||
|
? onlineStatus
|
||||||
|
: null,
|
||||||
draftTimestamp: conversationItem.draftTimestamp,
|
draftTimestamp: conversationItem.draftTimestamp,
|
||||||
convType: conversationItem.type),
|
convType: conversationItem.type),
|
||||||
onTap: () => onTapConvItem(conversationItem),
|
onTap: () => onTapConvItem(conversationItem),
|
||||||
|
|
@ -399,7 +411,9 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
isDarkBackground: false,
|
isDarkBackground: false,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||||
context: context,
|
context: context,
|
||||||
offset: Offset(min(details.globalPosition.dx, MediaQuery.of(context).size.width - 80), min(details.globalPosition.dy, MediaQuery.of(context).size.height - 130)),
|
offset: Offset(
|
||||||
|
min(details.globalPosition.dx, MediaQuery.of(context).size.width - 80),
|
||||||
|
min(details.globalPosition.dy, MediaQuery.of(context).size.height - 130)),
|
||||||
child: (onClose) => _getSecondaryMenu(conversationItem, onClose));
|
child: (onClose) => _getSecondaryMenu(conversationItem, onClose));
|
||||||
},
|
},
|
||||||
child: conversationLineItem(),
|
child: conversationLineItem(),
|
||||||
|
|
@ -409,7 +423,13 @@ class _TIMUIKitConversationState extends TIMUIKitState<TIMUIKitConversation> {
|
||||||
key: ValueKey(conversationItem.conversationID),
|
key: ValueKey(conversationItem.conversationID),
|
||||||
controller: _autoScrollController,
|
controller: _autoScrollController,
|
||||||
index: index,
|
index: index,
|
||||||
child: Slidable(groupTag: 'conversation-list', child: conversationLineItem(), endActionPane: ActionPane(extentRatio: slideChildren.length > 2 ? 0.77 : 0.5, motion: const DrawerMotion(), children: slideChildren)),
|
child: Slidable(
|
||||||
|
groupTag: 'conversation-list',
|
||||||
|
child: conversationLineItem(),
|
||||||
|
endActionPane: ActionPane(
|
||||||
|
extentRatio: slideChildren.length > 2 ? 0.77 : 0.5,
|
||||||
|
motion: const DrawerMotion(),
|
||||||
|
children: slideChildren)),
|
||||||
));
|
));
|
||||||
})
|
})
|
||||||
: (widget.emptyBuilder != null ? widget.emptyBuilder!() : Container());
|
: (widget.emptyBuilder != null ? widget.emptyBuilder!() : Container());
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
// ignore_for_file: empty_catches
|
// ignore_for_file: empty_catches
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_at_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_status.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_status.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/time_ago.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/time_ago.dart';
|
||||||
|
|
@ -14,8 +17,7 @@ import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
||||||
|
|
||||||
typedef LastMessageBuilder = Widget? Function(
|
typedef LastMessageBuilder = Widget? Function(V2TimMessage? lastMsg, List<V2TimGroupAtInfo?> groupAtInfoList);
|
||||||
V2TimMessage? lastMsg, List<V2TimGroupAtInfo?> groupAtInfoList);
|
|
||||||
|
|
||||||
class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
||||||
final String faceUrl;
|
final String faceUrl;
|
||||||
|
|
@ -51,10 +53,9 @@ class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
||||||
|
|
||||||
Widget _getShowMsgWidget(BuildContext context) {
|
Widget _getShowMsgWidget(BuildContext context) {
|
||||||
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
if (lastMsg != null && lastMessageBuilder != null &&
|
if (lastMsg != null && lastMessageBuilder != null && lastMessageBuilder!(lastMsg, groupAtInfoList) != null) {
|
||||||
lastMessageBuilder!(lastMsg, groupAtInfoList) != null) {
|
return lastMessageBuilder!(lastMsg, groupAtInfoList)!;
|
||||||
return lastMessageBuilder!(lastMsg, groupAtInfoList)!;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (lastMsg != null || (draftText != null && draftText != "")) {
|
if (lastMsg != null || (draftText != null && draftText != "")) {
|
||||||
return TIMUIKitLastMsg(
|
return TIMUIKitLastMsg(
|
||||||
|
|
@ -106,8 +107,7 @@ class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(
|
||||||
bottom: BorderSide(
|
bottom: BorderSide(
|
||||||
color: theme.conversationItemBorderColor ??
|
color: theme.conversationItemBorderColor ?? CommonColor.weakDividerColor,
|
||||||
CommonColor.weakDividerColor,
|
|
||||||
width: 1,
|
width: 1,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -124,11 +124,7 @@ class TIMUIKitConversationItem extends TIMUIKitStatelessWidget {
|
||||||
fit: StackFit.expand,
|
fit: StackFit.expand,
|
||||||
clipBehavior: Clip.none,
|
clipBehavior: Clip.none,
|
||||||
children: [
|
children: [
|
||||||
Avatar(
|
Avatar(onlineStatus: onlineStatus, faceUrl: faceUrl, showName: nickName, type: convType),
|
||||||
onlineStatus: onlineStatus,
|
|
||||||
faceUrl: faceUrl,
|
|
||||||
showName: nickName,
|
|
||||||
type: convType),
|
|
||||||
if (unreadCount != 0)
|
if (unreadCount != 0)
|
||||||
Positioned(
|
Positioned(
|
||||||
top: isDisturb ? -2.5 : -4.5,
|
top: isDisturb ? -2.5 : -4.5,
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,10 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_elem_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/message_status.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_at_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_at_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
|
|
@ -205,13 +207,13 @@ class _TIMUIKitLastMsgState extends TIMUIKitState<TIMUIKitLastMsg> {
|
||||||
if (widget.groupAtInfoList.isNotEmpty)
|
if (widget.groupAtInfoList.isNotEmpty)
|
||||||
Text(_getAtMessage(), style: TextStyle(color: theme.cautionColor, fontSize: widget.fontSize)),
|
Text(_getAtMessage(), style: TextStyle(color: theme.cautionColor, fontSize: widget.fontSize)),
|
||||||
if (widget.draftText != null && widget.draftText != "")
|
if (widget.draftText != null && widget.draftText != "")
|
||||||
Text(_getDraftShowText(), style: TextStyle(color: theme.conversationItemDraftTextColor, fontSize: widget.fontSize)),
|
Text(_getDraftShowText(),
|
||||||
|
style: TextStyle(color: theme.conversationItemDraftTextColor, fontSize: widget.fontSize)),
|
||||||
if (disturbUnreadCountInfo != "")
|
if (disturbUnreadCountInfo != "")
|
||||||
Text(disturbUnreadCountInfo, style: TextStyle(color: theme.weakTextColor, fontSize: widget.fontSize)),
|
Text(disturbUnreadCountInfo, style: TextStyle(color: theme.weakTextColor, fontSize: widget.fontSize)),
|
||||||
if (widget.draftText != null && widget.draftText != "")
|
if (widget.draftText != null && widget.draftText != "")
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ExtendedText(
|
child: ExtendedText(groupTipsAbstractText,
|
||||||
groupTipsAbstractText,
|
|
||||||
softWrap: true,
|
softWrap: true,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
|
|
@ -220,23 +222,20 @@ class _TIMUIKitLastMsgState extends TIMUIKitState<TIMUIKitLastMsg> {
|
||||||
isUseQQPackage: true,
|
isUseQQPackage: true,
|
||||||
isUseTencentCloudChatPackage: true,
|
isUseTencentCloudChatPackage: true,
|
||||||
showAtBackground: true,
|
showAtBackground: true,
|
||||||
)
|
)),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
if (widget.draftText == null || widget.draftText == "" && TencentUtils.checkString(groupTipsAbstractText) != null)
|
if (widget.draftText == null || widget.draftText == "" && TencentUtils.checkString(groupTipsAbstractText) != null)
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ExtendedText(
|
child: ExtendedText(groupTipsAbstractText,
|
||||||
groupTipsAbstractText,
|
softWrap: true,
|
||||||
softWrap: true,
|
maxLines: 1,
|
||||||
maxLines: 1,
|
overflow: TextOverflow.ellipsis,
|
||||||
overflow: TextOverflow.ellipsis,
|
style: TextStyle(height: 1, color: theme.weakTextColor, fontSize: widget.fontSize),
|
||||||
style: TextStyle(height: 1, color: theme.weakTextColor, fontSize: widget.fontSize),
|
specialTextSpanBuilder: DefaultSpecialTextSpanBuilder(
|
||||||
specialTextSpanBuilder: DefaultSpecialTextSpanBuilder(
|
isUseQQPackage: true,
|
||||||
isUseQQPackage: true,
|
isUseTencentCloudChatPackage: true,
|
||||||
isUseTencentCloudChatPackage: true,
|
showAtBackground: true,
|
||||||
showAtBackground: true,
|
)),
|
||||||
)
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ import 'package:azlistview_all_platforms/azlistview_all_platforms.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lpinyin/lpinyin.dart';
|
import 'package:lpinyin/lpinyin.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
|
|
@ -16,24 +18,17 @@ import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
||||||
|
|
||||||
typedef GroupItemBuilder = Widget Function(
|
typedef GroupItemBuilder = Widget Function(BuildContext context, V2TimGroupInfo groupInfo);
|
||||||
BuildContext context, V2TimGroupInfo groupInfo);
|
|
||||||
|
|
||||||
class TIMUIKitGroup extends StatefulWidget {
|
class TIMUIKitGroup extends StatefulWidget {
|
||||||
final void Function(V2TimGroupInfo groupInfo, V2TimConversation conversation)?
|
final void Function(V2TimGroupInfo groupInfo, V2TimConversation conversation)? onTapItem;
|
||||||
onTapItem;
|
|
||||||
final Widget Function(BuildContext context)? emptyBuilder;
|
final Widget Function(BuildContext context)? emptyBuilder;
|
||||||
final GroupItemBuilder? itemBuilder;
|
final GroupItemBuilder? itemBuilder;
|
||||||
|
|
||||||
/// the filter for group conversation
|
/// the filter for group conversation
|
||||||
final bool Function(V2TimGroupInfo? groupInfo)? groupCollector;
|
final bool Function(V2TimGroupInfo? groupInfo)? groupCollector;
|
||||||
|
|
||||||
const TIMUIKitGroup(
|
const TIMUIKitGroup({Key? key, this.onTapItem, this.emptyBuilder, this.itemBuilder, this.groupCollector})
|
||||||
{Key? key,
|
|
||||||
this.onTapItem,
|
|
||||||
this.emptyBuilder,
|
|
||||||
this.itemBuilder,
|
|
||||||
this.groupCollector})
|
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -41,15 +36,11 @@ class TIMUIKitGroup extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TIMUIKitGroupState extends TIMUIKitState<TIMUIKitGroup> {
|
class _TIMUIKitGroupState extends TIMUIKitState<TIMUIKitGroup> {
|
||||||
final TUIFriendShipViewModel _friendshipViewModel =
|
final TUIFriendShipViewModel _friendshipViewModel = serviceLocator<TUIFriendShipViewModel>();
|
||||||
serviceLocator<TUIFriendShipViewModel>();
|
final TUIGroupListenerModel _groupListenerModel = serviceLocator<TUIGroupListenerModel>();
|
||||||
final TUIGroupListenerModel _groupListenerModel =
|
|
||||||
serviceLocator<TUIGroupListenerModel>();
|
|
||||||
|
|
||||||
List<ISuspensionBeanImpl<V2TimGroupInfo>> _getShowList(
|
List<ISuspensionBeanImpl<V2TimGroupInfo>> _getShowList(List<V2TimGroupInfo> groupList) {
|
||||||
List<V2TimGroupInfo> groupList) {
|
final List<ISuspensionBeanImpl<V2TimGroupInfo>> showList = List.empty(growable: true);
|
||||||
final List<ISuspensionBeanImpl<V2TimGroupInfo>> showList =
|
|
||||||
List.empty(growable: true);
|
|
||||||
for (var i = 0; i < groupList.length; i++) {
|
for (var i = 0; i < groupList.length; i++) {
|
||||||
final item = groupList[i];
|
final item = groupList[i];
|
||||||
|
|
||||||
|
|
@ -72,14 +63,10 @@ class _TIMUIKitGroupState extends TIMUIKitState<TIMUIKitGroup> {
|
||||||
final theme = Provider.of<TUIThemeViewModel>(context).theme;
|
final theme = Provider.of<TUIThemeViewModel>(context).theme;
|
||||||
final showName = groupInfo.groupName ?? groupInfo.groupID;
|
final showName = groupInfo.groupName ?? groupInfo.groupID;
|
||||||
final faceUrl = groupInfo.faceUrl ?? "";
|
final faceUrl = groupInfo.faceUrl ?? "";
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
bottom: BorderSide(
|
|
||||||
color:
|
|
||||||
theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
|
||||||
child: Material(
|
child: Material(
|
||||||
color: isDesktopScreen ? theme.wideBackgroundColor : null,
|
color: isDesktopScreen ? theme.wideBackgroundColor : null,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
|
|
@ -93,10 +80,9 @@ class _TIMUIKitGroupState extends TIMUIKitState<TIMUIKitGroup> {
|
||||||
groupType: groupInfo.groupType,
|
groupType: groupInfo.groupType,
|
||||||
faceUrl: groupInfo.faceUrl,
|
faceUrl: groupInfo.faceUrl,
|
||||||
);
|
);
|
||||||
final res = await TencentImSDKPlugin
|
final res = await TencentImSDKPlugin.v2TIMManager
|
||||||
.v2TIMManager.getConversationManager()
|
.getConversationManager()
|
||||||
.getConversation(
|
.getConversation(conversationID: "group_${groupInfo.groupID}");
|
||||||
conversationID: "group_${groupInfo.groupID}");
|
|
||||||
if (res.code == 0 && res.data != null) {
|
if (res.code == 0 && res.data != null) {
|
||||||
conversation = res.data!;
|
conversation = res.data!;
|
||||||
}
|
}
|
||||||
|
|
@ -126,8 +112,7 @@ class _TIMUIKitGroupState extends TIMUIKitState<TIMUIKitGroup> {
|
||||||
padding: const EdgeInsets.only(top: 10, bottom: 20),
|
padding: const EdgeInsets.only(top: 10, bottom: 20),
|
||||||
child: Text(
|
child: Text(
|
||||||
showName,
|
showName,
|
||||||
style: TextStyle(
|
style: TextStyle(color: Colors.black, fontSize: isDesktopScreen ? 14 : 18),
|
||||||
color: Colors.black, fontSize: isDesktopScreen ? 14 : 18),
|
|
||||||
),
|
),
|
||||||
))
|
))
|
||||||
],
|
],
|
||||||
|
|
@ -154,12 +139,10 @@ class _TIMUIKitGroupState extends TIMUIKitState<TIMUIKitGroup> {
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider.value(value: _friendshipViewModel),
|
ChangeNotifierProvider.value(value: _friendshipViewModel),
|
||||||
ChangeNotifierProvider.value(value: _groupListenerModel),
|
ChangeNotifierProvider.value(value: _groupListenerModel),
|
||||||
ChangeNotifierProvider.value(
|
ChangeNotifierProvider.value(value: serviceLocator<TUIThemeViewModel>()),
|
||||||
value: serviceLocator<TUIThemeViewModel>()),
|
|
||||||
],
|
],
|
||||||
builder: (BuildContext context, Widget? w) {
|
builder: (BuildContext context, Widget? w) {
|
||||||
final NeedUpdate? needUpdate =
|
final NeedUpdate? needUpdate = Provider.of<TUIGroupListenerModel>(context).needUpdate;
|
||||||
Provider.of<TUIGroupListenerModel>(context).needUpdate;
|
|
||||||
if (needUpdate != null) {
|
if (needUpdate != null) {
|
||||||
_groupListenerModel.needUpdate = null;
|
_groupListenerModel.needUpdate = null;
|
||||||
switch (needUpdate.updateType) {
|
switch (needUpdate.updateType) {
|
||||||
|
|
@ -173,8 +156,7 @@ class _TIMUIKitGroupState extends TIMUIKitState<TIMUIKitGroup> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<V2TimGroupInfo> groupList =
|
List<V2TimGroupInfo> groupList = Provider.of<TUIFriendShipViewModel>(context).groupList;
|
||||||
Provider.of<TUIFriendShipViewModel>(context).groupList;
|
|
||||||
if (widget.groupCollector != null) {
|
if (widget.groupCollector != null) {
|
||||||
groupList = groupList.where(widget.groupCollector!).toList();
|
groupList = groupList.where(widget.groupCollector!).toList();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_application_type_enum.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_application_type_enum.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_application.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
|
||||||
|
|
@ -14,7 +15,8 @@ import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
||||||
|
|
||||||
typedef GroupApplicationItemBuilder = Widget Function(BuildContext context, V2TimGroupApplication applicationInfo, int index);
|
typedef GroupApplicationItemBuilder = Widget Function(
|
||||||
|
BuildContext context, V2TimGroupApplication applicationInfo, int index);
|
||||||
|
|
||||||
enum ApplicationStatus {
|
enum ApplicationStatus {
|
||||||
none,
|
none,
|
||||||
|
|
@ -57,7 +59,9 @@ class TIMUIKitGroupApplicationListState extends TIMUIKitState<TIMUIKitGroupAppli
|
||||||
final ApplicationStatus currentStatus = applicationStatusList[index];
|
final ApplicationStatus currentStatus = applicationStatusList[index];
|
||||||
|
|
||||||
String _getUserName() {
|
String _getUserName() {
|
||||||
if (applicationInfo.fromUserNickName != null && applicationInfo.fromUserNickName!.isNotEmpty && applicationInfo.fromUserNickName != applicationInfo.fromUser) {
|
if (applicationInfo.fromUserNickName != null &&
|
||||||
|
applicationInfo.fromUserNickName!.isNotEmpty &&
|
||||||
|
applicationInfo.fromUserNickName != applicationInfo.fromUser) {
|
||||||
return "${applicationInfo.fromUserNickName} (${applicationInfo.fromUser})";
|
return "${applicationInfo.fromUserNickName} (${applicationInfo.fromUser})";
|
||||||
} else {
|
} else {
|
||||||
return "${applicationInfo.fromUser}";
|
return "${applicationInfo.fromUser}";
|
||||||
|
|
@ -83,7 +87,9 @@ class TIMUIKitGroupApplicationListState extends TIMUIKitState<TIMUIKitGroupAppli
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
width: 40,
|
width: 40,
|
||||||
child: Avatar(faceUrl: applicationInfo.fromUserFaceUrl ?? "", showName: applicationInfo.fromUserNickName ?? applicationInfo.fromUser ?? ""),
|
child: Avatar(
|
||||||
|
faceUrl: applicationInfo.fromUserFaceUrl ?? "",
|
||||||
|
showName: applicationInfo.fromUserNickName ?? applicationInfo.fromUser ?? ""),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
|
|
@ -106,7 +112,10 @@ class TIMUIKitGroupApplicationListState extends TIMUIKitState<TIMUIKitGroupAppli
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(4), color: theme.primaryColor, border: Border.all(width: 1, color: theme.weakTextColor ?? CommonColor.weakTextColor)),
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
color: theme.primaryColor,
|
||||||
|
border: Border.all(width: 1, color: theme.weakTextColor ?? CommonColor.weakTextColor)),
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t("同意"), // agree
|
TIM_t("同意"), // agree
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
|
@ -135,7 +144,10 @@ class TIMUIKitGroupApplicationListState extends TIMUIKitState<TIMUIKitGroupAppli
|
||||||
if (currentStatus == ApplicationStatus.none && applicationInfo.handleStatus == 0)
|
if (currentStatus == ApplicationStatus.none && applicationInfo.handleStatus == 0)
|
||||||
InkWell(
|
InkWell(
|
||||||
child: Container(
|
child: Container(
|
||||||
decoration: BoxDecoration(borderRadius: BorderRadius.circular(4), color: Colors.white, border: Border.all(width: 1, color: theme.weakTextColor ?? CommonColor.weakTextColor)),
|
decoration: BoxDecoration(
|
||||||
|
borderRadius: BorderRadius.circular(4),
|
||||||
|
color: Colors.white,
|
||||||
|
border: Border.all(width: 1, color: theme.weakTextColor ?? CommonColor.weakTextColor)),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t("拒绝"), // reject
|
TIM_t("拒绝"), // reject
|
||||||
|
|
@ -146,7 +158,11 @@ class TIMUIKitGroupApplicationListState extends TIMUIKitState<TIMUIKitGroupAppli
|
||||||
),
|
),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
final res = await _groupServices.refuseGroupApplication(
|
final res = await _groupServices.refuseGroupApplication(
|
||||||
addTime: applicationInfo.addTime!, groupID: applicationInfo.groupID, fromUser: applicationInfo.fromUser!, toUser: applicationInfo.toUser!, type: GroupApplicationTypeEnum.values[applicationInfo.type]);
|
addTime: applicationInfo.addTime!,
|
||||||
|
groupID: applicationInfo.groupID,
|
||||||
|
fromUser: applicationInfo.fromUser!,
|
||||||
|
toUser: applicationInfo.toUser!,
|
||||||
|
type: GroupApplicationTypeEnum.values[applicationInfo.type]);
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
setState(() {
|
setState(() {
|
||||||
applicationStatusList[index] = ApplicationStatus.reject;
|
applicationStatusList[index] = ApplicationStatus.reject;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_application.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_application.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/widgets/avatar.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/widgets/avatar.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
|
|
@ -14,25 +15,19 @@ enum ApplicationStatus {
|
||||||
class TIMUIKitGroupApplicationListItem extends StatefulWidget {
|
class TIMUIKitGroupApplicationListItem extends StatefulWidget {
|
||||||
final V2TimGroupApplication applicationInfo;
|
final V2TimGroupApplication applicationInfo;
|
||||||
|
|
||||||
const TIMUIKitGroupApplicationListItem(
|
const TIMUIKitGroupApplicationListItem({Key? key, required this.applicationInfo}) : super(key: key);
|
||||||
{Key? key, required this.applicationInfo})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() =>
|
State<StatefulWidget> createState() => TIMUIKitGroupApplicationListItemState();
|
||||||
TIMUIKitGroupApplicationListItemState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class TIMUIKitGroupApplicationListItemState
|
class TIMUIKitGroupApplicationListItemState extends TIMUIKitState<TIMUIKitGroupApplicationListItem> {
|
||||||
extends TIMUIKitState<TIMUIKitGroupApplicationListItem> {
|
|
||||||
ApplicationStatus applicationStatus = ApplicationStatus.none;
|
ApplicationStatus applicationStatus = ApplicationStatus.none;
|
||||||
|
|
||||||
|
|
||||||
String _getUserName() {
|
String _getUserName() {
|
||||||
if (widget.applicationInfo.fromUserNickName != null &&
|
if (widget.applicationInfo.fromUserNickName != null &&
|
||||||
widget.applicationInfo.fromUserNickName!.isNotEmpty &&
|
widget.applicationInfo.fromUserNickName!.isNotEmpty &&
|
||||||
widget.applicationInfo.fromUserNickName !=
|
widget.applicationInfo.fromUserNickName != widget.applicationInfo.fromUser) {
|
||||||
widget.applicationInfo.fromUser) {
|
|
||||||
return "${widget.applicationInfo.fromUserNickName} (${widget.applicationInfo.fromUser})";
|
return "${widget.applicationInfo.fromUserNickName} (${widget.applicationInfo.fromUser})";
|
||||||
} else {
|
} else {
|
||||||
return "${widget.applicationInfo.fromUser}";
|
return "${widget.applicationInfo.fromUser}";
|
||||||
|
|
@ -55,26 +50,18 @@ class TIMUIKitGroupApplicationListItemState
|
||||||
width: 40,
|
width: 40,
|
||||||
child: Avatar(
|
child: Avatar(
|
||||||
faceUrl: widget.applicationInfo.fromUserFaceUrl ?? "",
|
faceUrl: widget.applicationInfo.fromUserFaceUrl ?? "",
|
||||||
showName: widget.applicationInfo.fromUserNickName ??
|
showName: widget.applicationInfo.fromUserNickName ?? widget.applicationInfo.fromUser ?? ""),
|
||||||
widget.applicationInfo.fromUser ??
|
|
||||||
""),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Column(
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
_getUserName(),
|
_getUserName(),
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: theme.darkTextColor),
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: theme.darkTextColor),
|
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
_getUserName(),
|
_getUserName(),
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 16, fontWeight: FontWeight.w600, color: theme.darkTextColor),
|
||||||
fontSize: 16,
|
|
||||||
fontWeight: FontWeight.w600,
|
|
||||||
color: theme.darkTextColor),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,10 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_param.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
||||||
|
|
@ -33,7 +35,8 @@ class _DeleteGroupMemberPageState extends TIMUIKitState<DeleteGroupMemberPage> {
|
||||||
|
|
||||||
handleSearchGroupMembers(String searchText, context) async {
|
handleSearchGroupMembers(String searchText, context) async {
|
||||||
searchText = searchText;
|
searchText = searchText;
|
||||||
List<V2TimGroupMemberFullInfo?> currentGroupMember = Provider.of<TUIGroupProfileModel>(context, listen: false).groupMemberList;
|
List<V2TimGroupMemberFullInfo?> currentGroupMember =
|
||||||
|
Provider.of<TUIGroupProfileModel>(context, listen: false).groupMemberList;
|
||||||
final res = await widget.model.searchGroupMember(V2TimGroupMemberSearchParam(
|
final res = await widget.model.searchGroupMember(V2TimGroupMemberSearchParam(
|
||||||
keywordList: [searchText],
|
keywordList: [searchText],
|
||||||
groupIDList: [widget.model.groupInfo!.groupID],
|
groupIDList: [widget.model.groupInfo!.groupID],
|
||||||
|
|
@ -60,7 +63,10 @@ class _DeleteGroupMemberPageState extends TIMUIKitState<DeleteGroupMemberPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
handleRole(groupMemberList) {
|
handleRole(groupMemberList) {
|
||||||
return groupMemberList?.where((value) => value?.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER).toList() ?? [];
|
return groupMemberList
|
||||||
|
?.where((value) => value?.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER)
|
||||||
|
.toList() ??
|
||||||
|
[];
|
||||||
}
|
}
|
||||||
|
|
||||||
void submitDelete() async {
|
void submitDelete() async {
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,10 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_search_param.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_search_param.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
|
|
@ -29,8 +31,7 @@ class GroupProfileMemberListPage extends StatefulWidget {
|
||||||
State<StatefulWidget> createState() => GroupProfileMemberListPageState();
|
State<StatefulWidget> createState() => GroupProfileMemberListPageState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class GroupProfileMemberListPageState
|
class GroupProfileMemberListPageState extends TIMUIKitState<GroupProfileMemberListPage> {
|
||||||
extends TIMUIKitState<GroupProfileMemberListPage> {
|
|
||||||
List<V2TimGroupMemberFullInfo?>? searchMemberList;
|
List<V2TimGroupMemberFullInfo?>? searchMemberList;
|
||||||
String? searchText;
|
String? searchText;
|
||||||
|
|
||||||
|
|
@ -45,8 +46,7 @@ class GroupProfileMemberListPageState
|
||||||
handleSearchGroupMembers(String searchText, context) async {
|
handleSearchGroupMembers(String searchText, context) async {
|
||||||
searchText = searchText;
|
searchText = searchText;
|
||||||
List<V2TimGroupMemberFullInfo?> currentGroupMember =
|
List<V2TimGroupMemberFullInfo?> currentGroupMember =
|
||||||
Provider.of<TUIGroupProfileModel>(context, listen: false)
|
Provider.of<TUIGroupProfileModel>(context, listen: false).groupMemberList;
|
||||||
.groupMemberList;
|
|
||||||
|
|
||||||
if (!isSearchTextExist(searchText)) {
|
if (!isSearchTextExist(searchText)) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
|
@ -55,8 +55,7 @@ class GroupProfileMemberListPageState
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final res =
|
final res = await widget.model.searchGroupMember(V2TimGroupMemberSearchParam(
|
||||||
await widget.model.searchGroupMember(V2TimGroupMemberSearchParam(
|
|
||||||
keywordList: [searchText],
|
keywordList: [searchText],
|
||||||
groupIDList: [widget.model.groupInfo!.groupID],
|
groupIDList: [widget.model.groupInfo!.groupID],
|
||||||
));
|
));
|
||||||
|
|
@ -84,25 +83,21 @@ class GroupProfileMemberListPageState
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final TUITheme theme = value.theme;
|
final TUITheme theme = value.theme;
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop;
|
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider.value(value: widget.model),
|
ChangeNotifierProvider.value(value: widget.model),
|
||||||
],
|
],
|
||||||
builder: (BuildContext context, Widget? w) {
|
builder: (BuildContext context, Widget? w) {
|
||||||
final TUIGroupProfileModel groupProfileModel =
|
final TUIGroupProfileModel groupProfileModel = Provider.of<TUIGroupProfileModel>(context);
|
||||||
Provider.of<TUIGroupProfileModel>(context);
|
String option1 = groupProfileModel.groupInfo?.memberCount.toString() ?? widget.memberList.length.toString();
|
||||||
String option1 = groupProfileModel.groupInfo?.memberCount.toString() ??
|
if (isDesktopScreen) {
|
||||||
widget.memberList.length.toString();
|
return GroupProfileMemberList(
|
||||||
if(isDesktopScreen){
|
|
||||||
return GroupProfileMemberList(
|
|
||||||
customTopArea: PlatformUtils().isWeb
|
customTopArea: PlatformUtils().isWeb
|
||||||
? null
|
? null
|
||||||
: GroupMemberSearchTextField(
|
: GroupMemberSearchTextField(
|
||||||
onTextChange: (text) =>
|
onTextChange: (text) => handleSearchGroupMembers(text, context),
|
||||||
handleSearchGroupMembers(text, context),
|
),
|
||||||
),
|
|
||||||
memberList: searchMemberList ?? groupProfileModel.groupMemberList,
|
memberList: searchMemberList ?? groupProfileModel.groupMemberList,
|
||||||
removeMember: _kickedOffMember,
|
removeMember: _kickedOffMember,
|
||||||
touchBottomCallBack: () {},
|
touchBottomCallBack: () {},
|
||||||
|
|
@ -116,13 +111,11 @@ class GroupProfileMemberListPageState
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(
|
title: Text(
|
||||||
TIM_t_para("群成员({{option1}}人)", "群成员($option1人)")(
|
TIM_t_para("群成员({{option1}}人)", "群成员($option1人)")(option1: option1),
|
||||||
option1: option1),
|
|
||||||
style: TextStyle(color: theme.appbarTextColor, fontSize: 17),
|
style: TextStyle(color: theme.appbarTextColor, fontSize: 17),
|
||||||
),
|
),
|
||||||
shadowColor: theme.weakBackgroundColor,
|
shadowColor: theme.weakBackgroundColor,
|
||||||
backgroundColor: theme.appbarBgColor ??
|
backgroundColor: theme.appbarBgColor ?? theme.primaryColor,
|
||||||
theme.primaryColor,
|
|
||||||
iconTheme: IconThemeData(
|
iconTheme: IconThemeData(
|
||||||
color: theme.appbarTextColor,
|
color: theme.appbarTextColor,
|
||||||
)),
|
)),
|
||||||
|
|
@ -130,8 +123,7 @@ class GroupProfileMemberListPageState
|
||||||
customTopArea: PlatformUtils().isWeb
|
customTopArea: PlatformUtils().isWeb
|
||||||
? null
|
? null
|
||||||
: GroupMemberSearchTextField(
|
: GroupMemberSearchTextField(
|
||||||
onTextChange: (text) =>
|
onTextChange: (text) => handleSearchGroupMembers(text, context),
|
||||||
handleSearchGroupMembers(text, context),
|
|
||||||
),
|
),
|
||||||
memberList: searchMemberList ?? groupProfileModel.groupMemberList,
|
memberList: searchMemberList ?? groupProfileModel.groupMemberList,
|
||||||
removeMember: _kickedOffMember,
|
removeMember: _kickedOffMember,
|
||||||
|
|
@ -141,8 +133,7 @@ class GroupProfileMemberListPageState
|
||||||
widget.model.onClickUser!(memberInfo, details);
|
widget.model.onClickUser!(memberInfo, details);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
));
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
|
|
||||||
enum GroupProfileWidgetEnum {
|
enum GroupProfileWidgetEnum {
|
||||||
/// The detail card for group.
|
/// The detail card for group.
|
||||||
|
|
@ -63,15 +65,14 @@ enum GroupProfileWidgetEnum {
|
||||||
|
|
||||||
class GroupProfileWidgetBuilder {
|
class GroupProfileWidgetBuilder {
|
||||||
/// The detail card for group.
|
/// The detail card for group.
|
||||||
Widget Function(V2TimGroupInfo groupInfo,
|
Widget Function(V2TimGroupInfo groupInfo, Function(String updateGroupName)? updateGroupName)? detailCard;
|
||||||
Function(String updateGroupName)? updateGroupName)? detailCard;
|
|
||||||
|
|
||||||
/// The tile shows the members in the group.
|
/// The tile shows the members in the group.
|
||||||
Widget Function(List<V2TimGroupMemberFullInfo?> memberList)? memberListTile;
|
Widget Function(List<V2TimGroupMemberFullInfo?> memberList)? memberListTile;
|
||||||
|
|
||||||
/// The entrance to the page editing the group notice.
|
/// The entrance to the page editing the group notice.
|
||||||
Widget Function(String currentNotice, Function() toDefaultNoticeEditPage,
|
Widget Function(String currentNotice, Function() toDefaultNoticeEditPage, Function(String newNotice) setGroupNotice)?
|
||||||
Function(String newNotice) setGroupNotice)? groupNotice;
|
groupNotice;
|
||||||
|
|
||||||
/// The entrance to the page managing the group.
|
/// The entrance to the page managing the group.
|
||||||
/// Works only for group owner and group admin.
|
/// Works only for group owner and group admin.
|
||||||
|
|
@ -89,47 +90,37 @@ class GroupProfileWidgetBuilder {
|
||||||
|
|
||||||
/// Shows and modify the mode or options users add the group.
|
/// Shows and modify the mode or options users add the group.
|
||||||
/// Includes "0: disallow group joining", "1: admin approval" and "2: automatic approval".
|
/// Includes "0: disallow group joining", "1: admin approval" and "2: automatic approval".
|
||||||
Widget Function(int groupAddOptType, Function(int addOpt) handleActionTap)?
|
Widget Function(int groupAddOptType, Function(int addOpt) handleActionTap)? groupJoiningModeBar;
|
||||||
groupJoiningModeBar;
|
|
||||||
|
|
||||||
/// Shows and modify the nickname for user in a specific group,
|
/// Shows and modify the nickname for user in a specific group,
|
||||||
/// only shows and used in this group, as the name card here.
|
/// only shows and used in this group, as the name card here.
|
||||||
Widget Function(String nameCard, Function(String newName) setNameCard)?
|
Widget Function(String nameCard, Function(String newName) setNameCard)? nameCardBar;
|
||||||
nameCardBar;
|
|
||||||
|
|
||||||
/// The switch of if mute the message notification from a specific group.
|
/// The switch of if mute the message notification from a specific group.
|
||||||
Widget Function(bool isMute, Function(bool isMute) setMute)?
|
Widget Function(bool isMute, Function(bool isMute) setMute)? muteGroupMessageBar;
|
||||||
muteGroupMessageBar;
|
|
||||||
|
|
||||||
/// The switch of if pin this group to the top in conversation list.
|
/// The switch of if pin this group to the top in conversation list.
|
||||||
Widget Function(bool isPined, Function(bool isMute) pinedConversation)?
|
Widget Function(bool isPined, Function(bool isMute) pinedConversation)? pinedConversationBar;
|
||||||
pinedConversationBar;
|
|
||||||
|
|
||||||
/// The button area, includes
|
/// The button area, includes
|
||||||
/// "clear chat history", "transfer group owner", "disband group" and "quit group"
|
/// "clear chat history", "transfer group owner", "disband group" and "quit group"
|
||||||
/// as default.
|
/// as default.
|
||||||
Widget Function(V2TimGroupInfo groupInfo,
|
Widget Function(V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList)? buttonArea;
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList)? buttonArea;
|
|
||||||
|
|
||||||
/// Custom area, you may define anything you want here.
|
/// Custom area, you may define anything you want here.
|
||||||
Widget Function(V2TimGroupInfo groupInfo,
|
Widget Function(V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderOne;
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderOne;
|
|
||||||
|
|
||||||
/// Custom area, you may define anything you want here.
|
/// Custom area, you may define anything you want here.
|
||||||
Widget Function(V2TimGroupInfo groupInfo,
|
Widget Function(V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderTwo;
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderTwo;
|
|
||||||
|
|
||||||
/// Custom area, you may define anything you want here.
|
/// Custom area, you may define anything you want here.
|
||||||
Widget Function(V2TimGroupInfo groupInfo,
|
Widget Function(V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderThree;
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderThree;
|
|
||||||
|
|
||||||
/// Custom area, you may define anything you want here.
|
/// Custom area, you may define anything you want here.
|
||||||
Widget Function(V2TimGroupInfo groupInfo,
|
Widget Function(V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderFour;
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderFour;
|
|
||||||
|
|
||||||
/// Custom area, you may define anything you want here.
|
/// Custom area, you may define anything you want here.
|
||||||
Widget Function(V2TimGroupInfo groupInfo,
|
Widget Function(V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderFive;
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList)? customBuilderFive;
|
|
||||||
|
|
||||||
GroupProfileWidgetBuilder(
|
GroupProfileWidgetBuilder(
|
||||||
{this.detailCard,
|
{this.detailCard,
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_change_info_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_change_info_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/group_profile_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/group_profile_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/listener_model/tui_group_listener_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/listener_model/tui_group_listener_model.dart';
|
||||||
|
|
@ -21,8 +23,8 @@ import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitGroupProfile/widgets/t
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
||||||
export 'package:tencent_cloud_chat_uikit/ui/widgets/transimit_group_owner_select.dart';
|
export 'package:tencent_cloud_chat_uikit/ui/widgets/transimit_group_owner_select.dart';
|
||||||
|
|
||||||
typedef GroupProfileBuilder = Widget Function(BuildContext context,
|
typedef GroupProfileBuilder = Widget Function(
|
||||||
V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList);
|
BuildContext context, V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList);
|
||||||
|
|
||||||
class TIMUIKitGroupProfile extends StatefulWidget {
|
class TIMUIKitGroupProfile extends StatefulWidget {
|
||||||
/// Group ID
|
/// Group ID
|
||||||
|
|
@ -31,13 +33,15 @@ class TIMUIKitGroupProfile extends StatefulWidget {
|
||||||
|
|
||||||
/// [Deprecated:] The builder for custom bottom operation area.
|
/// [Deprecated:] The builder for custom bottom operation area.
|
||||||
/// [operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead.
|
/// [operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead.
|
||||||
final Widget Function(BuildContext context, V2TimGroupInfo groupInfo,
|
final Widget Function(
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList)? bottomOperationBuilder;
|
BuildContext context, V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList)?
|
||||||
|
bottomOperationBuilder;
|
||||||
|
|
||||||
/// [Deprecated:] The builder for custom bottom operation area.
|
/// [Deprecated:] The builder for custom bottom operation area.
|
||||||
/// [operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead.
|
/// [operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead.
|
||||||
final Widget Function(BuildContext context, V2TimGroupInfo groupInfo,
|
final Widget Function(
|
||||||
List<V2TimGroupMemberFullInfo?> groupMemberList)? operationListBuilder;
|
BuildContext context, V2TimGroupInfo groupInfo, List<V2TimGroupMemberFullInfo?> groupMemberList)?
|
||||||
|
operationListBuilder;
|
||||||
|
|
||||||
/// [If you tend to customize the profile page, use [profileWidgetBuilder] with [profileWidgetsOrder] as priority.]
|
/// [If you tend to customize the profile page, use [profileWidgetBuilder] with [profileWidgetsOrder] as priority.]
|
||||||
/// The builder for each widgets in profile page,
|
/// The builder for each widgets in profile page,
|
||||||
|
|
@ -67,9 +71,9 @@ class TIMUIKitGroupProfile extends StatefulWidget {
|
||||||
required this.groupID,
|
required this.groupID,
|
||||||
this.backGroundColor,
|
this.backGroundColor,
|
||||||
@Deprecated("[operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead")
|
@Deprecated("[operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead")
|
||||||
this.bottomOperationBuilder,
|
this.bottomOperationBuilder,
|
||||||
@Deprecated("[operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead")
|
@Deprecated("[operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead")
|
||||||
this.operationListBuilder,
|
this.operationListBuilder,
|
||||||
this.builder,
|
this.builder,
|
||||||
this.profileWidgetBuilder,
|
this.profileWidgetBuilder,
|
||||||
this.onClickUser,
|
this.onClickUser,
|
||||||
|
|
@ -84,8 +88,7 @@ class TIMUIKitGroupProfile extends StatefulWidget {
|
||||||
class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
bool isSingleUse = false;
|
bool isSingleUse = false;
|
||||||
final model = TUIGroupProfileModel();
|
final model = TUIGroupProfileModel();
|
||||||
final TUIGroupListenerModel groupListenerModel =
|
final TUIGroupListenerModel groupListenerModel = serviceLocator<TUIGroupListenerModel>();
|
||||||
serviceLocator<TUIGroupListenerModel>();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -141,8 +144,7 @@ class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
model.lifeCycle = widget.lifeCycle;
|
model.lifeCycle = widget.lifeCycle;
|
||||||
final V2TimGroupInfo? groupInfo = model.groupInfo;
|
final V2TimGroupInfo? groupInfo = model.groupInfo;
|
||||||
final memberList = model.groupMemberList;
|
final memberList = model.groupMemberList;
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
if (groupInfo == null) {
|
if (groupInfo == null) {
|
||||||
return Center(
|
return Center(
|
||||||
child: LoadingAnimationWidget.staggeredDotsWave(
|
child: LoadingAnimationWidget.staggeredDotsWave(
|
||||||
|
|
@ -152,8 +154,7 @@ class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final TUIGroupListenerModel groupListenerModel =
|
final TUIGroupListenerModel groupListenerModel = Provider.of<TUIGroupListenerModel>(context);
|
||||||
Provider.of<TUIGroupListenerModel>(context);
|
|
||||||
final NeedUpdate? needUpdate = groupListenerModel.needUpdate;
|
final NeedUpdate? needUpdate = groupListenerModel.needUpdate;
|
||||||
if (needUpdate != null && needUpdate.groupID == widget.groupID) {
|
if (needUpdate != null && needUpdate.groupID == widget.groupID) {
|
||||||
groupListenerModel.needUpdate = null;
|
groupListenerModel.needUpdate = null;
|
||||||
|
|
@ -174,18 +175,14 @@ class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final isGroupOwner = groupInfo.role ==
|
final isGroupOwner = groupInfo.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER;
|
||||||
GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_OWNER;
|
final isAdmin = groupInfo.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN;
|
||||||
final isAdmin = groupInfo.role ==
|
|
||||||
GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_ADMIN;
|
|
||||||
|
|
||||||
Widget groupProfilePage({required Widget child}) {
|
Widget groupProfilePage({required Widget child}) {
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
child: Container(
|
child: Container(
|
||||||
color: widget.backGroundColor ??
|
color:
|
||||||
(isDesktopScreen
|
widget.backGroundColor ?? (isDesktopScreen ? theme.wideBackgroundColor : theme.weakBackgroundColor),
|
||||||
? theme.wideBackgroundColor
|
|
||||||
: theme.weakBackgroundColor),
|
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -195,9 +192,8 @@ class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => GroupProfileNotificationPage(
|
builder: (context) =>
|
||||||
model: model,
|
GroupProfileNotificationPage(model: model, notification: groupInfo.notification ?? "")));
|
||||||
notification: groupInfo.notification ?? "")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void toDefaultManagePage() {
|
void toDefaultManagePage() {
|
||||||
|
|
@ -209,19 +205,15 @@ class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _renderWidgetsWithOrder(
|
List<Widget> _renderWidgetsWithOrder(List<GroupProfileWidgetEnum> order) {
|
||||||
List<GroupProfileWidgetEnum> order) {
|
final GroupProfileWidgetBuilder? customBuilder = widget.profileWidgetBuilder;
|
||||||
final GroupProfileWidgetBuilder? customBuilder =
|
|
||||||
widget.profileWidgetBuilder;
|
|
||||||
return order.map((element) {
|
return order.map((element) {
|
||||||
switch (element) {
|
switch (element) {
|
||||||
case GroupProfileWidgetEnum.detailCard:
|
case GroupProfileWidgetEnum.detailCard:
|
||||||
return (customBuilder?.detailCard != null
|
return (customBuilder?.detailCard != null
|
||||||
? customBuilder?.detailCard!(
|
? customBuilder?.detailCard!(groupInfo, model.setGroupName)
|
||||||
groupInfo, model.setGroupName)
|
|
||||||
: TIMUIKitGroupProfileWidget.detailCard(
|
: TIMUIKitGroupProfileWidget.detailCard(
|
||||||
isHavePermission: isAdmin || isGroupOwner,
|
isHavePermission: isAdmin || isGroupOwner, groupInfo: groupInfo))!;
|
||||||
groupInfo: groupInfo))!;
|
|
||||||
case GroupProfileWidgetEnum.memberListTile:
|
case GroupProfileWidgetEnum.memberListTile:
|
||||||
return (customBuilder?.memberListTile != null
|
return (customBuilder?.memberListTile != null
|
||||||
? customBuilder?.memberListTile!(memberList)
|
? customBuilder?.memberListTile!(memberList)
|
||||||
|
|
@ -229,11 +221,8 @@ class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
case GroupProfileWidgetEnum.groupNotice:
|
case GroupProfileWidgetEnum.groupNotice:
|
||||||
return (customBuilder?.groupNotice != null
|
return (customBuilder?.groupNotice != null
|
||||||
? customBuilder?.groupNotice!(
|
? customBuilder?.groupNotice!(
|
||||||
groupInfo.notification ?? "",
|
groupInfo.notification ?? "", toDefaultNoticePage, model.setGroupNotification)
|
||||||
toDefaultNoticePage,
|
: TIMUIKitGroupProfileWidget.groupNotification(isHavePermission: isAdmin || isGroupOwner))!;
|
||||||
model.setGroupNotification)
|
|
||||||
: TIMUIKitGroupProfileWidget.groupNotification(
|
|
||||||
isHavePermission: isAdmin || isGroupOwner))!;
|
|
||||||
case GroupProfileWidgetEnum.groupManage:
|
case GroupProfileWidgetEnum.groupManage:
|
||||||
if (isAdmin || isGroupOwner) {
|
if (isAdmin || isGroupOwner) {
|
||||||
return (customBuilder?.groupManage != null
|
return (customBuilder?.groupManage != null
|
||||||
|
|
@ -263,25 +252,20 @@ class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
return (customBuilder?.groupJoiningModeBar != null
|
return (customBuilder?.groupJoiningModeBar != null
|
||||||
? customBuilder?.groupJoiningModeBar!(
|
? customBuilder?.groupJoiningModeBar!(groupInfo.groupAddOpt ?? 1, model.setGroupAddOpt)
|
||||||
groupInfo.groupAddOpt ?? 1, model.setGroupAddOpt)
|
|
||||||
: TIMUIKitGroupProfileWidget.groupAddOpt())!;
|
: TIMUIKitGroupProfileWidget.groupAddOpt())!;
|
||||||
case GroupProfileWidgetEnum.nameCardBar:
|
case GroupProfileWidgetEnum.nameCardBar:
|
||||||
return (customBuilder?.nameCardBar != null
|
return (customBuilder?.nameCardBar != null
|
||||||
? customBuilder?.nameCardBar!(
|
? customBuilder?.nameCardBar!(model.getSelfNameCard(), model.setNameCard)
|
||||||
model.getSelfNameCard(), model.setNameCard)
|
|
||||||
: TIMUIKitGroupProfileWidget.nameCard())!;
|
: TIMUIKitGroupProfileWidget.nameCard())!;
|
||||||
case GroupProfileWidgetEnum.muteGroupMessageBar:
|
case GroupProfileWidgetEnum.muteGroupMessageBar:
|
||||||
return (customBuilder?.muteGroupMessageBar != null
|
return (customBuilder?.muteGroupMessageBar != null
|
||||||
? customBuilder?.muteGroupMessageBar!(
|
? customBuilder?.muteGroupMessageBar!(model.conversation?.recvOpt != 0, model.setMessageDisturb)
|
||||||
model.conversation?.recvOpt != 0,
|
|
||||||
model.setMessageDisturb)
|
|
||||||
: TIMUIKitGroupProfileWidget.messageDisturb())!;
|
: TIMUIKitGroupProfileWidget.messageDisturb())!;
|
||||||
case GroupProfileWidgetEnum.pinedConversationBar:
|
case GroupProfileWidgetEnum.pinedConversationBar:
|
||||||
return (customBuilder?.pinedConversationBar != null
|
return (customBuilder?.pinedConversationBar != null
|
||||||
? customBuilder?.pinedConversationBar!(
|
? customBuilder?.pinedConversationBar!(
|
||||||
model.conversation?.isPinned ?? false,
|
model.conversation?.isPinned ?? false, model.pinedConversation)
|
||||||
model.pinedConversation)
|
|
||||||
: TIMUIKitGroupProfileWidget.pinedConversation())!;
|
: TIMUIKitGroupProfileWidget.pinedConversation())!;
|
||||||
case GroupProfileWidgetEnum.buttonArea:
|
case GroupProfileWidgetEnum.buttonArea:
|
||||||
return (customBuilder?.buttonArea != null
|
return (customBuilder?.buttonArea != null
|
||||||
|
|
@ -299,8 +283,7 @@ class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
||||||
case GroupProfileWidgetEnum.customBuilderThree:
|
case GroupProfileWidgetEnum.customBuilderThree:
|
||||||
return (customBuilder?.customBuilderThree != null
|
return (customBuilder?.customBuilderThree != null
|
||||||
? customBuilder?.customBuilderThree!(
|
? customBuilder?.customBuilderThree!(groupInfo, memberList)
|
||||||
groupInfo, memberList)
|
|
||||||
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
||||||
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
||||||
case GroupProfileWidgetEnum.customBuilderFour:
|
case GroupProfileWidgetEnum.customBuilderFour:
|
||||||
|
|
@ -326,9 +309,7 @@ class _TIMUIKitGroupProfileState extends TIMUIKitState<TIMUIKitGroupProfile> {
|
||||||
} else if (widget.profileWidgetsOrder != null) {
|
} else if (widget.profileWidgetsOrder != null) {
|
||||||
return groupProfilePage(
|
return groupProfilePage(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [..._renderWidgetsWithOrder(widget.profileWidgetsOrder!)],
|
||||||
..._renderWidgetsWithOrder(widget.profileWidgetsOrder!)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitGroupProfile/widgets/tim_ui_group_search_msg.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitGroupProfile/widgets/tim_ui_group_search_msg.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitGroupProfile/widgets/tim_uikit_group_add_opt.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitGroupProfile/widgets/tim_uikit_group_add_opt.dart';
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
||||||
|
|
@ -16,10 +17,8 @@ import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
||||||
|
|
||||||
class GroupProfileGroupSearch extends TIMUIKitStatelessWidget {
|
class GroupProfileGroupSearch extends TIMUIKitStatelessWidget {
|
||||||
GroupProfileGroupSearch({Key? key, required this.onJumpToSearch})
|
GroupProfileGroupSearch({Key? key, required this.onJumpToSearch}) : super(key: key);
|
||||||
: super(key: key);
|
final ConversationService _conversationService = serviceLocator<ConversationService>();
|
||||||
final ConversationService _conversationService =
|
|
||||||
serviceLocator<ConversationService>();
|
|
||||||
|
|
||||||
final Function(V2TimConversation?) onJumpToSearch;
|
final Function(V2TimConversation?) onJumpToSearch;
|
||||||
|
|
||||||
|
|
@ -32,21 +31,16 @@ class GroupProfileGroupSearch extends TIMUIKitStatelessWidget {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
V2TimConversation? conversation =
|
V2TimConversation? conversation =
|
||||||
await _conversationService.getConversation(
|
await _conversationService.getConversation(conversationID: "group_${model.groupInfo!.groupID}");
|
||||||
conversationID: "group_${model.groupInfo!.groupID}");
|
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
onJumpToSearch(conversation);
|
onJumpToSearch(conversation);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 16),
|
||||||
vertical: 14, horizontal: 16),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
border: Border(
|
border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
bottom: BorderSide(
|
|
||||||
color: theme.weakDividerColor ??
|
|
||||||
CommonColor.weakDividerColor))),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
||||||
|
|
@ -20,11 +21,9 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
final TUIGroupProfileModel model;
|
final TUIGroupProfileModel model;
|
||||||
final sdkInstance = TIMUIKitCore.getSDKInstance();
|
final sdkInstance = TIMUIKitCore.getSDKInstance();
|
||||||
final coreInstance = TIMUIKitCore.getInstance();
|
final coreInstance = TIMUIKitCore.getInstance();
|
||||||
final TIMUIKitChatController _timuiKitChatController =
|
final TIMUIKitChatController _timuiKitChatController = TIMUIKitChatController();
|
||||||
TIMUIKitChatController();
|
|
||||||
|
|
||||||
GroupProfileButtonArea(this.groupID, this.model, {Key? key})
|
GroupProfileButtonArea(this.groupID, this.model, {Key? key}) : super(key: key);
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
final _operationList = [
|
final _operationList = [
|
||||||
{"label": TIM_t("清空消息"), "id": "clearHistory"},
|
{"label": TIM_t("清空消息"), "id": "clearHistory"},
|
||||||
|
|
@ -34,8 +33,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
];
|
];
|
||||||
|
|
||||||
_clearHistory(BuildContext context, theme) async {
|
_clearHistory(BuildContext context, theme) async {
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
|
|
||||||
if (isDesktopScreen) {
|
if (isDesktopScreen) {
|
||||||
TUIKitWidePopup.showSecondaryConfirmDialog(
|
TUIKitWidePopup.showSecondaryConfirmDialog(
|
||||||
|
|
@ -46,16 +44,13 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
onCancel: () {},
|
onCancel: () {},
|
||||||
onConfirm: () async {
|
onConfirm: () async {
|
||||||
if (PlatformUtils().isWeb) {
|
if (PlatformUtils().isWeb) {
|
||||||
final res = await sdkInstance
|
final res =
|
||||||
.getConversationManager()
|
await sdkInstance.getConversationManager().deleteConversation(conversationID: "group_$groupID");
|
||||||
.deleteConversation(conversationID: "group_$groupID");
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
_timuiKitChatController.clearHistory(groupID);
|
_timuiKitChatController.clearHistory(groupID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final res = await sdkInstance
|
final res = await sdkInstance.getMessageManager().clearGroupHistoryMessage(groupID: groupID);
|
||||||
.getMessageManager()
|
|
||||||
.clearGroupHistoryMessage(groupID: groupID);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
_timuiKitChatController.clearHistory(groupID);
|
_timuiKitChatController.clearHistory(groupID);
|
||||||
}
|
}
|
||||||
|
|
@ -82,16 +77,13 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
if (PlatformUtils().isWeb) {
|
if (PlatformUtils().isWeb) {
|
||||||
final res = await sdkInstance
|
final res =
|
||||||
.getConversationManager()
|
await sdkInstance.getConversationManager().deleteConversation(conversationID: "group_$groupID");
|
||||||
.deleteConversation(conversationID: "group_$groupID");
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
_timuiKitChatController.clearHistory(groupID);
|
_timuiKitChatController.clearHistory(groupID);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
final res = await sdkInstance
|
final res = await sdkInstance.getMessageManager().clearGroupHistoryMessage(groupID: groupID);
|
||||||
.getMessageManager()
|
|
||||||
.clearGroupHistoryMessage(groupID: groupID);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
_timuiKitChatController.clearHistory(groupID);
|
_timuiKitChatController.clearHistory(groupID);
|
||||||
}
|
}
|
||||||
|
|
@ -111,8 +103,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
_quitGroup(BuildContext context, TUITheme theme) async {
|
_quitGroup(BuildContext context, TUITheme theme) async {
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
|
|
||||||
if (isDesktopScreen) {
|
if (isDesktopScreen) {
|
||||||
TUIKitWidePopup.showSecondaryConfirmDialog(
|
TUIKitWidePopup.showSecondaryConfirmDialog(
|
||||||
|
|
@ -124,9 +115,8 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
onConfirm: () async {
|
onConfirm: () async {
|
||||||
final res = await sdkInstance.quitGroup(groupID: groupID);
|
final res = await sdkInstance.quitGroup(groupID: groupID);
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
final deleteConvRes = await sdkInstance
|
final deleteConvRes =
|
||||||
.getConversationManager()
|
await sdkInstance.getConversationManager().deleteConversation(conversationID: "group_$groupID");
|
||||||
.deleteConversation(conversationID: "group_$groupID");
|
|
||||||
if (deleteConvRes.code == 0) {
|
if (deleteConvRes.code == 0) {
|
||||||
model.lifeCycle?.didLeaveGroup();
|
model.lifeCycle?.didLeaveGroup();
|
||||||
}
|
}
|
||||||
|
|
@ -155,9 +145,8 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
);
|
);
|
||||||
final res = await sdkInstance.quitGroup(groupID: groupID);
|
final res = await sdkInstance.quitGroup(groupID: groupID);
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
final deleteConvRes = await sdkInstance
|
final deleteConvRes =
|
||||||
.getConversationManager()
|
await sdkInstance.getConversationManager().deleteConversation(conversationID: "group_$groupID");
|
||||||
.deleteConversation(conversationID: "group_$groupID");
|
|
||||||
if (deleteConvRes.code == 0) {
|
if (deleteConvRes.code == 0) {
|
||||||
model.lifeCycle?.didLeaveGroup();
|
model.lifeCycle?.didLeaveGroup();
|
||||||
}
|
}
|
||||||
|
|
@ -181,8 +170,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
_dismissGroup(BuildContext context, theme) async {
|
_dismissGroup(BuildContext context, theme) async {
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
|
|
||||||
if (isDesktopScreen) {
|
if (isDesktopScreen) {
|
||||||
TUIKitWidePopup.showSecondaryConfirmDialog(
|
TUIKitWidePopup.showSecondaryConfirmDialog(
|
||||||
|
|
@ -194,9 +182,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
onConfirm: () async {
|
onConfirm: () async {
|
||||||
final res = await sdkInstance.dismissGroup(groupID: groupID);
|
final res = await sdkInstance.dismissGroup(groupID: groupID);
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
await sdkInstance
|
await sdkInstance.getConversationManager().deleteConversation(conversationID: "group_$groupID");
|
||||||
.getConversationManager()
|
|
||||||
.deleteConversation(conversationID: "group_$groupID");
|
|
||||||
model.lifeCycle?.didLeaveGroup();
|
model.lifeCycle?.didLeaveGroup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -220,9 +206,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final res = await sdkInstance.dismissGroup(groupID: groupID);
|
final res = await sdkInstance.dismissGroup(groupID: groupID);
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
await sdkInstance
|
await sdkInstance.getConversationManager().deleteConversation(conversationID: "group_$groupID");
|
||||||
.getConversationManager()
|
|
||||||
.deleteConversation(conversationID: "group_$groupID");
|
|
||||||
model.lifeCycle?.didLeaveGroup();
|
model.lifeCycle?.didLeaveGroup();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -240,8 +224,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
_transmitOwner(BuildContext context, String groupID) async {
|
_transmitOwner(BuildContext context, String groupID) async {
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
|
|
||||||
if (isDesktopScreen) {
|
if (isDesktopScreen) {
|
||||||
TUIKitWidePopup.showPopupWindow(
|
TUIKitWidePopup.showPopupWindow(
|
||||||
|
|
@ -260,9 +243,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
onSelectedMember: (selectedMember) async {
|
onSelectedMember: (selectedMember) async {
|
||||||
if (selectedMember.isNotEmpty) {
|
if (selectedMember.isNotEmpty) {
|
||||||
final userID = selectedMember.first.userID;
|
final userID = selectedMember.first.userID;
|
||||||
await sdkInstance
|
await sdkInstance.getGroupManager().transferGroupOwner(groupID: groupID, userID: userID);
|
||||||
.getGroupManager()
|
|
||||||
.transferGroupOwner(groupID: groupID, userID: userID);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -279,29 +260,23 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
);
|
);
|
||||||
if (selectedMember != null) {
|
if (selectedMember != null) {
|
||||||
final userID = selectedMember.first.userID;
|
final userID = selectedMember.first.userID;
|
||||||
await sdkInstance
|
await sdkInstance.getGroupManager().transferGroupOwner(groupID: groupID, userID: userID);
|
||||||
.getGroupManager()
|
|
||||||
.transferGroupOwner(groupID: groupID, userID: userID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _renderGroupOperation(
|
List<Widget> _renderGroupOperation(BuildContext context, TUITheme theme, bool isOwner, String groupType) {
|
||||||
BuildContext context, TUITheme theme, bool isOwner, String groupType) {
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
final isDesktopScreen =
|
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
return _operationList
|
return _operationList
|
||||||
.where((element) {
|
.where((element) {
|
||||||
if (!isOwner) {
|
if (!isOwner) {
|
||||||
return ["quitGroup", "clearHistory"].contains(element["id"]);
|
return ["quitGroup", "clearHistory"].contains(element["id"]);
|
||||||
} else {
|
} else {
|
||||||
if (groupType == "Work") {
|
if (groupType == "Work") {
|
||||||
return ["clearHistory", "quitGroup", "transimitOwner"]
|
return ["clearHistory", "quitGroup", "transimitOwner"].contains(element["id"]);
|
||||||
.contains(element["id"]);
|
|
||||||
}
|
}
|
||||||
if (groupType != "Work") {
|
if (groupType != "Work") {
|
||||||
return ["clearHistory", "dismissGroup", "transimitOwner"]
|
return ["clearHistory", "dismissGroup", "transimitOwner"].contains(element["id"]);
|
||||||
.contains(element["id"]);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -340,10 +315,8 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
border: Border(
|
border:
|
||||||
bottom: BorderSide(
|
Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
color: theme.weakDividerColor ??
|
|
||||||
CommonColor.weakDividerColor))),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
e["label"]!,
|
e["label"]!,
|
||||||
style: TextStyle(color: theme.cautionColor, fontSize: 17),
|
style: TextStyle(color: theme.cautionColor, fontSize: 17),
|
||||||
|
|
@ -358,8 +331,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
final theme = value.theme;
|
final theme = value.theme;
|
||||||
final groupInfo = model.groupInfo;
|
final groupInfo = model.groupInfo;
|
||||||
|
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
if (isDesktopScreen) {
|
if (isDesktopScreen) {
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
|
@ -367,10 +339,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
spacing: 28,
|
spacing: 28,
|
||||||
children: [
|
children: [
|
||||||
..._renderGroupOperation(
|
..._renderGroupOperation(
|
||||||
context,
|
context, theme, groupInfo?.owner == coreInstance.loginUserInfo?.userID, groupInfo?.groupType ?? "")
|
||||||
theme,
|
|
||||||
groupInfo?.owner == coreInstance.loginUserInfo?.userID,
|
|
||||||
groupInfo?.groupType ?? "")
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
@ -379,10 +348,7 @@ class GroupProfileButtonArea extends TIMUIKitStatelessWidget {
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
..._renderGroupOperation(
|
..._renderGroupOperation(
|
||||||
context,
|
context, theme, groupInfo?.owner == coreInstance.loginUserInfo?.userID, groupInfo?.groupType ?? "")
|
||||||
theme,
|
|
||||||
groupInfo?.owner == coreInstance.loginUserInfo?.userID,
|
|
||||||
groupInfo?.groupType ?? "")
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
|
|
@ -19,11 +20,7 @@ class GroupProfileDetailCard extends TIMUIKitStatelessWidget {
|
||||||
final TextEditingController controller = TextEditingController();
|
final TextEditingController controller = TextEditingController();
|
||||||
final bool isHavePermission;
|
final bool isHavePermission;
|
||||||
|
|
||||||
GroupProfileDetailCard(
|
GroupProfileDetailCard({Key? key, required this.groupInfo, this.isHavePermission = false, this.updateGroupName})
|
||||||
{Key? key,
|
|
||||||
required this.groupInfo,
|
|
||||||
this.isHavePermission = false,
|
|
||||||
this.updateGroupName})
|
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -33,8 +30,7 @@ class GroupProfileDetailCard extends TIMUIKitStatelessWidget {
|
||||||
final faceUrl = groupInfo.faceUrl ?? "";
|
final faceUrl = groupInfo.faceUrl ?? "";
|
||||||
final groupID = groupInfo.groupID;
|
final groupID = groupInfo.groupID;
|
||||||
final showName = groupInfo.groupName ?? groupID;
|
final showName = groupInfo.groupName ?? groupID;
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
|
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTapDown: !isHavePermission
|
onTapDown: !isHavePermission
|
||||||
|
|
@ -45,11 +41,8 @@ class GroupProfileDetailCard extends TIMUIKitStatelessWidget {
|
||||||
context: context,
|
context: context,
|
||||||
title: TIM_t("修改群名称"),
|
title: TIM_t("修改群名称"),
|
||||||
initText: showName,
|
initText: showName,
|
||||||
initOffset: Offset(
|
initOffset: Offset(min(details.globalPosition.dx, MediaQuery.of(context).size.width - 350),
|
||||||
min(details.globalPosition.dx,
|
min(details.globalPosition.dy + 20, MediaQuery.of(context).size.height - 470)),
|
||||||
MediaQuery.of(context).size.width - 350),
|
|
||||||
min(details.globalPosition.dy + 20,
|
|
||||||
MediaQuery.of(context).size.height - 470)),
|
|
||||||
onSubmitted: (String newText) async {
|
onSubmitted: (String newText) async {
|
||||||
final text = newText.trim();
|
final text = newText.trim();
|
||||||
if (updateGroupName != null) {
|
if (updateGroupName != null) {
|
||||||
|
|
@ -88,31 +81,25 @@ class GroupProfileDetailCard extends TIMUIKitStatelessWidget {
|
||||||
decoration: const BoxDecoration(
|
decoration: const BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
borderRadius: BorderRadius.only(
|
borderRadius: BorderRadius.only(
|
||||||
topLeft: Radius.circular(10.0),
|
topLeft: Radius.circular(10.0), topRight: Radius.circular(10.0))),
|
||||||
topRight: Radius.circular(10.0))),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(vertical: 20),
|
||||||
vertical: 20),
|
|
||||||
child: Text(TIM_t("修改群名称")),
|
child: Text(TIM_t("修改群名称")),
|
||||||
),
|
),
|
||||||
Divider(
|
Divider(height: 2, color: theme.weakDividerColor),
|
||||||
height: 2,
|
|
||||||
color: theme.weakDividerColor),
|
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.all(20),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment:
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
CrossAxisAlignment.start,
|
|
||||||
children: [
|
children: [
|
||||||
TextField(
|
TextField(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
border: InputBorder.none,
|
border: InputBorder.none,
|
||||||
fillColor: theme
|
fillColor: theme.weakBackgroundColor,
|
||||||
.weakBackgroundColor,
|
|
||||||
filled: true,
|
filled: true,
|
||||||
isDense: true,
|
isDense: true,
|
||||||
hintText: ''),
|
hintText: ''),
|
||||||
|
|
@ -122,10 +109,7 @@ class GroupProfileDetailCard extends TIMUIKitStatelessWidget {
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
TIM_t("修改群名称"),
|
TIM_t("修改群名称"),
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: 13, color: theme.weakTextColor),
|
||||||
fontSize: 13,
|
|
||||||
color:
|
|
||||||
theme.weakTextColor),
|
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|
@ -135,16 +119,11 @@ class GroupProfileDetailCard extends TIMUIKitStatelessWidget {
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
child: ElevatedButton(
|
child: ElevatedButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
final text = controller
|
final text = controller.text.trim();
|
||||||
.text
|
if (updateGroupName != null) {
|
||||||
.trim();
|
updateGroupName!(text);
|
||||||
if (updateGroupName !=
|
|
||||||
null) {
|
|
||||||
updateGroupName!(
|
|
||||||
text);
|
|
||||||
} else {
|
} else {
|
||||||
model.setGroupName(
|
model.setGroupName(text);
|
||||||
text);
|
|
||||||
}
|
}
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
|
@ -155,11 +134,8 @@ class GroupProfileDetailCard extends TIMUIKitStatelessWidget {
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(
|
padding:
|
||||||
bottom:
|
EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
|
||||||
MediaQuery.of(context)
|
|
||||||
.viewInsets
|
|
||||||
.bottom),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -209,17 +185,13 @@ class GroupProfileDetailCard extends TIMUIKitStatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
SelectableText(
|
SelectableText(
|
||||||
showName,
|
showName,
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: isDesktopScreen ? 15 : 18, fontWeight: FontWeight.w600),
|
||||||
fontSize: isDesktopScreen ? 15 : 18,
|
|
||||||
fontWeight: FontWeight.w600),
|
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: isDesktopScreen ? 4 : 8,
|
height: isDesktopScreen ? 4 : 8,
|
||||||
),
|
),
|
||||||
SelectableText("ID: $groupID",
|
SelectableText("ID: $groupID",
|
||||||
style: TextStyle(
|
style: TextStyle(fontSize: isDesktopScreen ? 13 : 13, color: theme.weakTextColor))
|
||||||
fontSize: isDesktopScreen ? 13 : 13,
|
|
||||||
color: theme.weakTextColor))
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,8 @@ import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_member_role.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/enum/group_type.dart';
|
import 'package:tencent_cloud_chat_sdk/enum/group_type.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
import 'package:tencent_cloud_chat_sdk/tencent_im_sdk_plugin.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
|
|
@ -45,7 +46,11 @@ class GroupProfileGroupManageState extends TIMUIKitState<GroupProfileGroupManage
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
decoration: BoxDecoration(color: Colors.white, border: isDesktopScreen ? null : Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border: isDesktopScreen
|
||||||
|
? null
|
||||||
|
: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
InkWell(
|
InkWell(
|
||||||
|
|
@ -121,7 +126,10 @@ class _GroupProfileGroupManagePageState extends TIMUIKitState<GroupProfileGroupM
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [ChangeNotifierProvider.value(value: widget.model), ChangeNotifierProvider.value(value: serviceLocator<TUIThemeViewModel>())],
|
providers: [
|
||||||
|
ChangeNotifierProvider.value(value: widget.model),
|
||||||
|
ChangeNotifierProvider.value(value: serviceLocator<TUIThemeViewModel>())
|
||||||
|
],
|
||||||
builder: (context, w) {
|
builder: (context, w) {
|
||||||
final memberList = Provider.of<TUIGroupProfileModel>(context).groupMemberList;
|
final memberList = Provider.of<TUIGroupProfileModel>(context).groupMemberList;
|
||||||
final theme = Provider.of<TUIThemeViewModel>(context).theme;
|
final theme = Provider.of<TUIThemeViewModel>(context).theme;
|
||||||
|
|
@ -133,8 +141,16 @@ class _GroupProfileGroupManagePageState extends TIMUIKitState<GroupProfileGroupM
|
||||||
return Column(
|
return Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: EdgeInsets.only(top: 12, left: isDesktopScreen ? 0 : 16, bottom: isDesktopScreen ? 0 : 12, right: isDesktopScreen ? 0 : 12),
|
padding: EdgeInsets.only(
|
||||||
decoration: BoxDecoration(color: Colors.white, border: isDesktopScreen ? null : Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
top: 12,
|
||||||
|
left: isDesktopScreen ? 0 : 16,
|
||||||
|
bottom: isDesktopScreen ? 0 : 12,
|
||||||
|
right: isDesktopScreen ? 0 : 12),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border: isDesktopScreen
|
||||||
|
? null
|
||||||
|
: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: isDesktopScreen
|
onTap: isDesktopScreen
|
||||||
? null
|
? null
|
||||||
|
|
@ -156,7 +172,11 @@ class _GroupProfileGroupManagePageState extends TIMUIKitState<GroupProfileGroupM
|
||||||
)
|
)
|
||||||
: Row(
|
: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [Text(TIM_t("设置管理员"), style: TextStyle(fontSize: isDesktopScreen ? 14 : 16, color: theme.darkTextColor)), Icon(Icons.keyboard_arrow_right, color: theme.weakTextColor)],
|
children: [
|
||||||
|
Text(TIM_t("设置管理员"),
|
||||||
|
style: TextStyle(fontSize: isDesktopScreen ? 14 : 16, color: theme.darkTextColor)),
|
||||||
|
Icon(Icons.keyboard_arrow_right, color: theme.weakTextColor)
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -167,7 +187,10 @@ class _GroupProfileGroupManagePageState extends TIMUIKitState<GroupProfileGroupM
|
||||||
if (!isDesktopScreen)
|
if (!isDesktopScreen)
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.only(top: 12, left: 16, bottom: 12, right: 12),
|
padding: const EdgeInsets.only(top: 12, left: 16, bottom: 12, right: 12),
|
||||||
decoration: BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border:
|
||||||
|
Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -229,7 +252,13 @@ class _GroupProfileGroupManagePageState extends TIMUIKitState<GroupProfileGroupM
|
||||||
: const EdgeInsets.only(
|
: const EdgeInsets.only(
|
||||||
bottom: 4,
|
bottom: 4,
|
||||||
),
|
),
|
||||||
decoration: isDesktopScreen ? null : BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
decoration: isDesktopScreen
|
||||||
|
? null
|
||||||
|
: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border: Border(
|
||||||
|
bottom:
|
||||||
|
BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
|
|
@ -293,7 +322,9 @@ class _GroupProfileGroupManagePageState extends TIMUIKitState<GroupProfileGroupM
|
||||||
isDarkBackground: false,
|
isDarkBackground: false,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||||
context: context,
|
context: context,
|
||||||
offset: Offset(min(details.globalPosition.dx, MediaQuery.of(context).size.width - 80), details.globalPosition.dy),
|
offset: Offset(
|
||||||
|
min(details.globalPosition.dx, MediaQuery.of(context).size.width - 80),
|
||||||
|
details.globalPosition.dy),
|
||||||
child: (onClose) => TUIKitColumnMenu(data: [
|
child: (onClose) => TUIKitColumnMenu(data: [
|
||||||
ColumnMenuItem(
|
ColumnMenuItem(
|
||||||
label: TIM_t("删除"),
|
label: TIM_t("删除"),
|
||||||
|
|
@ -408,7 +439,10 @@ Widget _buildListItem(BuildContext context, V2TimGroupMemberFullInfo memberInfo,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TUIKitScreenUtils.getDeviceWidget(context: context, desktopWidget: nameItem(), defaultWidget: SingleChildScrollView(child: Slidable(endActionPane: endActionPane, child: nameItem())));
|
return TUIKitScreenUtils.getDeviceWidget(
|
||||||
|
context: context,
|
||||||
|
desktopWidget: nameItem(),
|
||||||
|
defaultWidget: SingleChildScrollView(child: Slidable(endActionPane: endActionPane, child: nameItem())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 选择管理员
|
/// 选择管理员
|
||||||
|
|
@ -509,7 +543,12 @@ class _GroupProfileSetManagerPageState extends TIMUIKitState<GroupProfileSetMana
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 12,
|
vertical: 12,
|
||||||
),
|
),
|
||||||
decoration: isDesktopScreen ? null : BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
decoration: isDesktopScreen
|
||||||
|
? null
|
||||||
|
: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border: Border(
|
||||||
|
bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
|
|
@ -537,7 +576,10 @@ class _GroupProfileSetManagerPageState extends TIMUIKitState<GroupProfileSetMana
|
||||||
},
|
},
|
||||||
child: (onClose) => GroupProfileAddAdmin(
|
child: (onClose) => GroupProfileAddAdmin(
|
||||||
key: groupProfileAddAdminKey,
|
key: groupProfileAddAdminKey,
|
||||||
memberList: memberList.where((element) => element?.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER).toList(),
|
memberList: memberList
|
||||||
|
.where(
|
||||||
|
(element) => element?.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER)
|
||||||
|
.toList(),
|
||||||
appbarTitle: TIM_t("设置管理员"),
|
appbarTitle: TIM_t("设置管理员"),
|
||||||
selectCompletedHandler: (context, selectedMember) async {
|
selectCompletedHandler: (context, selectedMember) async {
|
||||||
if (selectedMember.isNotEmpty) {
|
if (selectedMember.isNotEmpty) {
|
||||||
|
|
@ -554,7 +596,10 @@ class _GroupProfileSetManagerPageState extends TIMUIKitState<GroupProfileSetMana
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => GroupProfileAddAdmin(
|
builder: (context) => GroupProfileAddAdmin(
|
||||||
key: groupProfileAddAdminKey,
|
key: groupProfileAddAdminKey,
|
||||||
memberList: memberList.where((element) => element?.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER).toList(),
|
memberList: memberList
|
||||||
|
.where((element) =>
|
||||||
|
element?.role == GroupMemberRoleType.V2TIM_GROUP_MEMBER_ROLE_MEMBER)
|
||||||
|
.toList(),
|
||||||
appbarTitle: TIM_t("设置管理员"),
|
appbarTitle: TIM_t("设置管理员"),
|
||||||
selectCompletedHandler: (context, selectedMember) async {
|
selectCompletedHandler: (context, selectedMember) async {
|
||||||
if (selectedMember.isNotEmpty) {
|
if (selectedMember.isNotEmpty) {
|
||||||
|
|
@ -576,7 +621,8 @@ class _GroupProfileSetManagerPageState extends TIMUIKitState<GroupProfileSetMana
|
||||||
isDarkBackground: false,
|
isDarkBackground: false,
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
borderRadius: const BorderRadius.all(Radius.circular(4)),
|
||||||
context: context,
|
context: context,
|
||||||
offset: Offset(min(details.globalPosition.dx, MediaQuery.of(context).size.width - 80), details.globalPosition.dy),
|
offset: Offset(min(details.globalPosition.dx, MediaQuery.of(context).size.width - 80),
|
||||||
|
details.globalPosition.dy),
|
||||||
child: (onClose) => TUIKitColumnMenu(data: [
|
child: (onClose) => TUIKitColumnMenu(data: [
|
||||||
ColumnMenuItem(
|
ColumnMenuItem(
|
||||||
label: TIM_t("删除"),
|
label: TIM_t("删除"),
|
||||||
|
|
@ -638,7 +684,9 @@ class GroupProfileAddAdmin extends StatefulWidget {
|
||||||
final String appbarTitle;
|
final String appbarTitle;
|
||||||
final void Function(BuildContext context, List<V2TimGroupMemberFullInfo?> selectedMemberList)? selectCompletedHandler;
|
final void Function(BuildContext context, List<V2TimGroupMemberFullInfo?> selectedMemberList)? selectCompletedHandler;
|
||||||
|
|
||||||
const GroupProfileAddAdmin({Key? key, required this.memberList, this.selectCompletedHandler, required this.appbarTitle}) : super(key: key);
|
const GroupProfileAddAdmin(
|
||||||
|
{Key? key, required this.memberList, this.selectCompletedHandler, required this.appbarTitle})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => _GroupProfileAddAdminState();
|
State<StatefulWidget> createState() => _GroupProfileAddAdminState();
|
||||||
|
|
@ -672,7 +720,10 @@ class _GroupProfileAddAdminState extends TIMUIKitState<GroupProfileAddAdmin> {
|
||||||
),
|
),
|
||||||
...widget.memberList
|
...widget.memberList
|
||||||
.map((e) => Container(
|
.map((e) => Container(
|
||||||
decoration: BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.white,
|
||||||
|
border:
|
||||||
|
Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ import 'package:dotted_border/dotted_border.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_member_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_member_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_group_profile_model.dart';
|
||||||
|
|
@ -87,7 +88,8 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
void navigateToMemberList(BuildContext context, TUIGroupProfileModel model, List<V2TimGroupMemberFullInfo?> memberList) {
|
void navigateToMemberList(
|
||||||
|
BuildContext context, TUIGroupProfileModel model, List<V2TimGroupMemberFullInfo?> memberList) {
|
||||||
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
if (!isDesktopScreen) {
|
if (!isDesktopScreen) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
|
|
@ -134,7 +136,10 @@ class GroupMemberTitle extends TIMUIKitStatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
padding: const EdgeInsets.only(bottom: 12),
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
decoration: isDesktopScreen ? null : BoxDecoration(border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
decoration: isDesktopScreen
|
||||||
|
? null
|
||||||
|
: BoxDecoration(
|
||||||
|
border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
navigateToMemberList(context, model, memberList);
|
navigateToMemberList(context, model, memberList);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_application.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_application.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_application.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/new_contact_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/new_contact_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_friendship_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_friendship_view_model.dart';
|
||||||
|
|
@ -13,8 +14,7 @@ import 'package:tencent_cloud_chat_uikit/ui/widgets/avatar.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme_view_model.dart';
|
||||||
|
|
||||||
typedef NewContactItemBuilder = Widget Function(
|
typedef NewContactItemBuilder = Widget Function(BuildContext context, V2TimFriendApplication applicationInfo);
|
||||||
BuildContext context, V2TimFriendApplication applicationInfo);
|
|
||||||
|
|
||||||
class TIMUIKitNewContact extends StatefulWidget {
|
class TIMUIKitNewContact extends StatefulWidget {
|
||||||
/// the callback when accept friend request
|
/// the callback when accept friend request
|
||||||
|
|
@ -33,12 +33,7 @@ class TIMUIKitNewContact extends StatefulWidget {
|
||||||
final NewContactLifeCycle? lifeCycle;
|
final NewContactLifeCycle? lifeCycle;
|
||||||
|
|
||||||
const TIMUIKitNewContact(
|
const TIMUIKitNewContact(
|
||||||
{Key? key,
|
{Key? key, this.lifeCycle, this.onAccept, this.onRefuse, this.emptyBuilder, this.itemBuilder})
|
||||||
this.lifeCycle,
|
|
||||||
this.onAccept,
|
|
||||||
this.onRefuse,
|
|
||||||
this.emptyBuilder,
|
|
||||||
this.itemBuilder})
|
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
@ -49,28 +44,22 @@ class _TIMUIKitNewContactState extends TIMUIKitState<TIMUIKitNewContact> {
|
||||||
late TUIFriendShipViewModel model = serviceLocator<TUIFriendShipViewModel>();
|
late TUIFriendShipViewModel model = serviceLocator<TUIFriendShipViewModel>();
|
||||||
|
|
||||||
_getShowName(V2TimFriendApplication item) {
|
_getShowName(V2TimFriendApplication item) {
|
||||||
return TencentUtils.checkString(item.nickname) ??
|
return TencentUtils.checkString(item.nickname) ?? TencentUtils.checkString(item.userID);
|
||||||
TencentUtils.checkString(item.userID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _itemBuilder(
|
Widget _itemBuilder(BuildContext context, V2TimFriendApplication applicationInfo) {
|
||||||
BuildContext context, V2TimFriendApplication applicationInfo) {
|
|
||||||
final theme = Provider.of<TUIThemeViewModel>(context).theme;
|
final theme = Provider.of<TUIThemeViewModel>(context).theme;
|
||||||
final showName = _getShowName(applicationInfo);
|
final showName = _getShowName(applicationInfo);
|
||||||
final faceUrl = applicationInfo.faceUrl ?? "";
|
final faceUrl = applicationInfo.faceUrl ?? "";
|
||||||
final applicationText = applicationInfo.addWording ?? "";
|
final applicationText = applicationInfo.addWording ?? "";
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
|
|
||||||
return Material(
|
return Material(
|
||||||
color: theme.wideBackgroundColor,
|
color: theme.wideBackgroundColor,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {},
|
onTap: () {},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(top: isDesktopScreen ? 6 : 10, left: 16, right: isDesktopScreen ? 16 : 0),
|
||||||
top: isDesktopScreen ? 6 : 10,
|
|
||||||
left: 16,
|
|
||||||
right: isDesktopScreen ? 16 : 0),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
|
@ -86,27 +75,19 @@ class _TIMUIKitNewContactState extends TIMUIKitState<TIMUIKitNewContact> {
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.only(top: 10, bottom: 20),
|
padding: const EdgeInsets.only(top: 10, bottom: 20),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border(
|
border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
bottom: BorderSide(
|
|
||||||
color: theme.weakDividerColor ??
|
|
||||||
CommonColor.weakDividerColor))),
|
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(top: (applicationText.isNotEmpty && isDesktopScreen) ? 10 : 0),
|
||||||
top: (applicationText.isNotEmpty && isDesktopScreen)
|
|
||||||
? 10
|
|
||||||
: 0),
|
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
showName,
|
showName,
|
||||||
style: TextStyle(
|
style: TextStyle(color: theme.darkTextColor, fontSize: isDesktopScreen ? 14 : 18),
|
||||||
color: theme.darkTextColor,
|
|
||||||
fontSize: isDesktopScreen ? 14 : 18),
|
|
||||||
),
|
),
|
||||||
if (applicationText.isNotEmpty && isDesktopScreen)
|
if (applicationText.isNotEmpty && isDesktopScreen)
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
|
@ -115,8 +96,7 @@ class _TIMUIKitNewContactState extends TIMUIKitState<TIMUIKitNewContact> {
|
||||||
if (applicationText.isNotEmpty && isDesktopScreen)
|
if (applicationText.isNotEmpty && isDesktopScreen)
|
||||||
Text(
|
Text(
|
||||||
applicationText,
|
applicationText,
|
||||||
style: TextStyle(
|
style: TextStyle(color: theme.weakTextColor, fontSize: 12),
|
||||||
color: theme.weakTextColor, fontSize: 12),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -126,15 +106,11 @@ class _TIMUIKitNewContactState extends TIMUIKitState<TIMUIKitNewContact> {
|
||||||
margin: const EdgeInsets.only(right: 8),
|
margin: const EdgeInsets.only(right: 8),
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
|
||||||
horizontal: 14, vertical: 6),
|
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
color: theme.primaryColor,
|
color: theme.primaryColor,
|
||||||
border: Border.all(
|
border: Border.all(width: 1, color: theme.weakTextColor ?? CommonColor.weakTextColor)),
|
||||||
width: 1,
|
|
||||||
color: theme.weakTextColor ??
|
|
||||||
CommonColor.weakTextColor)),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t("同意"),
|
TIM_t("同意"),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|
@ -163,12 +139,8 @@ class _TIMUIKitNewContactState extends TIMUIKitState<TIMUIKitNewContact> {
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
border: Border.all(
|
border: Border.all(width: 1, color: theme.weakTextColor ?? CommonColor.weakTextColor)),
|
||||||
width: 1,
|
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 6),
|
||||||
color: theme.weakTextColor ??
|
|
||||||
CommonColor.weakTextColor)),
|
|
||||||
padding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 14, vertical: 6),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t("拒绝"),
|
TIM_t("拒绝"),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
|
|
||||||
enum ProfileWidgetEnum {
|
enum ProfileWidgetEnum {
|
||||||
/// THe card shows the user info of a specific user.
|
/// THe card shows the user info of a specific user.
|
||||||
|
|
@ -85,13 +88,11 @@ class ProfileWidgetBuilder {
|
||||||
|
|
||||||
/// The switch of if add another user to block list.
|
/// The switch of if add another user to block list.
|
||||||
/// This will not shows when friendship relation not exist as default.
|
/// This will not shows when friendship relation not exist as default.
|
||||||
Widget Function(bool isAsBlocked, Function(bool value)? onChange)?
|
Widget Function(bool isAsBlocked, Function(bool value)? onChange)? addToBlockListBar;
|
||||||
addToBlockListBar;
|
|
||||||
|
|
||||||
/// The switch of if pin the one-to-one conversation to the top of the conversation list.
|
/// The switch of if pin the one-to-one conversation to the top of the conversation list.
|
||||||
/// This will not shows when friendship relation not exist as default.
|
/// This will not shows when friendship relation not exist as default.
|
||||||
Widget Function(bool isPinned, Function(bool value)? onChange)?
|
Widget Function(bool isPinned, Function(bool value)? onChange)? pinConversationBar;
|
||||||
pinConversationBar;
|
|
||||||
|
|
||||||
/// The switch of if mute the message notification from a specific user.
|
/// The switch of if mute the message notification from a specific user.
|
||||||
/// This will not shows when friendship relation not exist as default.
|
/// This will not shows when friendship relation not exist as default.
|
||||||
|
|
@ -136,28 +137,23 @@ class ProfileWidgetBuilder {
|
||||||
/// The area shows the buttons,
|
/// The area shows the buttons,
|
||||||
/// contains "Send message", "Voice/Video Call", "Delete friend" when has the friend relationship,
|
/// contains "Send message", "Voice/Video Call", "Delete friend" when has the friend relationship,
|
||||||
/// while contains "Add friend" when no relationship exists, as default.
|
/// while contains "Add friend" when no relationship exists, as default.
|
||||||
Widget Function(V2TimFriendInfo friendInfo, V2TimConversation conversation,
|
Widget Function(V2TimFriendInfo friendInfo, V2TimConversation conversation, int friendType, bool isDisturb)?
|
||||||
int friendType, bool isDisturb)? addAndDeleteArea;
|
addAndDeleteArea;
|
||||||
|
|
||||||
/// Custom area, you may define send message, make calling, search or anything you want here.
|
/// Custom area, you may define send message, make calling, search or anything you want here.
|
||||||
Widget Function(bool isFriend, V2TimFriendInfo friendInfo,
|
Widget Function(bool isFriend, V2TimFriendInfo friendInfo, V2TimConversation conversation)? customBuilderOne;
|
||||||
V2TimConversation conversation)? customBuilderOne;
|
|
||||||
|
|
||||||
/// Custom area, you may define send message, make calling, search or anything you want here.
|
/// Custom area, you may define send message, make calling, search or anything you want here.
|
||||||
Widget Function(bool isFriend, V2TimFriendInfo friendInfo,
|
Widget Function(bool isFriend, V2TimFriendInfo friendInfo, V2TimConversation conversation)? customBuilderTwo;
|
||||||
V2TimConversation conversation)? customBuilderTwo;
|
|
||||||
|
|
||||||
/// Custom area, you may define send message, make calling, search or anything you want here.
|
/// Custom area, you may define send message, make calling, search or anything you want here.
|
||||||
Widget Function(bool isFriend, V2TimFriendInfo friendInfo,
|
Widget Function(bool isFriend, V2TimFriendInfo friendInfo, V2TimConversation conversation)? customBuilderThree;
|
||||||
V2TimConversation conversation)? customBuilderThree;
|
|
||||||
|
|
||||||
/// Custom area, you may define send message, make calling, search or anything you want here.
|
/// Custom area, you may define send message, make calling, search or anything you want here.
|
||||||
Widget Function(bool isFriend, V2TimFriendInfo friendInfo,
|
Widget Function(bool isFriend, V2TimFriendInfo friendInfo, V2TimConversation conversation)? customBuilderFour;
|
||||||
V2TimConversation conversation)? customBuilderFour;
|
|
||||||
|
|
||||||
/// Custom area, you may define send message, make calling, search or anything you want here.
|
/// Custom area, you may define send message, make calling, search or anything you want here.
|
||||||
Widget Function(bool isFriend, V2TimFriendInfo friendInfo,
|
Widget Function(bool isFriend, V2TimFriendInfo friendInfo, V2TimConversation conversation)? customBuilderFive;
|
||||||
V2TimConversation conversation)? customBuilderFive;
|
|
||||||
|
|
||||||
ProfileWidgetBuilder(
|
ProfileWidgetBuilder(
|
||||||
{this.operationDivider,
|
{this.operationDivider,
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,12 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
import 'package:loading_animation_widget/loading_animation_widget.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/profile_life_cycle.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/profile_life_cycle.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_profile_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/separate_models/tui_profile_view_model.dart';
|
||||||
|
|
@ -19,11 +22,7 @@ import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitProfile/widget/tim_uik
|
||||||
typedef OnSelfAvatarTap = void Function();
|
typedef OnSelfAvatarTap = void Function();
|
||||||
|
|
||||||
typedef ProfileBuilder = Widget Function(
|
typedef ProfileBuilder = Widget Function(
|
||||||
BuildContext context,
|
BuildContext context, V2TimFriendInfo userInfo, V2TimConversation conversation, int friendType, bool isMute);
|
||||||
V2TimFriendInfo userInfo,
|
|
||||||
V2TimConversation conversation,
|
|
||||||
int friendType,
|
|
||||||
bool isMute);
|
|
||||||
|
|
||||||
class TIMUIKitProfile extends StatefulWidget {
|
class TIMUIKitProfile extends StatefulWidget {
|
||||||
/// user ID
|
/// user ID
|
||||||
|
|
@ -31,23 +30,19 @@ class TIMUIKitProfile extends StatefulWidget {
|
||||||
|
|
||||||
/// [Deprecated:] the builder for custom operation list.
|
/// [Deprecated:] the builder for custom operation list.
|
||||||
/// [operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead.
|
/// [operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead.
|
||||||
final Widget Function(
|
final Widget Function(BuildContext context, V2TimFriendInfo friendInfo, V2TimConversation conversation,
|
||||||
BuildContext context,
|
int friendType, bool isMute)? operationListBuilder;
|
||||||
V2TimFriendInfo friendInfo,
|
|
||||||
V2TimConversation conversation,
|
|
||||||
int friendType,
|
|
||||||
bool isMute)? operationListBuilder;
|
|
||||||
|
|
||||||
/// [Deprecated:] The builder for custom bottom operation area.
|
/// [Deprecated:] The builder for custom bottom operation area.
|
||||||
/// [operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead.
|
/// [operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead.
|
||||||
final Widget Function(BuildContext context, V2TimFriendInfo? friendInfo,
|
final Widget Function(
|
||||||
V2TimConversation? conversation, int friendType)? bottomOperationBuilder;
|
BuildContext context, V2TimFriendInfo? friendInfo, V2TimConversation? conversation, int friendType)?
|
||||||
|
bottomOperationBuilder;
|
||||||
|
|
||||||
/// [Deprecated:] Callback when clicking profile detail card.
|
/// [Deprecated:] Callback when clicking profile detail card.
|
||||||
/// This widget will no longer shows the personal info card and can not jump to personal info page automatically,
|
/// This widget will no longer shows the personal info card and can not jump to personal info page automatically,
|
||||||
/// please navigate to your custom personal info page manually and directly, you may refer to our demo.
|
/// please navigate to your custom personal info page manually and directly, you may refer to our demo.
|
||||||
final void Function(BuildContext context, V2TimUserFullInfo? userFullInfo)?
|
final void Function(BuildContext context, V2TimUserFullInfo? userFullInfo)? handleProfileDetailCardTap;
|
||||||
handleProfileDetailCardTap;
|
|
||||||
|
|
||||||
/// Profile Controller
|
/// Profile Controller
|
||||||
final TIMUIKitProfileController? controller;
|
final TIMUIKitProfileController? controller;
|
||||||
|
|
@ -90,11 +85,9 @@ class TIMUIKitProfile extends StatefulWidget {
|
||||||
const TIMUIKitProfile(
|
const TIMUIKitProfile(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
required this.userID,
|
required this.userID,
|
||||||
@Deprecated(
|
@Deprecated("[operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead")
|
||||||
"[operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead")
|
|
||||||
this.operationListBuilder,
|
this.operationListBuilder,
|
||||||
@Deprecated(
|
@Deprecated("[operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead")
|
||||||
"[operationListBuilder] and [bottomOperationBuilder] merged into [builder], please use it instead")
|
|
||||||
this.bottomOperationBuilder,
|
this.bottomOperationBuilder,
|
||||||
@Deprecated(
|
@Deprecated(
|
||||||
"This widget will no longer shows the personal info card and can not jump to personal info page automatically, please navigate to your custom personal info page manually and directly, you may refer to our demo")
|
"This widget will no longer shows the personal info card and can not jump to personal info page automatically, please navigate to your custom personal info page manually and directly, you may refer to our demo")
|
||||||
|
|
@ -139,11 +132,9 @@ class _TIMUIKitProfileState extends TIMUIKitState<TIMUIKitProfile> {
|
||||||
@override
|
@override
|
||||||
void didUpdateWidget(covariant TIMUIKitProfile oldWidget) {
|
void didUpdateWidget(covariant TIMUIKitProfile oldWidget) {
|
||||||
super.didUpdateWidget(oldWidget);
|
super.didUpdateWidget(oldWidget);
|
||||||
if (oldWidget.userID != widget.userID ||
|
if (oldWidget.userID != widget.userID || _model.userProfile?.friendInfo?.userID != widget.userID) {
|
||||||
_model.userProfile?.friendInfo?.userID != widget.userID) {
|
|
||||||
_model.userProfile = null;
|
_model.userProfile = null;
|
||||||
_model.loadData(
|
_model.loadData(userID: widget.userID, isNeedConversation: !widget.isSelf);
|
||||||
userID: widget.userID, isNeedConversation: !widget.isSelf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,14 +153,12 @@ class _TIMUIKitProfileState extends TIMUIKitState<TIMUIKitProfile> {
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
final theme = value.theme;
|
final theme = value.theme;
|
||||||
final isDesktopScreen =
|
final isDesktopScreen = TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor(context) == DeviceType.Desktop;
|
|
||||||
return ChangeNotifierProvider.value(
|
return ChangeNotifierProvider.value(
|
||||||
value: _model,
|
value: _model,
|
||||||
child: Consumer<TUIProfileViewModel>(
|
child: Consumer<TUIProfileViewModel>(
|
||||||
builder: (context, value, child) {
|
builder: (context, value, child) {
|
||||||
final TUIProfileViewModel model =
|
final TUIProfileViewModel model = Provider.of<TUIProfileViewModel>(context);
|
||||||
Provider.of<TUIProfileViewModel>(context);
|
|
||||||
_controller.model = model;
|
_controller.model = model;
|
||||||
final V2TimFriendInfo? userInfo = model.userProfile?.friendInfo;
|
final V2TimFriendInfo? userInfo = model.userProfile?.friendInfo;
|
||||||
|
|
||||||
|
|
@ -188,25 +177,20 @@ class _TIMUIKitProfileState extends TIMUIKitState<TIMUIKitProfile> {
|
||||||
type: 1,
|
type: 1,
|
||||||
userID: widget.userID,
|
userID: widget.userID,
|
||||||
faceUrl: model.userProfile?.friendInfo?.userProfile?.faceUrl,
|
faceUrl: model.userProfile?.friendInfo?.userProfile?.faceUrl,
|
||||||
showName: TencentUtils.checkString(
|
showName: TencentUtils.checkString(model.userProfile?.friendInfo?.friendRemark) ??
|
||||||
model.userProfile?.friendInfo?.friendRemark) ??
|
TencentUtils.checkString(model.userProfile?.friendInfo?.userProfile?.nickName) ??
|
||||||
TencentUtils.checkString(model
|
|
||||||
.userProfile?.friendInfo?.userProfile?.nickName) ??
|
|
||||||
widget.userID);
|
widget.userID);
|
||||||
final TUISelfInfoViewModel _selfInfoViewModel =
|
final TUISelfInfoViewModel _selfInfoViewModel = serviceLocator<TUISelfInfoViewModel>();
|
||||||
serviceLocator<TUISelfInfoViewModel>();
|
|
||||||
|
|
||||||
final isFriend = model.friendType != 0;
|
final isFriend = model.friendType != 0;
|
||||||
final isSelf = (model.userProfile?.friendInfo?.userID ==
|
final isSelf = (model.userProfile?.friendInfo?.userID == _selfInfoViewModel.loginInfo?.userID);
|
||||||
_selfInfoViewModel.loginInfo?.userID);
|
|
||||||
final isMute = model.isDisturb ?? false;
|
final isMute = model.isDisturb ?? false;
|
||||||
|
|
||||||
Widget profilePage({required Widget child}) {
|
Widget profilePage({required Widget child}) {
|
||||||
return Container(
|
return Container(
|
||||||
color: isDesktopScreen ? theme.wideBackgroundColor : null,
|
color: isDesktopScreen ? theme.wideBackgroundColor : null,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
physics: const BouncingScrollPhysics(
|
physics: const BouncingScrollPhysics(parent: AlwaysScrollableScrollPhysics()),
|
||||||
parent: AlwaysScrollableScrollPhysics()),
|
|
||||||
child: Container(
|
child: Container(
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
|
|
@ -234,8 +218,7 @@ class _TIMUIKitProfileState extends TIMUIKitState<TIMUIKitProfile> {
|
||||||
title: TIM_t("修改备注名"),
|
title: TIM_t("修改备注名"),
|
||||||
tips: TIM_t("仅限汉字、英文、数字和下划线"),
|
tips: TIM_t("仅限汉字、英文、数字和下划线"),
|
||||||
onSubmitted: (String remark) async {
|
onSubmitted: (String remark) async {
|
||||||
final res =
|
final res = await _controller.updateRemarks(widget.userID, remark);
|
||||||
await _controller.updateRemarks(widget.userID, remark);
|
|
||||||
if (res.code == 0) {
|
if (res.code == 0) {
|
||||||
widget.lifeCycle?.didRemarkUpdated(remark);
|
widget.lifeCycle?.didRemarkUpdated(remark);
|
||||||
}
|
}
|
||||||
|
|
@ -255,47 +238,37 @@ class _TIMUIKitProfileState extends TIMUIKitState<TIMUIKitProfile> {
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Widget> _renderWidgetsWithOrder(List<ProfileWidgetEnum> order) {
|
List<Widget> _renderWidgetsWithOrder(List<ProfileWidgetEnum> order) {
|
||||||
final ProfileWidgetBuilder? customBuilder =
|
final ProfileWidgetBuilder? customBuilder = widget.profileWidgetBuilder;
|
||||||
widget.profileWidgetBuilder;
|
|
||||||
return order.map((element) {
|
return order.map((element) {
|
||||||
switch (element) {
|
switch (element) {
|
||||||
case ProfileWidgetEnum.userInfoCard:
|
case ProfileWidgetEnum.userInfoCard:
|
||||||
return (customBuilder?.userInfoCard != null
|
return (customBuilder?.userInfoCard != null
|
||||||
? customBuilder?.userInfoCard!(userInfo.userProfile)
|
? customBuilder?.userInfoCard!(userInfo.userProfile)
|
||||||
: TIMUIKitProfileUserInfoCard(
|
: TIMUIKitProfileUserInfoCard(userInfo: userInfo.userProfile))!;
|
||||||
userInfo: userInfo.userProfile))!;
|
|
||||||
case ProfileWidgetEnum.addToBlockListBar:
|
case ProfileWidgetEnum.addToBlockListBar:
|
||||||
if (isSelf) {
|
if (isSelf) {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
return (customBuilder?.addToBlockListBar != null
|
return (customBuilder?.addToBlockListBar != null
|
||||||
? customBuilder?.addToBlockListBar!(
|
? customBuilder?.addToBlockListBar!(model.isAddToBlackList ?? false, handleAddToBlockList)
|
||||||
model.isAddToBlackList ?? false, handleAddToBlockList)
|
|
||||||
: TIMUIKitProfileWidget.addToBlackListBar(
|
: TIMUIKitProfileWidget.addToBlackListBar(
|
||||||
model.isAddToBlackList ?? false,
|
model.isAddToBlackList ?? false, context, handleAddToBlockList, widget.smallCardMode))!;
|
||||||
context,
|
|
||||||
handleAddToBlockList,
|
|
||||||
widget.smallCardMode))!;
|
|
||||||
case ProfileWidgetEnum.pinConversationBar:
|
case ProfileWidgetEnum.pinConversationBar:
|
||||||
// if (!isFriend) {
|
// if (!isFriend) {
|
||||||
// return Container();
|
// return Container();
|
||||||
// }
|
// }
|
||||||
return (customBuilder?.pinConversationBar != null
|
return (customBuilder?.pinConversationBar != null
|
||||||
? customBuilder?.pinConversationBar!(
|
? customBuilder?.pinConversationBar!(conversation.isPinned ?? false, handlePinConversation)
|
||||||
conversation.isPinned ?? false, handlePinConversation)
|
|
||||||
: TIMUIKitProfileWidget.pinConversationBar(
|
: TIMUIKitProfileWidget.pinConversationBar(
|
||||||
conversation.isPinned ?? false,
|
conversation.isPinned ?? false, context, handlePinConversation, widget.smallCardMode))!;
|
||||||
context,
|
|
||||||
handlePinConversation,
|
|
||||||
widget.smallCardMode))!;
|
|
||||||
case ProfileWidgetEnum.messageMute:
|
case ProfileWidgetEnum.messageMute:
|
||||||
// if (!isFriend) {
|
// if (!isFriend) {
|
||||||
// return Container();
|
// return Container();
|
||||||
// }
|
// }
|
||||||
return (customBuilder?.messageMute != null
|
return (customBuilder?.messageMute != null
|
||||||
? customBuilder?.messageMute!(isMute, handleMuteMessage)
|
? customBuilder?.messageMute!(isMute, handleMuteMessage)
|
||||||
: TIMUIKitProfileWidget.messageDisturb(context, isMute,
|
: TIMUIKitProfileWidget.messageDisturb(
|
||||||
handleMuteMessage, widget.smallCardMode))!;
|
context, isMute, handleMuteMessage, widget.smallCardMode))!;
|
||||||
case ProfileWidgetEnum.searchBar:
|
case ProfileWidgetEnum.searchBar:
|
||||||
return (customBuilder?.searchBar != null
|
return (customBuilder?.searchBar != null
|
||||||
? customBuilder?.searchBar!(conversation)
|
? customBuilder?.searchBar!(conversation)
|
||||||
|
|
@ -305,44 +278,30 @@ class _TIMUIKitProfileState extends TIMUIKitState<TIMUIKitProfile> {
|
||||||
return (customBuilder?.portraitBar != null
|
return (customBuilder?.portraitBar != null
|
||||||
? customBuilder?.portraitBar!(userInfo.userProfile)
|
? customBuilder?.portraitBar!(userInfo.userProfile)
|
||||||
: TIMUIKitProfileWidget.portraitBar(
|
: TIMUIKitProfileWidget.portraitBar(
|
||||||
TIMUIKitProfileWidget.defaultPortraitWidget(
|
TIMUIKitProfileWidget.defaultPortraitWidget(userInfo.userProfile, widget.smallCardMode),
|
||||||
userInfo.userProfile, widget.smallCardMode),
|
|
||||||
widget.smallCardMode))!;
|
widget.smallCardMode))!;
|
||||||
case ProfileWidgetEnum.nicknameBar:
|
case ProfileWidgetEnum.nicknameBar:
|
||||||
return (customBuilder?.nicknameBar != null
|
return (customBuilder?.nicknameBar != null
|
||||||
? customBuilder
|
? customBuilder?.nicknameBar!(userInfo.userProfile?.nickName ?? "")
|
||||||
?.nicknameBar!(userInfo.userProfile?.nickName ?? "")
|
: TIMUIKitProfileWidget.nicknameBar(userInfo.userProfile?.nickName ?? "", widget.smallCardMode))!;
|
||||||
: TIMUIKitProfileWidget.nicknameBar(
|
|
||||||
userInfo.userProfile?.nickName ?? "",
|
|
||||||
widget.smallCardMode))!;
|
|
||||||
case ProfileWidgetEnum.userAccountBar:
|
case ProfileWidgetEnum.userAccountBar:
|
||||||
return (customBuilder?.userAccountBar != null
|
return (customBuilder?.userAccountBar != null
|
||||||
? customBuilder
|
? customBuilder?.userAccountBar!(userInfo.userProfile?.userID ?? "")
|
||||||
?.userAccountBar!(userInfo.userProfile?.userID ?? "")
|
|
||||||
: TIMUIKitProfileWidget.userAccountBar(
|
: TIMUIKitProfileWidget.userAccountBar(
|
||||||
userInfo.userProfile?.userID ?? "",
|
userInfo.userProfile?.userID ?? "", widget.smallCardMode))!;
|
||||||
widget.smallCardMode))!;
|
|
||||||
case ProfileWidgetEnum.signatureBar:
|
case ProfileWidgetEnum.signatureBar:
|
||||||
return (customBuilder?.signatureBar != null
|
return (customBuilder?.signatureBar != null
|
||||||
? customBuilder?.signatureBar!(
|
? customBuilder?.signatureBar!(userInfo.userProfile?.selfSignature ?? "")
|
||||||
userInfo.userProfile?.selfSignature ?? "")
|
|
||||||
: TIMUIKitProfileWidget.signatureBar(
|
: TIMUIKitProfileWidget.signatureBar(
|
||||||
userInfo.userProfile?.selfSignature ?? "",
|
userInfo.userProfile?.selfSignature ?? "", widget.smallCardMode))!;
|
||||||
widget.smallCardMode))!;
|
|
||||||
case ProfileWidgetEnum.genderBar:
|
case ProfileWidgetEnum.genderBar:
|
||||||
return (customBuilder?.genderBar != null
|
return (customBuilder?.genderBar != null
|
||||||
? customBuilder
|
? customBuilder?.genderBar!(userInfo.userProfile?.gender ?? 0)
|
||||||
?.genderBar!(userInfo.userProfile?.gender ?? 0)
|
: TIMUIKitProfileWidget.genderBar(userInfo.userProfile?.gender ?? 0, widget.smallCardMode))!;
|
||||||
: TIMUIKitProfileWidget.genderBar(
|
|
||||||
userInfo.userProfile?.gender ?? 0,
|
|
||||||
widget.smallCardMode))!;
|
|
||||||
case ProfileWidgetEnum.birthdayBar:
|
case ProfileWidgetEnum.birthdayBar:
|
||||||
return (customBuilder?.birthdayBar != null
|
return (customBuilder?.birthdayBar != null
|
||||||
? customBuilder
|
? customBuilder?.birthdayBar!(userInfo.userProfile?.birthday)
|
||||||
?.birthdayBar!(userInfo.userProfile?.birthday)
|
: TIMUIKitProfileWidget.birthdayBar(userInfo.userProfile?.birthday, widget.smallCardMode))!;
|
||||||
: TIMUIKitProfileWidget.birthdayBar(
|
|
||||||
userInfo.userProfile?.birthday,
|
|
||||||
widget.smallCardMode))!;
|
|
||||||
case ProfileWidgetEnum.addAndDeleteArea:
|
case ProfileWidgetEnum.addAndDeleteArea:
|
||||||
if (isSelf) {
|
if (isSelf) {
|
||||||
return Container();
|
return Container();
|
||||||
|
|
@ -381,50 +340,39 @@ class _TIMUIKitProfileState extends TIMUIKitState<TIMUIKitProfile> {
|
||||||
: TIMUIKitProfileWidget.operationDivider(
|
: TIMUIKitProfileWidget.operationDivider(
|
||||||
color: theme.weakDividerColor,
|
color: theme.weakDividerColor,
|
||||||
height: isDesktopScreen ? 1 : 10,
|
height: isDesktopScreen ? 1 : 10,
|
||||||
margin: isDesktopScreen
|
margin:
|
||||||
? EdgeInsets.symmetric(
|
isDesktopScreen ? EdgeInsets.symmetric(vertical: widget.smallCardMode ? 4 : 20) : null))!;
|
||||||
vertical: widget.smallCardMode ? 4 : 20)
|
|
||||||
: null))!;
|
|
||||||
case ProfileWidgetEnum.remarkBar:
|
case ProfileWidgetEnum.remarkBar:
|
||||||
if (!isFriend) {
|
if (!isFriend) {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
return (customBuilder?.remarkBar != null
|
return (customBuilder?.remarkBar != null
|
||||||
? customBuilder?.remarkBar!(
|
? customBuilder?.remarkBar!(userInfo.friendRemark ?? "", handleTapRemarkBar)
|
||||||
userInfo.friendRemark ?? "", handleTapRemarkBar)
|
|
||||||
: TIMUIKitProfileWidget.remarkBar(
|
: TIMUIKitProfileWidget.remarkBar(
|
||||||
context,
|
context, userInfo.friendRemark ?? "", handleTapRemarkBar, widget.smallCardMode))!;
|
||||||
userInfo.friendRemark ?? "",
|
|
||||||
handleTapRemarkBar,
|
|
||||||
widget.smallCardMode))!;
|
|
||||||
case ProfileWidgetEnum.customBuilderOne:
|
case ProfileWidgetEnum.customBuilderOne:
|
||||||
return (customBuilder?.customBuilderOne != null
|
return (customBuilder?.customBuilderOne != null
|
||||||
? customBuilder?.customBuilderOne!(
|
? customBuilder?.customBuilderOne!(isFriend, userInfo, conversation)
|
||||||
isFriend, userInfo, conversation)
|
|
||||||
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
||||||
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
||||||
case ProfileWidgetEnum.customBuilderTwo:
|
case ProfileWidgetEnum.customBuilderTwo:
|
||||||
return (customBuilder?.customBuilderTwo != null
|
return (customBuilder?.customBuilderTwo != null
|
||||||
? customBuilder?.customBuilderTwo!(
|
? customBuilder?.customBuilderTwo!(isFriend, userInfo, conversation)
|
||||||
isFriend, userInfo, conversation)
|
|
||||||
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
||||||
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
||||||
case ProfileWidgetEnum.customBuilderThree:
|
case ProfileWidgetEnum.customBuilderThree:
|
||||||
return (customBuilder?.customBuilderThree != null
|
return (customBuilder?.customBuilderThree != null
|
||||||
? customBuilder?.customBuilderThree!(
|
? customBuilder?.customBuilderThree!(isFriend, userInfo, conversation)
|
||||||
isFriend, userInfo, conversation)
|
|
||||||
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
||||||
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
||||||
case ProfileWidgetEnum.customBuilderFour:
|
case ProfileWidgetEnum.customBuilderFour:
|
||||||
return (customBuilder?.customBuilderFour != null
|
return (customBuilder?.customBuilderFour != null
|
||||||
? customBuilder?.customBuilderFour!(
|
? customBuilder?.customBuilderFour!(isFriend, userInfo, conversation)
|
||||||
isFriend, userInfo, conversation)
|
|
||||||
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
||||||
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
||||||
case ProfileWidgetEnum.customBuilderFive:
|
case ProfileWidgetEnum.customBuilderFive:
|
||||||
return (customBuilder?.customBuilderFive != null
|
return (customBuilder?.customBuilderFive != null
|
||||||
? customBuilder?.customBuilderFive!(
|
? customBuilder?.customBuilderFive!(isFriend, userInfo, conversation)
|
||||||
isFriend, userInfo, conversation)
|
|
||||||
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
// Please define the corresponding custom widget in `profileWidgetBuilder` before using it here.
|
||||||
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
: Text(TIM_t("如使用自定义区域,请在profileWidgetBuilder传入对应组件")))!;
|
||||||
|
|
||||||
|
|
@ -435,14 +383,11 @@ class _TIMUIKitProfileState extends TIMUIKitState<TIMUIKitProfile> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.builder != null) {
|
if (widget.builder != null) {
|
||||||
return widget.builder!(
|
return widget.builder!(context, userInfo, conversation, value.friendType, isMute);
|
||||||
context, userInfo, conversation, value.friendType, isMute);
|
|
||||||
} else if (widget.profileWidgetsOrder != null) {
|
} else if (widget.profileWidgetsOrder != null) {
|
||||||
return profilePage(
|
return profilePage(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [..._renderWidgetsWithOrder(widget.profileWidgetsOrder!)],
|
||||||
..._renderWidgetsWithOrder(widget.profileWidgetsOrder!)
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
// ignore_for_file: deprecated_member_use_from_same_package
|
// ignore_for_file: deprecated_member_use_from_same_package
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitProfile/widget/tim_uikit_profile_userinfo_card/tim_uikit_profile_userinfo_card_narrow.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitProfile/widget/tim_uikit_profile_userinfo_card/tim_uikit_profile_userinfo_card_narrow.dart';
|
||||||
|
|
@ -19,8 +20,9 @@ class TIMUIKitProfileUserInfoCard extends StatelessWidget {
|
||||||
const TIMUIKitProfileUserInfoCard(
|
const TIMUIKitProfileUserInfoCard(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
this.userInfo,
|
this.userInfo,
|
||||||
@Deprecated("This info card can no longer navigate to default personal profile page automatically, please deal with it manually.")
|
@Deprecated(
|
||||||
this.isJumpToPersonalProfile = false,
|
"This info card can no longer navigate to default personal profile page automatically, please deal with it manually.")
|
||||||
|
this.isJumpToPersonalProfile = false,
|
||||||
this.showArrowRightIcon = false,
|
this.showArrowRightIcon = false,
|
||||||
this.onClickAvatar})
|
this.onClickAvatar})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/widgets/avatar.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/widgets/avatar.dart';
|
||||||
|
|
@ -19,8 +20,9 @@ class TIMUIKitProfileUserInfoCardNarrow extends TIMUIKitStatelessWidget {
|
||||||
{Key? key,
|
{Key? key,
|
||||||
this.onClickAvatar,
|
this.onClickAvatar,
|
||||||
this.userInfo,
|
this.userInfo,
|
||||||
@Deprecated("This info card can no longer navigate to default personal profile page automatically, please deal with it manually.")
|
@Deprecated(
|
||||||
this.isJumpToPersonalProfile = false,
|
"This info card can no longer navigate to default personal profile page automatically, please deal with it manually.")
|
||||||
|
this.isJumpToPersonalProfile = false,
|
||||||
this.showArrowRightIcon = false})
|
this.showArrowRightIcon = false})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
|
|
@ -32,9 +34,8 @@ class TIMUIKitProfileUserInfoCardNarrow extends TIMUIKitStatelessWidget {
|
||||||
final signature = userInfo?.selfSignature;
|
final signature = userInfo?.selfSignature;
|
||||||
final showName = nickName != "" ? nickName : userInfo?.userID;
|
final showName = nickName != "" ? nickName : userInfo?.userID;
|
||||||
final option1 = signature;
|
final option1 = signature;
|
||||||
final signatureText = option1 != null
|
final signatureText =
|
||||||
? TIM_t_para("个性签名: {{option1}}", "个性签名: $option1")(option1: option1)
|
option1 != null ? TIM_t_para("个性签名: {{option1}}", "个性签名: $option1")(option1: option1) : TIM_t("暂无个性签名");
|
||||||
: TIM_t("暂无个性签名");
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 16),
|
||||||
|
|
@ -76,25 +77,20 @@ class TIMUIKitProfileUserInfoCardNarrow extends TIMUIKitStatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"ID: ",
|
"ID: ",
|
||||||
style:
|
style: TextStyle(fontSize: 13, color: theme.weakTextColor),
|
||||||
TextStyle(fontSize: 13, color: theme.weakTextColor),
|
|
||||||
),
|
),
|
||||||
SelectableText(
|
SelectableText(
|
||||||
userInfo?.userID ?? "",
|
userInfo?.userID ?? "",
|
||||||
style:
|
style: TextStyle(fontSize: 13, color: theme.weakTextColor),
|
||||||
TextStyle(fontSize: 13, color: theme.weakTextColor),
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SelectableText(signatureText,
|
SelectableText(signatureText, style: TextStyle(fontSize: 13, color: theme.weakTextColor))
|
||||||
style: TextStyle(fontSize: 13, color: theme.weakTextColor))
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
showArrowRightIcon
|
showArrowRightIcon ? const Icon(Icons.keyboard_arrow_right) : Container()
|
||||||
? const Icon(Icons.keyboard_arrow_right)
|
|
||||||
: Container()
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_base.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/widgets/avatar.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/widgets/avatar.dart';
|
||||||
|
|
@ -19,8 +20,9 @@ class TIMUIKitProfileUserInfoCardWide extends TIMUIKitStatelessWidget {
|
||||||
{Key? key,
|
{Key? key,
|
||||||
this.userInfo,
|
this.userInfo,
|
||||||
this.onClickAvatar,
|
this.onClickAvatar,
|
||||||
@Deprecated("This info card can no longer navigate to default personal profile page automatically, please deal with it manually.")
|
@Deprecated(
|
||||||
this.isJumpToPersonalProfile = false,
|
"This info card can no longer navigate to default personal profile page automatically, please deal with it manually.")
|
||||||
|
this.isJumpToPersonalProfile = false,
|
||||||
this.showArrowRightIcon = false})
|
this.showArrowRightIcon = false})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
|
|
@ -55,22 +57,19 @@ class TIMUIKitProfileUserInfoCardWide extends TIMUIKitStatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"ID: ",
|
"ID: ",
|
||||||
style:
|
style: TextStyle(fontSize: 12, color: theme.weakTextColor),
|
||||||
TextStyle(fontSize: 12, color: theme.weakTextColor),
|
|
||||||
),
|
),
|
||||||
Expanded(child: SelectableText(
|
Expanded(
|
||||||
|
child: SelectableText(
|
||||||
userInfo?.userID ?? "",
|
userInfo?.userID ?? "",
|
||||||
style:
|
style: TextStyle(fontSize: 12, color: theme.weakTextColor),
|
||||||
TextStyle(fontSize: 12, color: theme.weakTextColor),
|
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
if (signature != null)
|
if (signature != null)
|
||||||
Container(
|
Container(
|
||||||
margin: const EdgeInsets.only(top: 18),
|
margin: const EdgeInsets.only(top: 18),
|
||||||
child: SelectableText(signature,
|
child: SelectableText(signature, style: TextStyle(fontSize: 14, color: hexToColor("7f7f7f"))),
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 14, color: hexToColor("7f7f7f"))),
|
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
@ -93,9 +92,7 @@ class TIMUIKitProfileUserInfoCardWide extends TIMUIKitStatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
showArrowRightIcon
|
showArrowRightIcon ? const Icon(Icons.keyboard_arrow_right) : Container()
|
||||||
? const Icon(Icons.keyboard_arrow_right)
|
|
||||||
: Container()
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,12 @@ import 'dart:math';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_user_full_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_user_full_info.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_class.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_class.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/utils/screen_utils.dart';
|
||||||
|
|
@ -14,11 +17,9 @@ import 'package:tencent_cloud_chat_uikit/theme/color.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
import 'package:tencent_cloud_chat_uikit/theme/tui_theme.dart';
|
||||||
|
|
||||||
class TIMUIKitProfileWidget extends TIMUIKitClass {
|
class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
static final bool isDesktopScreen =
|
static final bool isDesktopScreen = TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop;
|
||||||
TUIKitScreenUtils.getFormFactor() == DeviceType.Desktop;
|
|
||||||
|
|
||||||
static Widget operationDivider(
|
static Widget operationDivider({Color? color, double? height, EdgeInsetsGeometry? margin}) {
|
||||||
{Color? color, double? height, EdgeInsetsGeometry? margin}) {
|
|
||||||
return Container(
|
return Container(
|
||||||
color: color,
|
color: color,
|
||||||
margin: margin,
|
margin: margin,
|
||||||
|
|
@ -27,21 +28,15 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remarks
|
/// Remarks
|
||||||
static Widget remarkBar(
|
static Widget remarkBar(BuildContext context, String remark, Function({Offset? offset, String? initText})? handleTap,
|
||||||
BuildContext context,
|
|
||||||
String remark,
|
|
||||||
Function({Offset? offset, String? initText})? handleTap,
|
|
||||||
bool smallCardMode) {
|
bool smallCardMode) {
|
||||||
final GlobalKey key = GlobalKey();
|
final GlobalKey key = GlobalKey();
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTapDown: (details) {
|
onTapDown: (details) {
|
||||||
if (handleTap != null) {
|
if (handleTap != null) {
|
||||||
handleTap(
|
handleTap(
|
||||||
offset: Offset(
|
offset: Offset(min(details.globalPosition.dx, MediaQuery.of(context).size.width - 400),
|
||||||
min(details.globalPosition.dx,
|
min(details.globalPosition.dy, MediaQuery.of(context).size.height - 100)),
|
||||||
MediaQuery.of(context).size.width - 400),
|
|
||||||
min(details.globalPosition.dy,
|
|
||||||
MediaQuery.of(context).size.height - 100)),
|
|
||||||
initText: remark);
|
initText: remark);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -51,15 +46,14 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
isEmpty: remark.isEmpty,
|
isEmpty: remark.isEmpty,
|
||||||
wideEditText: TIM_t("设置备注名"),
|
wideEditText: TIM_t("设置备注名"),
|
||||||
operationName: TIM_t("备注名"),
|
operationName: TIM_t("备注名"),
|
||||||
operationRightWidget:
|
operationRightWidget: Text(remark, textAlign: isDesktopScreen ? null : TextAlign.end),
|
||||||
Text(remark, textAlign: isDesktopScreen ? null : TextAlign.end),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// add to block list
|
/// add to block list
|
||||||
static Widget addToBlackListBar(bool value, BuildContext context,
|
static Widget addToBlackListBar(
|
||||||
Function(bool value)? onChanged, bool smallCardMode) {
|
bool value, BuildContext context, Function(bool value)? onChanged, bool smallCardMode) {
|
||||||
return TIMUIKitOperationItem(
|
return TIMUIKitOperationItem(
|
||||||
smallCardMode: smallCardMode,
|
smallCardMode: smallCardMode,
|
||||||
isEmpty: false,
|
isEmpty: false,
|
||||||
|
|
@ -75,8 +69,8 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// pin the conversation to the top
|
/// pin the conversation to the top
|
||||||
static Widget pinConversationBar(bool value, BuildContext context,
|
static Widget pinConversationBar(
|
||||||
Function(bool value)? onChanged, bool smallCardMode) {
|
bool value, BuildContext context, Function(bool value)? onChanged, bool smallCardMode) {
|
||||||
return TIMUIKitOperationItem(
|
return TIMUIKitOperationItem(
|
||||||
smallCardMode: smallCardMode,
|
smallCardMode: smallCardMode,
|
||||||
isEmpty: false,
|
isEmpty: false,
|
||||||
|
|
@ -92,8 +86,8 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// message disturb
|
/// message disturb
|
||||||
static Widget messageDisturb(BuildContext context, bool isDisturb,
|
static Widget messageDisturb(
|
||||||
Function(bool value)? onChanged, bool smallCardMode) {
|
BuildContext context, bool isDisturb, Function(bool value)? onChanged, bool smallCardMode) {
|
||||||
return TIMUIKitOperationItem(
|
return TIMUIKitOperationItem(
|
||||||
smallCardMode: smallCardMode,
|
smallCardMode: smallCardMode,
|
||||||
isEmpty: false,
|
isEmpty: false,
|
||||||
|
|
@ -121,8 +115,7 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
isEmpty: isEmpty,
|
isEmpty: isEmpty,
|
||||||
operationName: operationName,
|
operationName: operationName,
|
||||||
type: type,
|
type: type,
|
||||||
operationRightWidget: Text(operationText ?? "",
|
operationRightWidget: Text(operationText ?? "", textAlign: isDesktopScreen ? null : TextAlign.end),
|
||||||
textAlign: isDesktopScreen ? null : TextAlign.end),
|
|
||||||
operationValue: operationValue,
|
operationValue: operationValue,
|
||||||
onSwitchChange: onSwitchChange,
|
onSwitchChange: onSwitchChange,
|
||||||
);
|
);
|
||||||
|
|
@ -163,8 +156,7 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// defaultPortraitWidget
|
/// defaultPortraitWidget
|
||||||
static Widget defaultPortraitWidget(
|
static Widget defaultPortraitWidget(V2TimUserFullInfo? userInfo, bool smallCardMode) {
|
||||||
V2TimUserFullInfo? userInfo, bool smallCardMode) {
|
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
width: 48,
|
width: 48,
|
||||||
height: 48,
|
height: 48,
|
||||||
|
|
@ -189,8 +181,7 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
isEmpty: nickName.isEmpty,
|
isEmpty: nickName.isEmpty,
|
||||||
showAllowEditStatus: false,
|
showAllowEditStatus: false,
|
||||||
operationName: TIM_t("昵称"),
|
operationName: TIM_t("昵称"),
|
||||||
operationRightWidget:
|
operationRightWidget: Text(nickName, textAlign: isDesktopScreen ? null : TextAlign.end),
|
||||||
Text(nickName, textAlign: isDesktopScreen ? null : TextAlign.end),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -203,8 +194,7 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
isEmpty: false,
|
isEmpty: false,
|
||||||
showAllowEditStatus: false,
|
showAllowEditStatus: false,
|
||||||
operationName: TIM_t("账号"),
|
operationName: TIM_t("账号"),
|
||||||
operationRightWidget: SelectableText(userNum,
|
operationRightWidget: SelectableText(userNum, textAlign: isDesktopScreen ? null : TextAlign.end),
|
||||||
textAlign: isDesktopScreen ? null : TextAlign.end),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -217,8 +207,7 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
isEmpty: false,
|
isEmpty: false,
|
||||||
showAllowEditStatus: false,
|
showAllowEditStatus: false,
|
||||||
operationName: TIM_t("个性签名"),
|
operationName: TIM_t("个性签名"),
|
||||||
operationRightWidget:
|
operationRightWidget: Text(signature, textAlign: isDesktopScreen ? null : TextAlign.end),
|
||||||
Text(signature, textAlign: isDesktopScreen ? null : TextAlign.end),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -236,8 +225,7 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
isEmpty: false,
|
isEmpty: false,
|
||||||
showAllowEditStatus: false,
|
showAllowEditStatus: false,
|
||||||
operationName: TIM_t("性别"),
|
operationName: TIM_t("性别"),
|
||||||
operationRightWidget: Text(genderMap[gender],
|
operationRightWidget: Text(genderMap[gender], textAlign: isDesktopScreen ? null : TextAlign.end),
|
||||||
textAlign: isDesktopScreen ? null : TextAlign.end),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -254,8 +242,7 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
smallCardMode: smallCardMode,
|
smallCardMode: smallCardMode,
|
||||||
isEmpty: false,
|
isEmpty: false,
|
||||||
operationName: TIM_t("性别"),
|
operationName: TIM_t("性别"),
|
||||||
operationRightWidget: Text(genderMap[gender],
|
operationRightWidget: Text(genderMap[gender], textAlign: isDesktopScreen ? null : TextAlign.end),
|
||||||
textAlign: isDesktopScreen ? null : TextAlign.end),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -269,16 +256,14 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
smallCardMode: smallCardMode,
|
smallCardMode: smallCardMode,
|
||||||
isEmpty: false,
|
isEmpty: false,
|
||||||
operationName: TIM_t("生日"),
|
operationName: TIM_t("生日"),
|
||||||
operationRightWidget: Text(formatter.format(date),
|
operationRightWidget: Text(formatter.format(date), textAlign: isDesktopScreen ? null : TextAlign.end),
|
||||||
textAlign: isDesktopScreen ? null : TextAlign.end),
|
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return TIMUIKitOperationItem(
|
return TIMUIKitOperationItem(
|
||||||
smallCardMode: smallCardMode,
|
smallCardMode: smallCardMode,
|
||||||
isEmpty: false,
|
isEmpty: false,
|
||||||
operationName: TIM_t("生日"),
|
operationName: TIM_t("生日"),
|
||||||
operationRightWidget:
|
operationRightWidget: Text(TIM_t("未填写"), textAlign: isDesktopScreen ? null : TextAlign.end),
|
||||||
Text(TIM_t("未填写"), textAlign: isDesktopScreen ? null : TextAlign.end),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -302,10 +287,8 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
child: Container(
|
child: Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
padding: const EdgeInsets.symmetric(vertical: 15),
|
padding: const EdgeInsets.symmetric(vertical: 15),
|
||||||
decoration: BoxDecoration(
|
decoration:
|
||||||
color: Colors.white,
|
BoxDecoration(color: Colors.white, border: Border(bottom: BorderSide(color: theme.weakDividerColor))),
|
||||||
border:
|
|
||||||
Border(bottom: BorderSide(color: theme.weakDividerColor))),
|
|
||||||
child: Text(
|
child: Text(
|
||||||
TIM_t("删除好友"),
|
TIM_t("删除好友"),
|
||||||
style: TextStyle(color: theme.cautionColor, fontSize: 17),
|
style: TextStyle(color: theme.cautionColor, fontSize: 17),
|
||||||
|
|
@ -320,15 +303,11 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
// padding: const EdgeInsets.symmetric(vertical: 15),
|
// padding: const EdgeInsets.symmetric(vertical: 15),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
border: Border(
|
border: Border(bottom: BorderSide(color: theme.weakDividerColor ?? CommonColor.weakDividerColor))),
|
||||||
bottom: BorderSide(
|
|
||||||
color: theme.weakDividerColor ??
|
|
||||||
CommonColor.weakDividerColor))),
|
|
||||||
child: Row(children: [
|
child: Row(children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextButton(
|
child: TextButton(
|
||||||
child: Text(TIM_t("加为好友"),
|
child: Text(TIM_t("加为好友"), style: TextStyle(color: theme.primaryColor, fontSize: 17)),
|
||||||
style: TextStyle(color: theme.primaryColor, fontSize: 17)),
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
handleAddFriend();
|
handleAddFriend();
|
||||||
}),
|
}),
|
||||||
|
|
@ -362,15 +341,13 @@ class TIMUIKitProfileWidget extends TIMUIKitClass {
|
||||||
style: TextStyle(color: color),
|
style: TextStyle(color: color),
|
||||||
),
|
),
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
minimumSize:
|
minimumSize: MaterialStateProperty.all<Size>(const Size(160, 40)),
|
||||||
MaterialStateProperty.all<Size>(const Size(160, 40)),
|
|
||||||
))
|
))
|
||||||
: ElevatedButton(
|
: ElevatedButton(
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: Text(text),
|
child: Text(text),
|
||||||
style: ButtonStyle(
|
style: ButtonStyle(
|
||||||
minimumSize:
|
minimumSize: MaterialStateProperty.all<Size>(const Size(180, 46)),
|
||||||
MaterialStateProperty.all<Size>(const Size(180, 46)),
|
|
||||||
backgroundColor: MaterialStateProperty.all<Color>(color)),
|
backgroundColor: MaterialStateProperty.all<Color>(color)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info_result.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result_item.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result_item.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_search_result_item.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/services_locatar.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_search_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_search_view_model.dart';
|
||||||
|
|
@ -29,12 +34,10 @@ class TIMUIKitSearch extends StatefulWidget {
|
||||||
|
|
||||||
/// [Deprecated] : You are supposed to use [onEnterSearchInConversation],
|
/// [Deprecated] : You are supposed to use [onEnterSearchInConversation],
|
||||||
/// though the effects are the same.
|
/// though the effects are the same.
|
||||||
final Function(V2TimConversation conversation, String initKeyword)?
|
final Function(V2TimConversation conversation, String initKeyword)? onEnterConversation;
|
||||||
onEnterConversation;
|
|
||||||
|
|
||||||
/// On click each conversation from 'Chat history' and searching for historical message in it.
|
/// On click each conversation from 'Chat history' and searching for historical message in it.
|
||||||
final Function(V2TimConversation conversation, String initKeyword)?
|
final Function(V2TimConversation conversation, String initKeyword)? onEnterSearchInConversation;
|
||||||
onEnterSearchInConversation;
|
|
||||||
|
|
||||||
final VoidCallback? onBack;
|
final VoidCallback? onBack;
|
||||||
|
|
||||||
|
|
@ -43,10 +46,11 @@ class TIMUIKitSearch extends StatefulWidget {
|
||||||
const TIMUIKitSearch(
|
const TIMUIKitSearch(
|
||||||
{required this.onTapConversation,
|
{required this.onTapConversation,
|
||||||
Key? key,
|
Key? key,
|
||||||
@Deprecated("You are supposed to use [TIMUIKitSearchMsgDetail], if you tend to search inside a specific conversation, includes c2c and group")
|
@Deprecated(
|
||||||
this.conversation,
|
"You are supposed to use [TIMUIKitSearchMsgDetail], if you tend to search inside a specific conversation, includes c2c and group")
|
||||||
|
this.conversation,
|
||||||
@Deprecated("You are supposed to use [onEnterSearchInConversation], though the effects are the same.")
|
@Deprecated("You are supposed to use [onEnterSearchInConversation], though the effects are the same.")
|
||||||
this.onEnterConversation,
|
this.onEnterConversation,
|
||||||
this.isAutoFocus = true,
|
this.isAutoFocus = true,
|
||||||
this.onEnterSearchInConversation,
|
this.onEnterSearchInConversation,
|
||||||
this.onBack})
|
this.onBack})
|
||||||
|
|
@ -61,11 +65,7 @@ class TIMUIKitSearchState extends TIMUIKitState<TIMUIKitSearch> {
|
||||||
final model = serviceLocator<TUISearchViewModel>();
|
final model = serviceLocator<TUISearchViewModel>();
|
||||||
final FocusNode focusNode = FocusNode();
|
final FocusNode focusNode = FocusNode();
|
||||||
GlobalKey<dynamic> inputTextField = GlobalKey();
|
GlobalKey<dynamic> inputTextField = GlobalKey();
|
||||||
List<SearchType> searchTypes = [
|
List<SearchType> searchTypes = [SearchType.group, SearchType.contact, SearchType.history];
|
||||||
SearchType.group,
|
|
||||||
SearchType.contact,
|
|
||||||
SearchType.history
|
|
||||||
];
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
|
@ -80,19 +80,12 @@ class TIMUIKitSearchState extends TIMUIKitState<TIMUIKitSearch> {
|
||||||
return TIMUIKitSearchNotSupport();
|
return TIMUIKitSearchNotSupport();
|
||||||
}
|
}
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [ChangeNotifierProvider.value(value: serviceLocator<TUISearchViewModel>())],
|
||||||
ChangeNotifierProvider.value(
|
|
||||||
value: serviceLocator<TUISearchViewModel>())
|
|
||||||
],
|
|
||||||
builder: (context, w) {
|
builder: (context, w) {
|
||||||
List<V2TimFriendInfoResult> friendResultList =
|
List<V2TimFriendInfoResult> friendResultList = Provider.of<TUISearchViewModel>(context).friendList ?? [];
|
||||||
Provider.of<TUISearchViewModel>(context).friendList ?? [];
|
List<V2TimMessageSearchResultItem> msgList = Provider.of<TUISearchViewModel>(context).msgList ?? [];
|
||||||
List<V2TimMessageSearchResultItem> msgList =
|
List<V2TimGroupInfo> groupList = Provider.of<TUISearchViewModel>(context).groupList ?? [];
|
||||||
Provider.of<TUISearchViewModel>(context).msgList ?? [];
|
int totalMsgCount = Provider.of<TUISearchViewModel>(context).totalMsgCount;
|
||||||
List<V2TimGroupInfo> groupList =
|
|
||||||
Provider.of<TUISearchViewModel>(context).groupList ?? [];
|
|
||||||
int totalMsgCount =
|
|
||||||
Provider.of<TUISearchViewModel>(context).totalMsgCount;
|
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
FocusScopeNode currentFocus = FocusScope.of(context);
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||||
|
|
@ -123,14 +116,9 @@ class TIMUIKitSearchState extends TIMUIKitState<TIMUIKitSearch> {
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
if ((friendResultList.isEmpty ||
|
if ((friendResultList.isEmpty || !(searchTypes.contains(SearchType.contact))) &&
|
||||||
!(searchTypes.contains(SearchType.contact))) &&
|
(groupList.isEmpty || !(searchTypes.contains(SearchType.group))) &&
|
||||||
(groupList.isEmpty ||
|
(totalMsgCount == 0 || !(searchTypes.contains(SearchType.history))))
|
||||||
!(searchTypes
|
|
||||||
.contains(SearchType.group))) &&
|
|
||||||
(totalMsgCount == 0 ||
|
|
||||||
!(searchTypes
|
|
||||||
.contains(SearchType.history))))
|
|
||||||
TIMUIKitSearchIndicator(
|
TIMUIKitSearchIndicator(
|
||||||
typeList: searchTypes,
|
typeList: searchTypes,
|
||||||
onChange: (list) {
|
onChange: (list) {
|
||||||
|
|
@ -143,10 +131,8 @@ class TIMUIKitSearchState extends TIMUIKitState<TIMUIKitSearch> {
|
||||||
TIMUIKitSearchFriend(
|
TIMUIKitSearchFriend(
|
||||||
onTapConversation: (conversation, message) {
|
onTapConversation: (conversation, message) {
|
||||||
focusNode.unfocus();
|
focusNode.unfocus();
|
||||||
Future.delayed(
|
Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
const Duration(milliseconds: 100), () {
|
widget.onTapConversation(conversation, message);
|
||||||
widget.onTapConversation(
|
|
||||||
conversation, message);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
friendResultList: friendResultList),
|
friendResultList: friendResultList),
|
||||||
|
|
@ -155,8 +141,7 @@ class TIMUIKitSearchState extends TIMUIKitState<TIMUIKitSearch> {
|
||||||
groupList: groupList,
|
groupList: groupList,
|
||||||
onTapConversation: (conversation, message) {
|
onTapConversation: (conversation, message) {
|
||||||
focusNode.unfocus();
|
focusNode.unfocus();
|
||||||
Future.delayed(const Duration(milliseconds: 100),
|
Future.delayed(const Duration(milliseconds: 100), () {
|
||||||
() {
|
|
||||||
widget.onTapConversation(conversation, message);
|
widget.onTapConversation(conversation, message);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -167,15 +152,11 @@ class TIMUIKitSearchState extends TIMUIKitState<TIMUIKitSearch> {
|
||||||
keyword: textEditingController.text,
|
keyword: textEditingController.text,
|
||||||
totalMsgCount: totalMsgCount,
|
totalMsgCount: totalMsgCount,
|
||||||
msgList: msgList,
|
msgList: msgList,
|
||||||
onEnterConversation:
|
onEnterConversation: (V2TimConversation conversation, String keyword) {
|
||||||
(V2TimConversation conversation,
|
|
||||||
String keyword) {
|
|
||||||
if (widget.onEnterSearchInConversation != null) {
|
if (widget.onEnterSearchInConversation != null) {
|
||||||
widget.onEnterSearchInConversation!(
|
widget.onEnterSearchInConversation!(conversation, keyword);
|
||||||
conversation, keyword);
|
|
||||||
} else if (widget.onEnterConversation != null) {
|
} else if (widget.onEnterConversation != null) {
|
||||||
widget.onEnterConversation!(
|
widget.onEnterConversation!(conversation, keyword);
|
||||||
conversation, keyword);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,12 @@ import 'dart:math';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_friend_info_result.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_friend_info_result.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitSearch/pureUI/tim_uikit_search_item.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitSearch/pureUI/tim_uikit_search_item.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitSearch/pureUI/tim_uikit_search_folder.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitSearch/pureUI/tim_uikit_search_folder.dart';
|
||||||
|
|
@ -19,11 +22,7 @@ class TIMUIKitSearchFriend extends StatefulWidget {
|
||||||
List<V2TimFriendInfoResult> friendResultList;
|
List<V2TimFriendInfoResult> friendResultList;
|
||||||
final Function(V2TimConversation, V2TimMessage?) onTapConversation;
|
final Function(V2TimConversation, V2TimMessage?) onTapConversation;
|
||||||
|
|
||||||
TIMUIKitSearchFriend(
|
TIMUIKitSearchFriend({required this.friendResultList, Key? key, required this.onTapConversation}) : super(key: key);
|
||||||
{required this.friendResultList,
|
|
||||||
Key? key,
|
|
||||||
required this.onTapConversation})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => TIMUIKitSearchFriendState();
|
State<StatefulWidget> createState() => TIMUIKitSearchFriendState();
|
||||||
|
|
@ -46,31 +45,26 @@ class TIMUIKitSearchFriendState extends TIMUIKitState<TIMUIKitSearchFriend> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
List<V2TimConversation?> _conversationList =
|
List<V2TimConversation?> _conversationList = Provider.of<TUISearchViewModel>(context).conversationList;
|
||||||
Provider.of<TUISearchViewModel>(context).conversationList;
|
|
||||||
|
|
||||||
List<V2TimFriendInfoResult> filteredFriendResultList =
|
List<V2TimFriendInfoResult> filteredFriendResultList = widget.friendResultList.where((friend) {
|
||||||
widget.friendResultList.where((friend) {
|
int index = _conversationList.indexWhere((conv) => friend.friendInfo?.userID == conv?.userID);
|
||||||
int index = _conversationList
|
|
||||||
.indexWhere((conv) => friend.friendInfo?.userID == conv?.userID);
|
|
||||||
return index == -1 ? false : true;
|
return index == -1 ? false : true;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
List<V2TimFriendInfoResult> halfFilteredFriendResultList = isShowAll
|
List<V2TimFriendInfoResult> halfFilteredFriendResultList = isShowAll
|
||||||
? filteredFriendResultList
|
? filteredFriendResultList
|
||||||
: filteredFriendResultList.sublist(
|
: filteredFriendResultList.sublist(0, min(defaultShowLines, filteredFriendResultList.length));
|
||||||
0, min(defaultShowLines, filteredFriendResultList.length));
|
|
||||||
|
|
||||||
if (filteredFriendResultList.isNotEmpty) {
|
if (filteredFriendResultList.isNotEmpty) {
|
||||||
return TIMUIKitSearchFolder(folderName: TIM_t("联系人"), children: [
|
return TIMUIKitSearchFolder(folderName: TIM_t("联系人"), children: [
|
||||||
...halfFilteredFriendResultList.map((conv) {
|
...halfFilteredFriendResultList.map((conv) {
|
||||||
int convIndex = _conversationList
|
int convIndex = _conversationList.indexWhere((item) => conv.friendInfo?.userID == item?.userID);
|
||||||
.indexWhere((item) => conv.friendInfo?.userID == item?.userID);
|
|
||||||
V2TimConversation conversation = _conversationList[convIndex]!;
|
V2TimConversation conversation = _conversationList[convIndex]!;
|
||||||
late String? showNickName;
|
late String? showNickName;
|
||||||
if (conv.friendInfo?.friendRemark != null && conv.friendInfo?.friendRemark != "") {
|
if (conv.friendInfo?.friendRemark != null && conv.friendInfo?.friendRemark != "") {
|
||||||
showNickName = conv.friendInfo?.friendRemark;
|
showNickName = conv.friendInfo?.friendRemark;
|
||||||
} else if (conv.friendInfo?.userProfile?.nickName != null && conv.friendInfo?.userProfile?.nickName != "") {
|
} else if (conv.friendInfo?.userProfile?.nickName != null && conv.friendInfo?.userProfile?.nickName != "") {
|
||||||
showNickName = conv.friendInfo?.userProfile?.nickName;
|
showNickName = conv.friendInfo?.userProfile?.nickName;
|
||||||
} else {
|
} else {
|
||||||
showNickName = conv.friendInfo?.userID;
|
showNickName = conv.friendInfo?.userID;
|
||||||
|
|
@ -82,7 +76,6 @@ class TIMUIKitSearchFriendState extends TIMUIKitState<TIMUIKitSearchFriend> {
|
||||||
},
|
},
|
||||||
faceUrl: conv.friendInfo?.userProfile?.faceUrl ?? "",
|
faceUrl: conv.friendInfo?.userProfile?.faceUrl ?? "",
|
||||||
showName: "",
|
showName: "",
|
||||||
|
|
||||||
lineOne: conversation.userID!,
|
lineOne: conversation.userID!,
|
||||||
lineTwo: TIM_t("昵称") + ":" + showNickName!,
|
lineTwo: TIM_t("昵称") + ":" + showNickName!,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,12 @@ import 'dart:math';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_group_info.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_group_info.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_state.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitSearch/pureUI/tim_uikit_search_item.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitSearch/pureUI/tim_uikit_search_item.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitSearch/pureUI/tim_uikit_search_folder.dart';
|
import 'package:tencent_cloud_chat_uikit/ui/views/TIMUIKitSearch/pureUI/tim_uikit_search_folder.dart';
|
||||||
|
|
@ -19,9 +22,7 @@ class TIMUIKitSearchGroup extends StatefulWidget {
|
||||||
List<V2TimGroupInfo> groupList;
|
List<V2TimGroupInfo> groupList;
|
||||||
final Function(V2TimConversation, V2TimMessage?) onTapConversation;
|
final Function(V2TimConversation, V2TimMessage?) onTapConversation;
|
||||||
|
|
||||||
TIMUIKitSearchGroup(
|
TIMUIKitSearchGroup({required this.groupList, Key? key, required this.onTapConversation}) : super(key: key);
|
||||||
{required this.groupList, Key? key, required this.onTapConversation})
|
|
||||||
: super(key: key);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => TIMUIKitSearchGroupState();
|
State<StatefulWidget> createState() => TIMUIKitSearchGroupState();
|
||||||
|
|
@ -44,26 +45,21 @@ class TIMUIKitSearchGroupState extends TIMUIKitState<TIMUIKitSearchGroup> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
List<V2TimConversation?> _conversationList =
|
List<V2TimConversation?> _conversationList = Provider.of<TUISearchViewModel>(context).conversationList;
|
||||||
Provider.of<TUISearchViewModel>(context).conversationList;
|
|
||||||
|
|
||||||
List<V2TimGroupInfo> filteredGroupResultList =
|
List<V2TimGroupInfo> filteredGroupResultList = widget.groupList.where((group) {
|
||||||
widget.groupList.where((group) {
|
int index = _conversationList.indexWhere((conv) => group.groupID == conv?.groupID);
|
||||||
int index = _conversationList
|
|
||||||
.indexWhere((conv) => group.groupID == conv?.groupID);
|
|
||||||
return index == -1 ? false : true;
|
return index == -1 ? false : true;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
List<V2TimGroupInfo> halfFilteredGroupResultList = isShowAll
|
List<V2TimGroupInfo> halfFilteredGroupResultList = isShowAll
|
||||||
? filteredGroupResultList
|
? filteredGroupResultList
|
||||||
: filteredGroupResultList.sublist(
|
: filteredGroupResultList.sublist(0, min(defaultShowLines, filteredGroupResultList.length));
|
||||||
0, min(defaultShowLines, filteredGroupResultList.length));
|
|
||||||
|
|
||||||
if (filteredGroupResultList.isNotEmpty) {
|
if (filteredGroupResultList.isNotEmpty) {
|
||||||
return TIMUIKitSearchFolder(folderName: TIM_t("群聊"), children: [
|
return TIMUIKitSearchFolder(folderName: TIM_t("群聊"), children: [
|
||||||
...halfFilteredGroupResultList.map((group) {
|
...halfFilteredGroupResultList.map((group) {
|
||||||
int convIndex = _conversationList
|
int convIndex = _conversationList.indexWhere((item) => group.groupID == item?.groupID);
|
||||||
.indexWhere((item) => group.groupID == item?.groupID);
|
|
||||||
V2TimConversation conversation = _conversationList[convIndex]!;
|
V2TimConversation conversation = _conversationList[convIndex]!;
|
||||||
return TIMUIKitSearchItem(
|
return TIMUIKitSearchItem(
|
||||||
onClick: () {
|
onClick: () {
|
||||||
|
|
@ -71,10 +67,7 @@ class TIMUIKitSearchGroupState extends TIMUIKitState<TIMUIKitSearchGroup> {
|
||||||
},
|
},
|
||||||
faceUrl: conversation.faceUrl ?? group.faceUrl ?? "",
|
faceUrl: conversation.faceUrl ?? group.faceUrl ?? "",
|
||||||
showName: "",
|
showName: "",
|
||||||
lineOne: conversation.showName ??
|
lineOne: conversation.showName ?? group.groupName ?? conversation.groupID ?? "",
|
||||||
group.groupName ??
|
|
||||||
conversation.groupID ??
|
|
||||||
"",
|
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
_renderShowALl(filteredGroupResultList.length),
|
_renderShowALl(filteredGroupResultList.length),
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,12 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_conversation.dart'
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart';
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_conversation.dart';
|
||||||
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result_item.dart';
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message.dart';
|
||||||
|
import 'package:tencent_cloud_chat_sdk/models/v2_tim_message_search_result_item.dart'
|
||||||
|
if (dart.library.html) 'package:tencent_cloud_chat_sdk/web/compatible_models/v2_tim_message_search_result_item.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
import 'package:tencent_cloud_chat_uikit/base_widgets/tim_ui_kit_statelesswidget.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/data_services/conversation/conversation_services.dart';
|
import 'package:tencent_cloud_chat_uikit/data_services/conversation/conversation_services.dart';
|
||||||
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_search_view_model.dart';
|
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_search_view_model.dart';
|
||||||
|
|
@ -45,19 +48,17 @@ class TIMUIKitSearchMsg extends TIMUIKitStatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
Widget tuiBuild(BuildContext context, TUIKitBuildValue value) {
|
||||||
List<V2TimConversation?> _conversationList =
|
List<V2TimConversation?> _conversationList = Provider.of<TUISearchViewModel>(context).conversationList;
|
||||||
Provider.of<TUISearchViewModel>(context).conversationList;
|
|
||||||
|
|
||||||
if (msgList.isNotEmpty) {
|
if (msgList.isNotEmpty) {
|
||||||
return TIMUIKitSearchFolder(folderName: TIM_t("聊天记录"), children: [
|
return TIMUIKitSearchFolder(folderName: TIM_t("聊天记录"), children: [
|
||||||
...msgList.map((conv) {
|
...msgList.map((conv) {
|
||||||
V2TimConversation? conversation;
|
V2TimConversation? conversation;
|
||||||
final index = _conversationList.indexWhere(
|
final index = _conversationList.indexWhere((item) => item!.conversationID == conv?.conversationID);
|
||||||
(item) => item!.conversationID == conv?.conversationID);
|
if (index > -1) {
|
||||||
if(index > -1){
|
|
||||||
conversation = _conversationList[index]!;
|
conversation = _conversationList[index]!;
|
||||||
}
|
}
|
||||||
if(conversation == null){
|
if (conversation == null) {
|
||||||
return Container();
|
return Container();
|
||||||
}
|
}
|
||||||
final option1 = conv?.messageCount;
|
final option1 = conv?.messageCount;
|
||||||
|
|
@ -68,8 +69,7 @@ class TIMUIKitSearchMsg extends TIMUIKitStatelessWidget {
|
||||||
faceUrl: conversation.faceUrl ?? "",
|
faceUrl: conversation.faceUrl ?? "",
|
||||||
showName: conversation.showName ?? "",
|
showName: conversation.showName ?? "",
|
||||||
lineOne: conversation.showName ?? "",
|
lineOne: conversation.showName ?? "",
|
||||||
lineTwo: TIM_t_para("{{option1}}条相关聊天记录", "$option1条相关聊天记录")(
|
lineTwo: TIM_t_para("{{option1}}条相关聊天记录", "$option1条相关聊天记录")(option1: option1),
|
||||||
option1: option1),
|
|
||||||
);
|
);
|
||||||
}).toList(),
|
}).toList(),
|
||||||
_renderShowALl(totalMsgCount > msgList.length)
|
_renderShowALl(totalMsgCount > msgList.length)
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue