Screens
UIKit v3 for Android allows you to create customizable views and execute essential chat functions such as list channels, create channels, and chat in channels. Key functions are carried out on a screen basis, meaning each function corresponds to a single screen. A key function is composed of three main components: Fragment, Module, and ViewModel
. Each fragment has a corresponding module that creates the view, and each module is made up of customizable UI components. A fragment also has a corresponding ViewModel
that provides the necessary data from Sendbird Chat SDK. Refer to the table below to see which key functions we provide and the components that make up each key function.
List of screens
Key function | Fragment | Module | Component | ViewModel |
---|---|---|---|---|
ChannelListFragment | ChannelListModule | HeaderComponent | ChannelListViewModel | |
ChannelFragment | ChannelModule | ChannelHeaderComponent | ChannelViewModel | |
OpenChannelFragment | OpenChannelModule | OpenChannelHeaderComponent | OpenChannelViewModel | |
CreateChannelFragment | CreateChannelModule | SelectUserHeaderComponent | CreateChannelViewModel | |
ChannelSettingsFragment | ChannelSettingsModule | ChannelSettingsHeaderComponent | ChannelSettingsViewModel | |
OpenChannelSettingsFragment | OpenChannelSettingsModule | OpenChannelSettingsHeaderComponent | OpenChannelSettingsViewModel | |
InviteUserFragment | InviteUserModule | SelectUserHeaderComponent | InviteUserViewModel | |
RegisterOperatorFragment | RegisterOperatorModule | SelectUserHeaderComponent | RegisterOperatorViewModel | |
OpenChannelRegisterOperatorFragment | OpenChannelRegisterOperatorModule | SelectUserHeaderComponent | OpenChannelRegisterOperatorViewModel | |
MemberListFragment | MemberListModule | HeaderComponent | MemberListViewModel | |
ParticipantsListFragment | ParticipantListModule | HeaderComponent | ParticipantListViewModel | |
BannedUserListFragment | BannedUserListModule | HeaderComponent | BannedUserListViewModel | |
OpenChannelBannedUserListFragment | OpenChannelBannedUserListModule | HeaderComponent | OpenChannelBannedUserListViewModel | |
MutedMemberListFragment | MutedMemberListModule | HeaderComponent | MutedMemberListViewModel | |
OpenChannelMutedParticipantListFragment | OpenChannelMutedParticipantListModule | HeaderComponent | OpenChannelMutedParticipantListViewModel | |
OperatorListFragment | OperatorListModule | HeaderComponent | OperatorListViewModel | |
OpenChannelOperatorListFragment | OpenChannelOperatorListModule | HeaderComponent | OpenChannelOperatorListViewModel | |
ModerationFragment | ModerationModule | HeaderComponent | ModerationViewModel | |
OpenChannelModerationFragment | OpenChannelModerationModule | HeaderComponent | OpenChannelModerationViewModel | |
MessageSearchFragment | MessageSearchModule | MessageSearchHeaderComponent | MessageSearchViewModel | |
MessageThreadFragment | MessageThreadModule | MessageThreadHeaderComponent | MessageThreadViewModel |
Architecture
In a key function, fragment plays the most important role because it needs to create a module and ViewModel
in order to build the whole screen and gather data from the Chat SDK. The following diagram explains the basic architecture of UIKit for Android.
UIKit for Android provides both activity and fragment for each key function. An activity allows you to build a single screen and it contains multiple fragments that enable you to divide the UI for more discrete customization. But in UIKit for Android, there is one fragment for every activity, which means the fragment takes up the whole screen. We offer both activity and fragment so you can choose which one to build your app with. You may solely use activity instead of fragment if you wish to.
As shown in the diagram above, each fragment generates a module to build a view. A module is composed of several components, which combined together, make up a single screen. You can customize the view on a component-level, allowing you to easily make small style changes.
Fragments also need to create and use ViewModel
to communicate with the Chat SDK. The ViewModel
manages data received from the SDK, which are necessary to perform key functions in the screen. You can customize the ViewModel
to change how you wish to receive and process data. The fragment plays a binding role between data provided by the ViewModel
and view created by the module.
BaseModuleFragment lifecycle
All fragments in the UIKit inherit a BaseModuleFragment
class, which creates the modules, UI components, and ViewModel
in a set process as shown in the flow diagram below. BaseModuleFragment
manages and controls the lifecycle of all fragments in the UIKit.
Note: The result of whether the
ViewModel
has been authenticated or not is always called after a view has been built using theonCreateView
method.
When the onCreate
method of a fragment is called, the onCreateModule
, onConfigureParams
, and onCreateViewModel
methods of BaseModuleFragment
are also called. The onCreateModule
method creates a module for the fragment to build a view, while the onCreateViewModel
method creates a ViewModel
that communicates with the Chat SDK. By calling onConfigureParams
, you can configure parameters in the setter methods of each module or component. It is strongly recommended that the parameters in the setter methods are set before creating a view.
Once the module and its UI components have been created, the fragment calls the onCreateView
method that exists in the module and the UI components to build a view. The returned view of the module is then used by the fragment.
After a ViewModel
has been created, the fragment's onCreate
method requires the ViewModel
to be authenticated. To authenticate, the connect()
method of Chat SDK is called and requests connection to Sendbird server. Depending on whether the corresponding key function requires any channel information, the server can retrieve such channel data during the authentication process.
Once the ViewModel
is authenticated, the onBeforeReady
method is called right before the onReady
method. Using onBeforeReady
, you can change the setter methods of each component in a module.
Lastly, the onReady
method is called when the initialization process of the module and its components are finished and the authentication process of the ViewModel
is done. You can find out whether everything has been properly initialized and authenticated through the ReadyStatus
property sent to the onReady
method.
Once the entire process is finished, the fragment's lifecycle will initialize. The following table shows all methods of the BaseModuleFragment
lifecycle.
List of methods of BaseModuleFragment
Methods | Description |
---|---|
onCreateViewModel | Creates a |
onCreateModule | Creates a module that builds the view used in a fragment. This method is called when the |
onConfigureParams | Specifies a set of parameters to change in the module. This method is called when the |
onBeforeReady | Changes the setter methods related to |
onReady | Indicates that the initialization process of the module and its components are finished and the authentication process of the |