init
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
||||
|
||||
class AddFriendLifeCycle {
|
||||
/// Before requesting to add a user as friend or a contact,
|
||||
/// `true` means can add continually, while `false` will not add.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(
|
||||
String userID, String? remark, String? friendGroup, String? addWording,
|
||||
[BuildContext? context]) shouldAddFriend;
|
||||
|
||||
AddFriendLifeCycle({
|
||||
this.shouldAddFriend = DefaultLifeCycle.defaultAddFriend,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
||||
|
||||
class AddGroupLifeCycle {
|
||||
/// Before requesting to add or join to a group,
|
||||
/// `true` means can add continually, while `false` will not add.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String groupID, String message, [BuildContext? context])
|
||||
shouldAddGroup;
|
||||
|
||||
AddGroupLifeCycle({
|
||||
this.shouldAddGroup = DefaultLifeCycle.defaultAddGroup,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:tencent_chat_i18n_tool/tencent_chat_i18n_tool.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_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_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_callback.dart';
|
||||
|
||||
typedef MessageFunction = Future<V2TimMessage?> Function(V2TimMessage message);
|
||||
|
||||
typedef MessageFunctionNullCallback = Function(V2TimValueCallback<V2TimMessage> res);
|
||||
|
||||
typedef MessageFunctionOptional = Future<V2TimMessage?> Function(V2TimMessage message);
|
||||
|
||||
typedef MessageListFunction = Future<List<V2TimMessage>> Function(List<V2TimMessage> messageList);
|
||||
|
||||
typedef MessageListFunctionAsync = List<V2TimMessage> Function(List<V2TimMessage> messageList);
|
||||
|
||||
typedef FutureBool = Future<bool>;
|
||||
|
||||
typedef AddFriendFunction = Function(String userID, String? remark, String? friendGroup, String? addWording);
|
||||
|
||||
typedef ConversationListFunction = Future<List<V2TimConversation?>> Function(List<V2TimConversation?> conversationList);
|
||||
|
||||
typedef FriendListFunction = Future<List<V2TimFriendInfo>> Function(List<V2TimFriendInfo> friendList);
|
||||
|
||||
typedef FriendInfoFunction = Future<V2TimFriendInfo?> Function(V2TimFriendInfo? friendInfo);
|
||||
|
||||
/// Here is the default life cycle hooks implementation for all the hooks in TUIKit.
|
||||
abstract class DefaultLifeCycle {
|
||||
static Future<List<V2TimConversation?>> defaultConversationListSolution(List<V2TimConversation?> list) async {
|
||||
return list;
|
||||
}
|
||||
|
||||
static Future<List<V2TimFriendInfo>> defaultFriendListSolution(List<V2TimFriendInfo> list) async {
|
||||
return list;
|
||||
}
|
||||
|
||||
static Future<V2TimMessage> defaultMessageSolution(V2TimMessage message) async {
|
||||
return message;
|
||||
}
|
||||
|
||||
static Future<V2TimMessage> defaultTwoMessagesSolution(V2TimMessage message, [V2TimMessage? repliedMessage]) async {
|
||||
return message;
|
||||
}
|
||||
|
||||
static Future<List<V2TimMessage>> defaultMessageListSolution(List<V2TimMessage> list) async {
|
||||
return list;
|
||||
}
|
||||
|
||||
static List<V2TimMessage> defaultMessageListSolutionAsync(List<V2TimMessage> list) {
|
||||
return list;
|
||||
}
|
||||
|
||||
static Future<bool> defaultAsyncBooleanSolution(dynamic) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool defaultBooleanSolution(dynamic) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static defaultNullCallbackSolution(dynamic) {}
|
||||
|
||||
static Future<bool> defaultAddFriend(String userID, String? remark, String? friendGroup, String? addWording,
|
||||
[BuildContext? context]) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
static Future<bool> defaultAddGroup(String groupID, String message, [BuildContext? context]) async {
|
||||
return true;
|
||||
}
|
||||
|
||||
static Future<V2TimFriendInfo?> defaultFriendInfoSolution(V2TimFriendInfo? friendInfo) async {
|
||||
return friendInfo;
|
||||
}
|
||||
|
||||
static Future<void> defaultPopBackRemind() async {
|
||||
// You have to implement the exact life cycle hook in this case.
|
||||
TIMUIKitClass.onTIMCallback(TIMCallback(
|
||||
type: TIMCallbackType.INFO, infoRecommendText: TIM_t("请传入离开群组生命周期函数,提供返回首页或其他页面的导航方法。"), infoCode: 6661402));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
||||
|
||||
class BlockListLifeCycle {
|
||||
/// Before requesting to delete a user from block list,
|
||||
/// `true` means can delete continually, while `false` will not delete.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(List<String> userIDList) shouldDeleteFromBlockList;
|
||||
|
||||
BlockListLifeCycle({
|
||||
this.shouldDeleteFromBlockList = DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
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/tencent_cloud_chat_uikit.dart';
|
||||
|
||||
class ChatLifeCycle {
|
||||
/// Before a new message will be added to historical message list from long connection.
|
||||
/// You may not render this message by return null.
|
||||
MessageFunctionOptional newMessageWillMount;
|
||||
|
||||
/// Before a modified message updated to historical message list UI.
|
||||
MessageFunction modifiedMessageWillMount;
|
||||
|
||||
/// Before a new message will be sent.
|
||||
/// Returns null can block the message from sending.
|
||||
// Future<V2TimMessage?> Function(V2TimMessage message, [V2TimMessage? repliedMessage]) messageWillSend;
|
||||
|
||||
/// After a new message been sent.
|
||||
MessageFunctionNullCallback messageDidSend;
|
||||
|
||||
/// After getting the latest message list from API,
|
||||
/// and before historical message list will be rendered.
|
||||
/// You may add or delete some messages here.
|
||||
MessageListFunction didGetHistoricalMessageList;
|
||||
|
||||
/// Before deleting a message from historical message list,
|
||||
/// `true` means can delete continually, while `false` will not delete.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String msgID) shouldDeleteMessage;
|
||||
|
||||
/// Before clearing the historical message list,
|
||||
/// `true` means can clear continually, while `false` will not clear.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String conversationID) shouldClearHistoricalMessageList;
|
||||
|
||||
/// Before rendering a message to message list.
|
||||
bool Function(V2TimMessage msg) messageShouldMount;
|
||||
|
||||
/// Before all message will be rendered on the message list.
|
||||
/// You may add or delete some messages here.
|
||||
MessageListFunctionAsync messageListShouldMount;
|
||||
|
||||
ChatLifeCycle({
|
||||
this.shouldClearHistoricalMessageList = DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
this.shouldDeleteMessage = DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
this.messageDidSend = DefaultLifeCycle.defaultNullCallbackSolution,
|
||||
this.didGetHistoricalMessageList = DefaultLifeCycle.defaultMessageListSolution,
|
||||
// this.messageWillSend = DefaultLifeCycle.defaultTwoMessagesSolution,
|
||||
this.modifiedMessageWillMount = DefaultLifeCycle.defaultMessageSolution,
|
||||
this.newMessageWillMount = DefaultLifeCycle.defaultMessageSolution,
|
||||
this.messageShouldMount = DefaultLifeCycle.defaultBooleanSolution,
|
||||
this.messageListShouldMount = DefaultLifeCycle.defaultMessageListSolutionAsync,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
||||
|
||||
class ConversationLifeCycle {
|
||||
/// Before deleting a conversation, or a channel, from the conversation list,
|
||||
/// `true` means can delete continually, while `false` will not delete.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String conversationID) shouldDeleteConversation;
|
||||
|
||||
/// Before clearing the historical message for a specific conversation, provided in parameter,
|
||||
/// `true` means can clear continually, while `false` will not clear.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String conversationID)
|
||||
shouldClearHistoricalMessageForConversation;
|
||||
|
||||
/// Before conversation list will mount or update to conversation page.
|
||||
ConversationListFunction conversationListWillMount;
|
||||
|
||||
ConversationLifeCycle({
|
||||
this.conversationListWillMount =
|
||||
DefaultLifeCycle.defaultConversationListSolution,
|
||||
this.shouldClearHistoricalMessageForConversation =
|
||||
DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
this.shouldDeleteConversation = DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
||||
|
||||
class FriendListLifeCycle {
|
||||
/// Before friend list (contacts list) will mount or update to contacts page.
|
||||
FriendListFunction friendListWillMount;
|
||||
|
||||
FriendListLifeCycle({
|
||||
this.friendListWillMount = DefaultLifeCycle.defaultFriendListSolution,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
||||
|
||||
class GroupProfileLifeCycle {
|
||||
/// In this case, you have better navigating to you home page or conversation list page,
|
||||
/// due to user request to leave the group, as quitting or disbanding.
|
||||
Future<void> Function() didLeaveGroup;
|
||||
|
||||
GroupProfileLifeCycle({
|
||||
this.didLeaveGroup = DefaultLifeCycle.defaultPopBackRemind,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
||||
|
||||
class NewContactLifeCycle {
|
||||
/// Before accepting a friend or contact requirement from other user,
|
||||
/// `true` means can accept continually, while `false` will not accept.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String userID) shouldAcceptContactApplication;
|
||||
|
||||
/// Before refusing a friend or contact requirement from other user,
|
||||
/// `true` means can refuse continually, while `false` will not refuse.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String userID) shouldRefuseContactApplication;
|
||||
|
||||
NewContactLifeCycle({
|
||||
this.shouldAcceptContactApplication =
|
||||
DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
this.shouldRefuseContactApplication =
|
||||
DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:tencent_cloud_chat_uikit/business_logic/life_cycle/base_life_cycle.dart';
|
||||
|
||||
class ProfileLifeCycle {
|
||||
/// Before adding a contact to block list,
|
||||
/// `true` means can add continually, while `false` will not add.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String userID) shouldAddToBlockList;
|
||||
|
||||
/// Before deleting a contact or friend,
|
||||
/// `true` means can delete continually, while `false` will not delete.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String userID) shouldDeleteFriend;
|
||||
|
||||
/// Before requesting to add a user as friend or a contact,
|
||||
/// `true` means can add continually, while `false` will not add.
|
||||
/// You can make a second confirmation here by a modal, etc.
|
||||
FutureBool Function(String userID) shouldAddFriend;
|
||||
|
||||
/// After getting the user info of friend or contact,
|
||||
/// and before rendering it to the profile page.
|
||||
FriendInfoFunction didGetFriendInfo;
|
||||
|
||||
/// The callback after the remark to a friend changed.
|
||||
FutureBool Function(String userID) didRemarkUpdated;
|
||||
|
||||
ProfileLifeCycle({
|
||||
this.didRemarkUpdated = DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
this.didGetFriendInfo = DefaultLifeCycle.defaultFriendInfoSolution,
|
||||
this.shouldAddToBlockList = DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
this.shouldAddFriend = DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
this.shouldDeleteFriend = DefaultLifeCycle.defaultAsyncBooleanSolution,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user