Skip to content

Commit dfcf305

Browse files
Exposed configuring the jumbo emoji view
1 parent ca946e7 commit dfcf305

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ public struct MessageView<Factory: ViewFactory>: View {
8888
}
8989
} else {
9090
if message.shouldRenderAsJumbomoji {
91-
EmojiTextView(
92-
factory: factory,
91+
factory.makeEmojiTextView(
9392
message: message,
9493
scrolledId: $scrolledId,
9594
isFirst: isFirst

Sources/StreamChatSwiftUI/DefaultViewFactory.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,19 @@ extension ViewFactory {
395395
SystemMessageView(message: message.text)
396396
}
397397

398+
public func makeEmojiTextView(
399+
message: ChatMessage,
400+
scrolledId: Binding<String?>,
401+
isFirst: Bool
402+
) -> some View {
403+
EmojiTextView(
404+
factory: self,
405+
message: message,
406+
scrolledId: scrolledId,
407+
isFirst: isFirst
408+
)
409+
}
410+
398411
public func makeCustomAttachmentViewType(
399412
for message: ChatMessage,
400413
isFirst: Bool,

Sources/StreamChatSwiftUI/ViewFactory.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,18 @@ public protocol ViewFactory: AnyObject {
393393
/// - Returns: view displayed when a system message appears.
394394
func makeSystemMessageView(message: ChatMessage) -> SystemMessageViewType
395395

396+
associatedtype EmojiTextViewType: View
397+
/// Creates the view displaying emojis.
398+
/// - Parameters:
399+
/// - message: the deleted message that will be displayed with indicator.
400+
/// - scrolledId: Identifier for the message that should be scrolled to.
401+
/// - isFirst: whether it is first in the group (latest creation date).
402+
func makeEmojiTextView(
403+
message: ChatMessage,
404+
scrolledId: Binding<String?>,
405+
isFirst: Bool
406+
) -> EmojiTextViewType
407+
396408
associatedtype CustomAttachmentViewType: View
397409
/// Creates custom attachment view.
398410
/// If support for more than one custom view is needed, just do if-else check inside the view.

StreamChatSwiftUITests/Tests/Utils/ViewFactory_Tests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,21 @@ class ViewFactory_Tests: StreamChatTestCase {
700700
// Then
701701
XCTAssert(view is EmptyView)
702702
}
703+
704+
func test_viewFactory_makeEmojiTextView() {
705+
// Given
706+
let viewFactory = DefaultViewFactory.shared
707+
708+
// When
709+
let view = viewFactory.makeEmojiTextView(
710+
message: message,
711+
scrolledId: .constant(nil),
712+
isFirst: true
713+
)
714+
715+
// Then
716+
XCTAssert(view is EmojiTextView<DefaultViewFactory>)
717+
}
703718
}
704719

705720
extension ChannelAction: Equatable {

0 commit comments

Comments
 (0)