Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Add support for customising the `MessageAvatarView` placeholder [#878](https://github.com/GetStream/stream-chat-swiftui/pull/878)
- Add `ViewFactory.makeVideoPlayerFooterView` to customize video player footer [#879](https://github.com/GetStream/stream-chat-swiftui/pull/879)
- Add `utils.channelListConfig.channelItemMutedLayoutStyle` [#881](https://github.com/GetStream/stream-chat-swiftui/pull/881)
- Add jumping to pinned message when tapping a message in the pinned messages view [#884](https://github.com/GetStream/stream-chat-swiftui/pull/884)

### 🔄 Changed
- From now on, jumping to a message will centre it in the middle instead of at the top [#884](https://github.com/GetStream/stream-chat-swiftui/pull/884)

# [4.81.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.81.0)
_July 03, 2025_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ import SwiftUI
/// View displaying pinned messages in the chat info screen.
public struct PinnedMessagesView<Factory: ViewFactory>: View {
@Injected(\.images) private var images
@Injected(\.utils) private var utils
@Injected(\.chatClient) private var chatClient

@StateObject private var viewModel: PinnedMessagesViewModel

let factory: Factory
private let channel: ChatChannel

public init(
factory: Factory = DefaultViewFactory.shared,
Expand All @@ -24,6 +27,7 @@ public struct PinnedMessagesView<Factory: ViewFactory>: View {
channelController: channelController
)
)
self.channel = channel
self.factory = factory
}

Expand All @@ -33,7 +37,27 @@ public struct PinnedMessagesView<Factory: ViewFactory>: View {
ScrollView {
LazyVStack(spacing: 0) {
ForEach(viewModel.pinnedMessages) { message in
PinnedMessageView(factory: factory, message: message, channel: viewModel.channel)
ZStack {
PinnedMessageView(factory: factory, message: message, channel: viewModel.channel)
.contentShape(Rectangle())
.onTapGesture {
viewModel.selectedMessage = message
}
NavigationLink(
tag: message,
selection: $viewModel.selectedMessage
) {
LazyView(
makeMessageDestination(message: message)
.modifier(HideTabBarModifier(
handleTabBarVisibility: utils.messageListConfig.handleTabBarVisibility
))
)
} label: {
EmptyView()
}
.opacity(0) // Fixes showing accessibility button shape
}
Divider()
}
}
Expand All @@ -49,6 +73,26 @@ public struct PinnedMessagesView<Factory: ViewFactory>: View {
}
.navigationTitle(L10n.ChatInfo.PinnedMessages.title)
}

private func makeMessageDestination(message: ChatMessage) -> ChatChannelView<Factory> {
let channelController = utils.channelControllerFactory
.makeChannelController(for: channel.cid)

var messageController: ChatMessageController?
if let parentMessageId = message.parentMessageId {
messageController = chatClient.messageController(
cid: channel.cid,
messageId: parentMessageId
)
}

return ChatChannelView(
viewFactory: factory,
channelController: channelController,
messageController: messageController,
scrollToMessage: message
)
}
}

struct PinnedMessageView<Factory: ViewFactory>: View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public class PinnedMessagesViewModel: ObservableObject {
let channel: ChatChannel

@Published var pinnedMessages: [ChatMessage]

@Published var selectedMessage: ChatMessage?

private var channelController: ChatChannelController?

public init(channel: ChatChannel, channelController: ChatChannelController? = nil) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public struct MessageListConfig {
maxTimeIntervalBetweenMessagesInGroup: TimeInterval = 60,
cacheSizeOnChatDismiss: Int = 1024 * 1024 * 100,
iPadSplitViewEnabled: Bool = true,
scrollingAnchor: UnitPoint = .bottom,
scrollingAnchor: UnitPoint = .center,
showNewMessagesSeparator: Bool = true,
handleTabBarVisibility: Bool = true,
messageListAlignment: MessageListAlignment = .standard,
Expand Down
Loading