List channels
A channel list shows a complete list of group channels that the current user is a member of. Once a connection with the Sendbird server is established, you can display and manage the channel list without complex implementation. All chat services built with Sendbird UIKit begin from the channel list. Note that it can only list channels that the current user is a member of and can't list other public channels the user hasn't joined.
Usage
You can start building a channel list screen by first creating a fragment. To do so, call the createGroupChannelListFragment
method and display the current user's channel list. Once a channel list fragment is built, you need to set up the navigation props and register the screen to a navigation library. Refer to the code below.
List of properties
The following table lists the properties of GroupChannelListFragment
.
Properties
Required | Type | Description |
---|---|---|
onPressChannel | function | Specifies the prop to execute a custom navigation operation when one of the channels in a channel list is selected. By default, the screen changes to the group channel fragment. |
onPressCreateChannel | function | Specifies the prop to execute a custom navigation operation with a create new channel button in the upper right corner of the screen. By default, the create group channel screen will appear. |
Optional | Type | Description |
---|---|---|
channelListQueryParams | object | Specifies the prop to set the query parameters for the channel list. |
renderGroupChannelPreview | function | Renders a customized channel preview component to replace the default |
skipTypeSelection | boolean | Determines whether to create a group channel without selecting a channel type. |
flatListProps | object | Specifies a FlatList prop that renders a list view in the list component of |
menuItemCreator | function | Specifies a function that creates a custom action menu when a user long taps on a specific channel in the channel list. You can customize the list of action items in the menu. |
| function | (Deprecated) Creates and returns a custom channel list collection to retrieve a list of group channels. |
Context
To store and handle data that are used to build a working channel list, Sendbird UIKit provides GroupChannelListContexts
, which is comprised of two context objects: GroupChannelListContexts.Fragment
and GroupChannelListContexts.TypeSelector
.
Fragment
To retrieve data from the Chat SDK on the current user's channel list screen, you need to call the useContext
hook and pass GroupChannelListContexts.Fragment
as a parameter. The data is then used to render the channel list module and its components.
TypeSelector
You can call the useContext
hook and pass GroupChannelListContexts.TypeSelector
as a parameter to retrieve data from the Chat SDK on the channel type.
Module components
A channel list screen is composed of four module components: header, list, type selector, loading status, and empty status. These components make up the GroupChannelListModule
and are used to create and display the channel list UI.
Header
The header component displays the title of the channel list screen and a button on the top right corner which, by default, allows you to choose the type of channel you wish to create. Once the channel type is selected, the onPressCreateChannel
navigation prop is called and you'll be able to create a new channel in the create group channel screen.
List
The list component displays a list of all channels that the current user is part of. When the current user selects one of the channels in the list, they'll be able to enter the channel and start chatting in a group channel.
List of properties
The following table lists the properties of GroupChannelListModule.List
.
Property name | Type | Description |
---|---|---|
groupChannels | array of objects | Specifies a list of all group channels that the current user is a member of. |
onLoadNext | function | Specifies the prop to execute custom operations when loading more channel list items. |
renderGroupChannelPreview | function | Renders a customized channel preview component to replace the default |
menuItemCreator | function | Specifies a function that creates a custom action menu when a user long taps on a channel preview in the channel list. You can customize the list of action items in the menu. |
flatListProps | object | Specifies a FlatList prop that renders a list view in the list component of |
TypeSelector
The TypeSelector
component exists in the GroupChannelListModule
and lets the user choose between group channel and Supergroup channel to create a new channel with.
List of properties
The following table lists the properties of TypeSelector
.
Property name | Type | Description |
---|---|---|
skipTypeSelection | boolean | Determines whether to create a group channel without selecting a channel type. |
onSelectType | function | Specifies the prop to execute custom operations when the channel type is selected. Based on the selected type, the |
StatusLoading
The StatusLoading
component exists in the GroupChannelListModule
and lets the user know if the list is loading.
StatusEmpty
The StatusEmpty
component exists in the GroupChannelListModule
and lets the user know if the list is empty.
Customization
In the list channel function, you can customize the default GroupChannelListFragment
to change various elements of the screen such as the module and its components. See the code below on how to replace the default header component with a custom header component in GroupChannelListFragment
as an example.
Note: To learn more about how to customize a fragment, go to the fragment page.