Skip to content

Commit 163fbfa

Browse files
made the send in channel view injectable
1 parent d80bd98 commit 163fbfa

File tree

6 files changed

+25
-3
lines changed

6 files changed

+25
-3
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChatChannelViewModel.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Nuke
77
import StreamChat
88
import SwiftUI
99

10+
/// View model for the `ChatChannelView`.
1011
public class ChatChannelViewModel: ObservableObject, MessagesDataSource {
1112

1213
@Injected(\.chatClient) private var chatClient

Sources/StreamChatSwiftUI/ChatChannel/Composer/MessageComposerView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ public struct MessageComposerView<Factory: ViewFactory>: View, KeyboardReadable
5858
.padding(.all, 8)
5959

6060
if viewModel.sendInChannelShown {
61-
SendInChannelView(
62-
sendInChannel: $viewModel.showReplyInChannel,
61+
factory.makeSendInChannelView(
62+
showReplyInChannel: $viewModel.showReplyInChannel,
6363
isDirectMessage: viewModel.isDirectChannel
6464
)
6565
}

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageRepliesView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import StreamChat
66
import SwiftUI
77

8+
/// View shown below a message, when there are replies to it.
89
struct MessageRepliesView<Factory: ViewFactory>: View {
910

1011
@Injected(\.fonts) private var fonts

Sources/StreamChatSwiftUI/ChatChannel/Reactions/MessageActions/MessageActionsViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public struct MessageAction: Identifiable, Equatable {
2727

2828
public let title: String
2929
public let iconName: String
30-
public var action: () -> Void
30+
public let action: () -> Void
3131
public let confirmationPopup: ConfirmationPopup?
3232
public let isDestructive: Bool
3333
public var navigationDestination: AnyView?

Sources/StreamChatSwiftUI/DefaultViewFactory.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,16 @@ extension ViewFactory {
394394
AssetsAccessPermissionView()
395395
}
396396

397+
public func makeSendInChannelView(
398+
showReplyInChannel: Binding<Bool>,
399+
isDirectMessage: Bool
400+
) -> some View {
401+
SendInChannelView(
402+
sendInChannel: showReplyInChannel,
403+
isDirectMessage: isDirectMessage
404+
)
405+
}
406+
397407
public func supportedMessageActions(
398408
for message: ChatMessage,
399409
channel: ChatChannel,

Sources/StreamChatSwiftUI/ViewFactory.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,16 @@ public protocol ViewFactory: AnyObject {
386386
onError: @escaping (Error) -> Void
387387
) -> [MessageAction]
388388

389+
associatedtype SendInChannelViewType: View
390+
/// Creates the view that allows thread messages to be sent in a channel.
391+
/// - Parameters:
392+
/// - showReplyInChannel: whether the message should be send also in the channel.
393+
/// - isDirectMessage: whether the message is direct.
394+
func makeSendInChannelView(
395+
showReplyInChannel: Binding<Bool>,
396+
isDirectMessage: Bool
397+
) -> SendInChannelViewType
398+
389399
associatedtype MessageActionsViewType: View
390400
/// Creates the message actions view.
391401
/// - Parameters:

0 commit comments

Comments
 (0)