List open channels
A channel list shows a complete list of open channels available for the current user. 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.
Usage
You can start building a channel list screen by first creating a fragment. To do so, call the createOpenChannelListFragment
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 OpenChannelListFragment
.
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 open 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 open channel screen will appear. |
Optional | Type | Description |
---|---|---|
renderOpenChannelPreview | function | Renders a customized channel preview component to replace the default |
queryCreator | object | Specifies query parameters for the channel list. |
flatListProps | object | Specifies a FlatList prop that renders a list view in the list component of |
Context
To store and handle data that are used to build a working channel list, Sendbird UIKit provides OpenChannelListContexts
, which is comprised of a single object: OpenChannelListContexts.Fragment
.
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 OpenChannelListContexts.Fragment
as a parameter. The data is then used to render the channel list module and its components.
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 OpenChannelListModule
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 open 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 an open channel.
List of properties
The following table lists the properties of OpenChannelListModule.List
.
Property name | Type | Description |
---|---|---|
openChannels | array of objects | Specifies a list of all open channels. |
onLoadNext | function | Specifies the prop to execute custom operations when loading more channel list items. |
renderOpenChannelPreview | 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 |
StatusLoading
The StatusLoading
component exists in the OpenChannelListModule
and lets the user know if the list is loading.
StatusEmpty
The StatusEmpty
component exists in the OpenChannelListModule
and lets the user know if the list is empty.
Customization
In the list channel function, you can customize the default OpenChannelListFragment
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 OpenChannelListFragment
as an example.
Note: To learn more about how to customize a fragment, go to the fragment page.