Moderate group channels and members
You can moderate group channels and members in UIKit through the SBUModerationsViewController
class. This class is used to display a moderation view for operators, muted members, and banned users, and the option to freeze the channel.
Note: By default, the moderation menu in
SBUGroupChannelSettingsViewController
is accessible for operators only.
Initialize
You can start building a moderation view through the SBUModerationsViewController
class. Use either the init(channelURL:)
or init(channel:)
initializer to create the instance and display the view as shown below.
Usage
The following items are key elements of SBUModerationsViewController
that are used to create a functional moderation view.
Module components
In the SBUModerationsViewController
class, SBUModerationsModule
and its components are used to create the moderation view. The module is composed of two components: HeaderComponent
and ListComponent
.
Property name | Type | Default value |
---|---|---|
HeaderComponent | SBUModerationsModule.Header | SBUModuleSet.GroupModerationsModule.HeaderComponent |
ListComponent | SBUModerationsModule.List | SBUModuleSet.GroupModerationsModule.ListComponent |
Each module component is assigned a value from the SBUModuleSet
class and gets added to the view in the setupView()
method of the Sendbird UIKit's view life cycle. Then, the configure method of each module component is called to set the property values and display the view.
HeaderComponent
The HeaderComponent
includes a channel title and a back button that takes the user to the previous view. Each property corresponds to the elements in the navigation bar of SBUModerationsViewController
.
The following table shows the parameters of the configure
method of the HeaderComponent
.
Parameter name | Type |
---|---|
delegate | SBUModerationsModuleHeaderDelegate |
theme | SBUChannelSettingsTheme |
Note: To learn more about the delegate and the properties of the
HeaderComponent
, go to the API reference page.
ListComponent
The ListComponent
shows the moderation menu, which contains a list of operators, muted members, banned users, and the option to freeze the channel. The following table shows the parameters of the configure
method of the ListComponent
.
Parameter name | Type |
---|---|
delegate | SBUModerationsModuleListDelegate |
dataSource | SBUModerationsModuleListDataSource |
theme | SBUChannelSettingsTheme |
Note: To learn more about the delegate, data source, and the properties of the
ListComponent
, go to the API reference page.
View model
The SBUModerationsViewController
class uses a view model that is a type of the SBUModerationsViewModel
class. The view model is created in the initializer of the view controller through the createViewModel(channel:)
and createViewModel(channelURL:channelType:)
methods. When the view model object is created, it retrieves moderation data from Chat SDK to the view controller and updates the view through the moderationsViewModel(_:didChangeChannel:withContext:)
event.
Note: If the value of
channel
orchannelURL
is invalid, the view model cannot retrieve the moderation menu.
The following table shows the parameters of the createViewModel
method.
Parameter name | Type | Description |
---|---|---|
channel | BaseChannel | Specifies the channel value. (Default: |
channelURL | String | Specifies the URL of the channel. (Default: |
Note: To learn more about the methods and the event delegates of the view model, go to this API reference page.
SBUModerationsViewController properties
To learn more about the properties of SBUModerationsViewController
, go to the API reference page.
Customization
You can customize the moderation view by changing the view controller, module component, and view model that correspond to this key function.
View controller
There are two ways to customize the view controller: change the default view controller value in the global SBUViewControllerSet
class or set a single-use custom view controller in the key function.
The custom view controller in the code below is used in the following customization examples.
- Change the value of
SBUViewControllerSet.GroupModerationsViewController
.
- Use a one-time custom view controller in the moderation view.
Module component
There are two ways to customize a module component: change the default module component type in the global SBUModuleSet.GroupModerationsModule
class or set a single-use custom module component in the view controller.
The custom header component in the code below is used in the following customization examples.
- Change the value of
SBUModuleSet.GroupModerationsModule.HeaderComponent
.
- Change the module component in
SBUModerationsViewController
.
Note: To learn more about the methods of
SBUModerationsModule
, go to the API reference page.
View model
In order to use a customized view model or customize the existing view model's event delegate, you must override the view controller.
- Use a customized view model.
- Customize the view model's event delegate.