tencent cloud

Chat

Política IM
Política de Privacidade do
Contrato de Privacidade e Segurança de Dados

iOS(SwiftUI)

Modo Foco
Tamanho da Fonte
Última atualização: 2026-03-02 17:40:30

Component Overview

ConversationList is a SwiftUI component for displaying and managing user chat conversations. It offers a full set of conversation list features, including conversation display and interactive actions.
Conversation List
Conversation Actions



Component Integration

ConversationList is part of TUIKit SwiftUI. To use ConversationList, integrate TUIKit SwiftUI into your project. For detailed integration steps, see the TUIKit SwiftUI documentation.

Component Structure

ConversationList exposes only its initialization method. All other logic is encapsulated within the component.

Public Methods

Method
Parameter
Description
init
onConversationClick: @escaping (ConversationInfo) -> Void
Initializes the component and sets the conversation click Webhook. Required.
config: ConversationActionConfigProtocol = ChatConversationActionConfig()
Initializes the component and sets the conversation action menu items. Optional.
customActions: [ConversationCustomAction] = []
Initializes the component and sets custom conversation action options. Optional.

Basic Usage

You can initialize and use the ConversationList component directly. You must implement the onConversationClick Webhook.
Parameter Name
Type
Description
onConversationClick
(ConversationInfo) -> Void
Conversation click Webhook, triggered when a user clicks a conversation cell.
Sample code:
import AtomicX
import SwiftUI

struct ContentView: View {
var body: some View {
ConversationList(
onConversationClick: { conversation in
// Recommended: Navigate to the chat page here
}
)
}
}

Customization

You can customize the action items in the conversation list using the following methods.

Method 1. Hide Conversation Action Items Locally

Pass a custom config when initializing ConversationList to control which menu items are displayed:
struct CustomConversationView: View {
var body: some View {
ConversationList(
onConversationClick: { conversation in
// Navigate on conversation cell click
},
// Hide ClearHistory
config: ChatConversationActionConfig(isSupportDelete: true, isSupportPin: true, isSupportClearHistory: false)
)
}
}
Currently Supported Menu Item Toggles
Action Type
Description
isSupportDelete
Enable or disable deleting conversations
isSupportPin
Enable or disable Pin Conversation
isSupportClearHistory
Enable or disable clearing conversation history

Method 2. Add Conversation Action Items Locally

Pass customActions when initializing ConversationList. ConversationList will display your custom options below the default actions:
Parameter Name
Type
Description
customActions
[ConversationCustomAction]
Custom conversation actions, shown when the user opens the conversation action menu.
Sample code:
struct CustomConversationView: View {
var body: some View {
ConversationList(
onConversationClick: { conversation in
onShowMessage?(NavigationInfo(conversation: conversation))
},
// Custom actions
customActions: [
ConversationCustomAction(title: "Share") { conversation in
print("Share conversation: \\(conversation.title ?? "")")
},
]
)
.conversationActions([.delete, .pin, .clearHistory])
.environmentObject(themeState)
}
}


Method 3. Global Configuration

Configure global action items using AppBuilderConfig:
// Set this at application startup; if omitted, the feature is not enabled
AppBuilderConfig.shared.conversationActionList = [
.delete, // Enable delete
.pin, // Enable Pin Conversation
.clearHistory // Enable clearing conversation messages
]

// Then initialize ConversationList; all ConversationList instances will use the above conversationActionList configuration
ConversationList(
onConversationClick: { conversation in
// Navigate to the chat page here if needed
}
)
Note:
Local configuration takes precedence over global configuration.
The following images show the customization effects:
Conversation Actions
(Default Options)
Conversation Actions
(Delete Option Hidden)
Conversation Actions
(Share Option Added)





Ajuda e Suporte

Esta página foi útil?

comentários