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

Invite users

Copy link

In Sendbird Chat SwiftUI, you can invite users to a group channel through the InviteUserView. The view displays a list of users who aren't in the channel and invite them. Unless you have a specific list of users you selected, all users who are using your chat service is displayed in the user list by default.

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


Initialize

Copy link

You can start building an invite users view through the InviteUserView. Use the init(channelURL:users:) initializer to create the instance and display the view as shown below.

import SwiftUI
import SendbirdUI

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

Init parameters

Copy link
ParameterTypeRequired

channelURL

String

o

users

[SBUUser]

x


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 items

headerItem

InviteUserType.HeaderItem

leftView
rightView
titleView

listItem

InviteUserType.ListItem

rowView
- profileImage
- userName
- selectionButton

list

Closure

-

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.

InviteUserView(
    channelURL: {CHANNEL_URL},
    users: [{MEMBER}]
    headerItem: {
        .init()
        .leftView { viewConfig in
            Text("Custom Left")
        }
        .rightView { viewConfig in // chaining
            Text("Custom 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.

InviteUserView(
    channelURL: {CHANNEL_URL},
    users: [{USER}],
    list: { viewConfig in
        List(viewConfig.users) { user in
            Text(user.nickname)
        }
    }
)

DestinationViewBuilder

Copy link

This screen has no DestinationViewBuilder because there's no navigational elements, such as buttons or links to other screens.