Skip to content

Commit 7d49ef1

Browse files
Exposed few methods as public
1 parent b41e196 commit 7d49ef1

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChannelHeader/ChatChannelHeaderViewModifier.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ public struct DefaultChatChannelHeader: ToolbarContent {
4141
public var channel: ChatChannel
4242
public var headerImage: UIImage
4343

44+
public init(channel: ChatChannel, headerImage: UIImage) {
45+
self.channel = channel
46+
self.headerImage = headerImage
47+
}
48+
4449
public var body: some ToolbarContent {
4550
ToolbarItem(placement: .principal) {
4651
VStack(spacing: 2) {

Sources/StreamChatSwiftUI/ChatChannel/Utils/ChatChannelExtensions.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extension ChatChannel {
1111
/// - Parameters:
1212
/// - currentUserId: the id of the current user.
1313
/// - Returns: the online info text string.
14-
func onlineInfoText(currentUserId: String) -> String {
14+
public func onlineInfoText(currentUserId: String) -> String {
1515
if isDirectMessageChannel {
1616
guard let member = lastActiveMembers
1717
.first(where: { $0.id != currentUserId })
@@ -36,7 +36,7 @@ extension ChatChannel {
3636
/// - Parameters:
3737
/// - currentUserId: the id of the current user.
3838
/// - Returns: Array of users that are currently typing.
39-
func currentlyTypingUsersFiltered(currentUserId: UserId?) -> [ChatUser] {
39+
public func currentlyTypingUsersFiltered(currentUserId: UserId?) -> [ChatUser] {
4040
currentlyTypingUsers.filter { user in
4141
user.id != currentUserId
4242
}
@@ -46,7 +46,7 @@ extension ChatChannel {
4646
/// - Parameters:
4747
/// - currentUserId: the id of the current user.
4848
/// - Returns: the typing indicator string.
49-
func typingIndicatorString(currentUserId: UserId?) -> String {
49+
public func typingIndicatorString(currentUserId: UserId?) -> String {
5050
let typingUsers = currentlyTypingUsersFiltered(currentUserId: currentUserId)
5151
if let user = typingUsers.first(where: { user in user.name != nil }), let name = user.name {
5252
return L10n.MessageList.TypingIndicator.users(name, typingUsers.count - 1)

docusaurus/docs/iOS/swiftui/components/channel-header.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ public struct CustomChatChannelHeader: ToolbarContent {
7777

7878
Our custom header implementation exposes an onTapTrailing callback, that will be called when the trailing button is tapped (for example for displaying an edit view). The implementation of this button will be done in a `ViewModifier`, since the `ToolbarContent` can't keep `@State` variables.
7979

80-
The next step is to provide a new implementation of the `ChannelHeaderViewModifier`. In our case, we need to provide handling for the onTapTrailing method from the `CustomChatChannelHeader`. To do this, we will introduce a new `@State` variable in the modifier and change its state to true when the button is tapped.
80+
The next step is to provide a new implementation of the `ChatChannelHeaderViewModifier`. In our case, we need to provide handling for the onTapTrailing method from the `CustomChatChannelHeader`. To do this, we will introduce a new `@State` variable in the modifier and change its state to true when the button is tapped.
8181

8282
```swift
83-
struct CustomChannelModifier: ChannelHeaderViewModifier {
83+
struct CustomChannelModifier: ChatChannelHeaderViewModifier {
8484

8585
var channel: ChatChannel
8686

@@ -111,7 +111,7 @@ class CustomFactory: ViewFactory {
111111

112112
public static let shared = CustomFactory()
113113

114-
func makeChannelHeaderViewModifier(for channel: ChatChannel) -> some ChannelHeaderViewModifier {
114+
func makeChannelHeaderViewModifier(for channel: ChatChannel) -> some ChatChannelHeaderViewModifier {
115115
CustomChannelModifier(channel: channel)
116116
}
117117

0 commit comments

Comments
 (0)