Page Event Listening
Listening to Conversation List Page Events
You can set up conversation list operation listeners to implement custom requirements. The listening events for the conversation list RCChatListViewController
are in the delegates RCChatListViewDelegate
, RCChatListViewDataSource
, and RCChatListViewModelDelegate
. Overriding these delegate methods allows for custom handling.
Conversation List View Event Callbacks
RCChatListViewDelegate
includes callbacks for cell loading, search bar clicks, conversation selection and deselection, and loading more conversations. After handling custom requirements in the methods below, you may still need the SDK's default processing, which can be invoked via super
.
Cell About to Load in the List
/// Cell about to load in the list
/// - Parameters:
/// - listView: The list page
/// - chatModel: The conversation object
- (void)listView:(RCChatListView *)listView willLoadCell:(UITableViewCell *)cell
forChatModel:(RCChatModel *)chatModel;
Cell Loaded in the List
/// Cell loaded in the list
/// - Parameters:
/// - listView: The list page
/// - chatModel: The conversation message object
- (void)listView:(RCChatListView *)listView didLoadCell:(UITableViewCell *)cell
forChatModel:(RCChatModel *)chatModel;
Search Bar Click Event
/// Search bar click event
/// - Parameter listView: The conversation list
/// - Parameter searBar: The search bar
- (void)listView:(RCChatListView *)listView didClickSearchBar:(RCChatListSearchBar *)searBar;
Selecting a Conversation in the List
/// Selecting a conversation in the list
/// - Parameter listView: The conversation list
/// - Parameter chatModel: The conversation object
- (void)listView:(RCChatListView *)listView didSelectedChat:(RCChatModel *)chatModel;
Deselecting a Conversation in the List
/// Deselecting a conversation in the list
/// - Parameter listView: The conversation list
/// - Parameter chatModel: The conversation object
- (void)listView:(RCChatListView *)listView didDeselectedChat:(RCChatModel *)chatModel;
Conversation List About to Load More
/// Conversation list about to load more
/// - Parameter listView: The conversation list
/// - Parameter chatModel: The conversation object
- (void)listView:(RCChatListView *)listView didDetectPreloadingAtIndexPath:(NSIndexPath *)indexPath;
Conversation List View Data Source
RCChatListViewDataSource
allows you to access the data source of the conversation list, and perform add, delete, modify, and query operations on the swipe edit items of the conversation.
Conversation List Data
/// Conversation list data
/// - Parameters:
/// - listView: The conversation list component
/// - tableView: The tableView
- (NSArray<RCChatModel *> *)listView:(RCChatListView *)listView
chatModelsInTableView:(UITableView *)tableView;
Code Example:
- (NSArray<RCChatModel *> *)listView:(RCChatListView *)listView chatModelsInTableView:(UITableView *)tableView {
NSMutableArray *tempArray = [super listView:listView chatModelsInTableView:tableView].mutableCopy;
/// Perform add, delete, modify operations on tempArray
///
return tempArray;
}
Swipe Edit Items for Conversation
/// Returns the items displayed by the cell based on indexPath and swipe direction
/// - Parameter listView: The conversation list
/// - Parameter indexPath: The conversation position
/// - Parameter direction: The swipe direction
- (NSArray<RCSwipeItem *> *)listView:(RCChatListView *)listView
cellSwipeItemsAtIndexPath:(NSIndexPath *)indexPath
forDirection:(RCSwipeDirection)direction;
Code Example:
- (NSArray<RCSwipeItem *> *)listView:(RCChatListView *)listView cellSwipeItemsAtIndexPath:(NSIndexPath *)indexPath forDirection:(RCSwipeDirection)direction {
NSMutableArray *tempArray = [super listView:listView cellSwipeItemsAtIndexPath:indexPath forDirection:direction].mutableCopy;
/// Perform add, delete, modify operations on tempArray
return tempArray;
}
Conversation List ViewModel Callbacks
RCChatListViewModelDelegate
includes callbacks related to updating the conversation view. After handling custom requirements in the methods below, you may still need the SDK's default processing, which can be invoked via super
.
Reloading the Conversation List
/// Reloading the conversation list
/// - Parameter viewModel: The ViewModel
/// - Parameter chatModels: The conversation data
- (void)viewModel:(RCChatListViewModel *)viewModel chatListDidReload:(NSArray<RCChatModel *> *)chatModels;
Inserting a Conversation
/// Inserting a conversation
/// - Parameter viewModel: The ViewModel
/// - Parameter indexSet: The conversation index list
- (void)viewModel:(RCChatListViewModel *)viewModel chatListDidInsertAtIndexSet:(NSIndexSet *)indexSet;
Moving a Conversation
/// Moving a conversation
/// - Parameter viewModel: The ViewModel
/// - Parameter indexSet: The conversation index list
- (void)viewModel:(RCChatListViewModel *)viewModel chatListDidMoveFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex;
Updating Certain Conversations
/// Updating certain conversations
/// - Parameter viewModel: The ViewModel
/// - Parameter indexSet: The conversation index list
- (void)viewModel:(RCChatListViewModel *)viewModel chatListDidUpdateAtIndexSet:(NSIndexSet *)indexSet;
Removing Certain Conversations
/// Removing certain conversations
/// - Parameter viewModel: The ViewModel
/// - Parameter indexSet: The conversation index list
- (void)viewModel:(RCChatListViewModel *)viewModel chatListDidRemoveAtIndexSet:(NSIndexSet *)indexSet;
All Data Loaded in the Conversation List
/// All data loaded in the conversation list
/// - Parameter viewModel: The ViewModel
- (void)viewModelDidLoadAllChat:(RCChatListViewModel *)viewModel;
Error Occurred in the Conversation List
/// Error occurred in the conversation list
/// - Parameters:
/// - viewModel: The ViewModel
/// - error: The error information
- (void)viewModel:(RCChatListViewModel *)viewModel errorDidOccur:(NSError *)error;
Listening to Conversation Page Events
You can set up conversation page operation listeners to implement custom requirements. Below are the common events provided by RCChatViewController
.
More Page About to Display
/// More page about to display
/// - Parameters:
/// - items: Built-in events
/// - chatModel: The conversation object
- (NSArray<RCChatMoreBarItem *> *)willDisplayMoreMenu:(NSArray<RCChatMoreBarItem *> *)items
forChatModel:(RCChatModel *)chatModel;
Search Bar Item Click Event
- (void)didClickSearchBarItem;
Long Press Message Edit View About to Display
- (NSArray<RCMessageEditBarItem *> *)willDisplayEditMenu:(NSArray<RCMessageEditBarItem *> *)items
forMessageModel:(RCMessageModel *)messageModel;
Select Bar About to Display When Selecting Messages
- (NSArray<RCMessageSelectionBarItem *> *)willDisplaySelectBar:(NSArray<RCMessageSelectionBarItem *> *)items
forChatModel:(RCChatModel *)chatModel;
Step-by-Step Forward Event
- (void)forwardOriginalMessages:(NSArray *)messageModels;
Merge Forward Event
- (void)forwardCombinedMessages:(NSArray *)messageModels;
End Selection Event
- (void)endSelection;
Message List Events
Message list events are in RCMessageListViewDelegate
@protocol RCMessageListViewDelegate <NSObject>
@optional
/// Cell about to load in the list
/// - Parameters:
/// - listView: The list page
/// - messageModel: The message object
- (void)listView:(RCMessageListView *)listView willLoadCell:(UITableViewCell *)cell forMessageModel:(RCMessageModel *)messageModel;
/// Cell loaded in the list
/// - Parameters:
/// - listView: The list page
/// - messageModel: The message object
- (void)listView:(RCMessageListView *)listView didLoadCell:(UITableViewCell *)cell forMessageModel:(RCMessageModel *)messageModel;
/// Cell about to display in the list
/// - Parameters:
/// - listView: The list page
/// - messageModel: The message object
- (void)listView:(RCMessageListView *)listView willDisplayCell:(UITableViewCell *)cell forMessageModel:(RCMessageModel *)messageModel;
/// Detected need to load previous page data
/// - Parameters:
/// - listView: The list page
/// - messageModel: The first message object in the list
- (void)listView:(RCMessageListView *)listView didDetectPreviousPageLoadingWithMessageModel:(RCMessageModel *)messageModel;
/// Detected need to load next page data
/// - Parameters:
/// - listView: The list page
/// - messageModel: The last message object in the list
- (