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

Reply to messages

Copy link

Members of a group or supergroup channel can reply to each others' messages in a thread using the MessageThreadView structure. When a user taps Reply in thread in the Message menu of a user or file message in the GroupChannelView class, the thread view appears. In the new thread, users can start a separate conversation in response to the parent message.


Initialize

Copy link

You can start building a thread view by initializing the MessageThreadView structure.

import SwiftUI
import SendbirdSwiftUI

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

Init parameters

Copy link
ParameterTypeRequired

channelURL

String

o

parentMessageId

Int64

o

delegate

SBUMessageThreadViewControllerDelegate

x

threadedMessageListParams

ThreadedMessageListParams

x

startingPoint

Int64

x

voiceFileInfos

[String: SBUVoiceFileInfo]

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

() -> MessageThreadType.HeaderItem

leftView
rightView
titleView
- coverImage
- titleLabel
- typingStatusView

parentInfoItem

() -> MessageThreadType.ParentInfoItem

parentInfoView
- profileView
- userNameLabel
- dateLabel
- moreButton
- replyLabel
- messageTextView
- fileContentView
- multipleFilesContentView
- webView
- reactionView

listItem

() -> MessageThreadType.ListItem

rowView
- senderProfileImage
- userMessageView
- fileMessageView
- multipleFilesMessageView
- channelStateBanner

inputItem

() -> MessageThreadType.InputItem

leftView
- addButton
rightView
- sendButton
- voiceButton

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.

var body: some View {
    MessageThreadView(
        channelURL: {CHANNEL_URL},
        parentMessageId: {PARENT_MESSAGE_ID},
        headerItem: {
            .init()
            .leftView { config in
                Text("Left")
                    .foregroundStyle(.blue)
            }
        }
    )
}

DestinationViewBuilder

Copy link

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