Chat UIKit SwiftUI v3
Chat UIKit SwiftUI
Chat UIKit
SwiftUI
Version 3

Sendbird Chat SwiftUI is a SwiftUI-based Sendbird Chat framework that provides fully functioning chat features embedded in easily customizable user interfaces. With Sendbird Chat SwiftUI, developers can build a full chat service in just a few lines of codes. The framework also provides exceptionally intuitive interfaces that allow customization of views and actions.

Build a key feature by initializing the corresponding SendbirdSwiftUI View. Use a ViewAdapter to selectively customize different components inside a View. Use DestinationViewBuilder to customize navigation behaviors between views.


Architecture

Copy link

Sendbird Chat SwiftUI uses Sendbird UIKit as its core, and the SwiftUI View wraps UIKit's ViewController to finally deliver the SwiftUI View. Almost all of the functionality available in Sendbird Chat SwiftUI is provided in a SwiftUI optimized interface.

Sendbird Chat SwiftUI provides a set of Views for each feature, and each view is an entry point that can be used to access the feature. The Views are initialized with the minimum required arguments to configure the view. The Views use the Sendbird Chat UIKit as their core and wrap the ViewController to provide the SwiftUI View. The Views are designed to process the data from the Chat SDK and configure and operate the screens.

The following diagram explains the View basic architecture of Sendbird Chat SwiftUI.

Note : Events generated by the Chat SDK and updates to related Views are handled internally. Handling internal events in SwiftUI Views is not yet supported.

The following demonstrates how to use the Sendbird Chat SwiftUI channel list View.

import SwiftUI
import SendbirdSwiftUI 

struct ContentView: View {
    var body: some View {
        GroupChannelListView()
    }
}

View customization

Copy link

Sendbird Chat SwiftUI Views are based on areas such as Header, List, and so on. These areas can be customized through parameters in each View's initializer, allowing you to replace the entire view or partial elements within the area.

For partial customization, use parameters like headerItem. Parameters that follows the form of {Component}Item are used to customize the view items in the component area through the parameters of a ViewConfig.

On the other hand, you can replace the entire view components through builders such as list. They are used to replace the entire component area with your custom SwiftUI view.

TypeDescription

Partial customization

Use parameters that follow the naming format of {Component}Item, such as headerItem. They are used to customize the view items in the component area through the parameters of a ViewConfig.

Full customization

Use parameters that follow the naming format of {Component}, such as list. They are used to replace the entire component area with your custom SwiftUI view. Both of ViewItem adapter and component modifier provide a ViewConfig, which contains the properties needed to build the view.

Note: When you customize a parent view, customizations in the child views will not be applied. For example, if you customize the titleView in the headerItem, the customizations of the coverImage or titleLabel in the lower view items will not be applied. The same goes for list and listItem.

The following diagram explains the ViewAdapter basic architecture of Sendbird Chat SwiftUI.

The following demonstrates how to replace the ViewItems in the header area of the Sendbird Chat SwiftUI channel list View.

GroupChannelListView(
    headerItem: {
        .init()
        .leftView { viewConfig in
            Text("Left")
        }
        .rightView { viewConfig in
            Text("Right")
        }
    }
)

The following demonstrates how to replace the entire list area of the Sendbird Chat SwiftUI channel list View.

GroupChannelListView(
    list: { viewConfig in
        ScrollView {
            ForEach(viewConfig.channels) { channel in
                VStack {
                    Text("\(channel.name)")
                }
            }
        }
    }
)

DestinationViewBuilder

Copy link

Sendbird Chat SwiftUI connects views to each other based on the behavior of the views. The Sendbird Chat SwiftUI View internally handles the navigation between views. Since all features are implemented by default, there is no problem using all flows without any additional processing. When you need to customize the destination view, you can do so by using the interface provided by the DestinationViewBuilder.

The following diagram explains the DestinationViewBuilder basic architecture of Sendbird Chat SwiftUI.

The following demonstrates how to replace the groupChannelView connected to the groupChannelListView in Sendbird Chat SwiftUI.

GroupChannelListView()
    .groupChannelView { channelURL, startingPoint, messageListParams in
        GroupChannelView(
            channelURL: channelURL,
            startingPoint: startingPoint,
            messageListParams: messageListParams
        )
    }

Note : If the View under the top view is customized, all destination views connected from the top view must be configured.


List of views

Copy link
Key functionViewViewAdapterDestinationViewBuilder

List channels

GroupChannelListView

headerItem, list, listItem

groupChannelView(:), createChannelView(:)

Chat in a group channel

GroupChannelView

headerItem, list, listItem, inputItem

channelSettingsView(:), messageThreadView(:)

Create a group channel

CreateGroupChannelView

headerItem, list, listItem

Configure group channel settings

GroupChannelSettingsView

headerItem, list, listItem

userListView(:), moderationsView(:), pushSettingsView(:), messageSearchView(:)

List members in a group channel

GroupMemberListView

headerItem, list, listItem

inviteUserView(_:)

Configure group channel settings

GroupChannelSettingsView

headerItem, list, listItem

userListView(:), moderationsView(:), pushSettingsView(:), messageSearchView(:)

Configure group channel push settings

GroupChannelPushSettingsView

headerItem

Moderate group channels

GroupModerationsView

headerItem

operatorListView(:), mutedMemberListView(:), bannedUserListView(_:)

Banned members in a group channel

GroupBannedUserListView

headerItem, list, listItem

Muted members in a group channel

GroupMutedMemberListView

headerItem, list, listItem

Operators in a group channel

GroupOperatorListView

headerItem, list, listItem

registerOperatorView(_:)

Register members as operators

GroupChannelRegisterOperatorView

headerItem

Search messages

MessageSearchView

headerItem

groupChannelView(_:)

Reply to messages

MessageThreadView

headerItem, parentInfoItem, list, listItem, inputItem

Invite users

InviteUserView

headerItem, list, listItem

List open channels

OpenChannelListView

headerItem, list, listItem

openChannelView(:), createChannelView(:)

Chat in an open channel

OpenChannelView

headerItem, list, listItem, inputItem

channelSettingsView(:), userListView(:)

Create an open channel

CreateOpenChannelView

headerItem

Configure open channel settings

OpenChannelSettingsView

headerItem

userListView(:), moderationsView(:)

Participants in an open channel

OpenParticipantListView

headerItem, list, listItem

Moderate open channels

OpenModerationsView

headerItem

operatorListView(:), mutedParticipantListView(:), bannedUserListView(_:)

Banned users in an open channel

OpenBannedUserListView

headerItem, list, listItem

Muted participants in an open channel

OpenMutedParticipantListView

headerItem, list, listItem

Operators in an open channel

OpenOperatorListView

headerItem, list, listItem

registerOperatorView(_:)

Register participants as operators

OpenChannelRegisterOperatorView

headerItem