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

Configure group channel settings

Copy link

In Sendbird Chat SwiftUI, you can configure channel settings in group channels through the GroupChannelSettingsView structure. In the group channel settings view, you can change the channel name and cover image, see the member list, and more.

Note: If you set the starting point of your chat service to be the channel list or group channel, you can seamlessly guide your users to the channel settings view.


Initialize

Copy link

You can start building a group channel settings view through the GroupChannelSettingsView structure. Use the init(channelURL:) initializer to create the instance and display the view.

import SwiftUI
import SendbirdSwiftUI

struct ContentView: View {
    var body: some View {
        GroupChannelSettingsView(channelURL: {CHANNEL_URL})
    }
}

Init parameter

Copy link
ParameterTypeRequired

channelURL

String

o


Customization

Copy link

Sendbird Chat SwiftUI provides a View customization and DestinationViewBuilder.

  • View customization: Our SwiftUI SDK allows you to selectively customize view elements. To learn more about the customization and our SwiftUI is designed, see the customization guide.
  • DestinationViewBuilder: Use DestinationViewBuilder to customize the destination views that are navigatable from the group channel view.

Note : Visit our Github Sample to see the custom sample implementation for each item.

Partial customization

Copy link

You can easily customize a specific part of a View, which particularly comes in handy when changing only a certain area in the View. To do so, use the View Builders that Sendbird has predefined and its a ViewConfig. The ViewConfig contains the data needed to render the view and its parameters can be found in the table below.

Parameter

Copy link
ParameterTypeView builders

headerItem

() -> GroupChannelSettingsType.HeaderItem

leftView
rightView
titleView

listItem

() -> GroupChannelSettingsType.ListItem

channelInfo
moderationRow
notificationRow
memberRow
searchRow
leaveChannelRow

The following code demonstrates how to replace the view items using headerItem. All other {Component}Items can be used in the same way.

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.

GroupChannelSettingsView(
    channelURL: {CHANNEL_URL},
    headerItem: {
        .init()
        .leftView { viewConfig in
            Text("Left")
        }
        .rightView { viewConfig in // chaining
            Text("Right")
        }
    }
)

Full customization

Copy link

You can also customize the entire view area as desired. You simply need to return a SwiftUI View in the closure. The ViewConfig contains the data needed to render the view. Its parameters can be found in the table below.

Parameter

Copy link
ParameterTypeView builders

list

(ViewConfig) -> some View

-

The following code demonstrates how to replace the entire list area using the list parameter.

Note : When you customize a parent view, customizations in the child views will not be applied. For example, if you customize the entire area through the list, the customizations set in the listItem will not be applied.

GroupChannelSettingsView(
    list: { viewConfig in
        VStack {
            Text(viewConfig.channel.name)
            Text("\(viewConfig.channel.memberCount)")
        }
    }
)

Note: The messages in viewConfig are sorted in descending timestamp. This means that the latest message appears first in the array.

DestinationViewBuilder

Copy link

Sendbird Chat SwiftUI is designed to internally navigate from each view to its connected view. However, if you need to customize the destination view, you can do so by using the interface provided by the DestinationViewBuilder.

DestinationViewBuilder method

Copy link
MethodViewBuilder type

userListView

GroupUserListViewBuilder

moderationsView

GroupModerationsViewBuilder

pushSettingsView

GroupChannelPushSettingsViewBuilder

messageSearchView

MessageSearchViewBuilder

The following code demonstrates how to replace the channel settings view connected from the channel view.

GroupChannelSettingsView(channelURL: {CHANNEL_URL})
    .userListView { channelURL in
        GroupUserListView(channelURL: channelURL)
    }

Note : If you've customized a child view of another view, you need to set the destination view for all the views from the top to the destination view.