Use the ChatFeedViewBuilder protocol to define how to render each chat feed element.
nonerenders an empty view.existingrenders our default view.replacerenders the view you provide. For the elements that you set toreplace, you must provide a view to render instead of the default view.
struct MyEntryViewBuilder: ChatFeedViewBuilder {
var renderMode: RenderModeClosure? {
return { model in
guard let entryModel = model as? ConversationEntryModel else { return .existing }
switch entryModel.entry.type {
case .participantChanged:
if let changed = entryModel.entry.payload as? ParticipantChanged {
if changed.operations.first?.type == .add { return .existing }
else { return .none }
} else {
return .existing
}
default: return .replace
}
}
}
var completeView: CompleteViewClosure? {
return { model, client in
guard let entryModel = model as? ConversationEntryModel else { return Color.red }
switch entryModel.entry.format {
case .textMessage: return Color.green
case .listPicker: return Color.yellow
default: return Color.blue
}
}
}
}
The preceding example shows how you can use logic on the participantChanged event to set different render modes. It also shows how you can replace the text messages with a green bar and the list pickers with a yellow bar. Similarly, you can define your unique views or our default views for each chat element.