diff --git a/CHANGELOG.md b/CHANGELOG.md index b25f0ee1..2fe050ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Add support for overriding `onImageTap` in `LinkAttachmentView` [#986](https://github.com/GetStream/stream-chat-swiftui/pull/986) - Add support for customizing text colors in `LinkAttachmentView` [#992](https://github.com/GetStream/stream-chat-swiftui/pull/992) - Expose `MediaAttachment` properties and initializer [#1000](https://github.com/GetStream/stream-chat-swiftui/pull/1000) +- Add `ColorPalette.navigationBarGlyph` for configuring the glyph color for buttons in navigation bars [#999](https://github.com/GetStream/stream-chat-swiftui/pull/999) +- Allow overriding `ChatChannelInfoViewModel` properties: `shouldShowLeaveConversationButton`, `canRenameChannel`, and `shouldShowAddUserButton` [#995](https://github.com/GetStream/stream-chat-swiftui/pull/995) ### 🐞 Fixed - Fix openChannel not working when searching or another chat shown [#975](https://github.com/GetStream/stream-chat-swiftui/pull/975) @@ -20,6 +22,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix random scroll after marking a message unread [#989](https://github.com/GetStream/stream-chat-swiftui/pull/989) - Fix marking channel read when the user scrolls to the bottom after marking a message as unread [#989](https://github.com/GetStream/stream-chat-swiftui/pull/989) - Fix replying to unread messages marking them instantly as read [#989](https://github.com/GetStream/stream-chat-swiftui/pull/989) +- Fix rendering of the add users button on iOS 26 [#999](https://github.com/GetStream/stream-chat-swiftui/pull/999) +- Use `ColorPalette.navigationBarTint` for the background of the add users button [#999](https://github.com/GetStream/stream-chat-swiftui/pull/999) # [4.89.1](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.89.1) _September 23, 2025_ diff --git a/DemoAppSwiftUI/ChannelHeader/CustomChannelHeader.swift b/DemoAppSwiftUI/ChannelHeader/CustomChannelHeader.swift index 4c07615d..b3e7dc1d 100644 --- a/DemoAppSwiftUI/ChannelHeader/CustomChannelHeader.swift +++ b/DemoAppSwiftUI/ChannelHeader/CustomChannelHeader.swift @@ -31,7 +31,7 @@ public struct CustomChannelHeader: ToolbarContent { .resizable() .scaledToFit() .frame(width: 24, height: 24) - .foregroundColor(Color.white) + .foregroundColor(Color(colors.navigationBarGlyph)) .padding(.all, 8) .background(colors.navigationBarTintColor) .clipShape(Circle()) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift index 7c0d9abc..a6a8837d 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift @@ -141,38 +141,7 @@ public struct ChatChannelInfoView: View, KeyboardReadable } } } - .toolbarThemed { - ToolbarItem(placement: .principal) { - Group { - if viewModel.showSingleMemberDMView { - Text(viewModel.displayedParticipants.first?.chatUser.name ?? "") - .font(fonts.bodyBold) - .foregroundColor(Color(colors.navigationBarTitle)) - } else { - ChannelTitleView( - channel: viewModel.channel, - shouldShowTypingIndicator: false - ) - .id(viewModel.channelId) - } - } - } - - ToolbarItem(placement: .navigationBarTrailing) { - if viewModel.shouldShowAddUserButton { - Button { - viewModel.addUsersShown = true - } label: { - Image(systemName: "person.badge.plus") - .customizable() - .foregroundColor(Color.white) - .padding(.all, 8) - .background(colors.tintColor) - .clipShape(Circle()) - } - } - } - } + .modifier(ChatChannelInfoViewHeaderViewModifier(viewModel: viewModel)) .onReceive(keyboardWillChangePublisher) { visible in viewModel.keyboardShown = visible } @@ -184,3 +153,61 @@ public struct ChatChannelInfoView: View, KeyboardReadable viewModel.addUsersShown || viewModel.selectedParticipant != nil } } + +struct ChatChannelInfoViewHeaderViewModifier: ViewModifier { + @Injected(\.colors) private var colors + @Injected(\.fonts) private var fonts + + let viewModel: ChatChannelInfoViewModel + + func body(content: Content) -> some View { + if #available(iOS 26.0, *) { + content + .toolbarThemed { + toolbar(glyphSize: 24) + #if compiler(>=6.2) + .sharedBackgroundVisibility(.hidden) + #endif + } + } else { + content + .toolbarThemed { + toolbar() + } + } + } + + @ToolbarContentBuilder func toolbar(glyphSize: CGFloat? = nil) -> some ToolbarContent { + ToolbarItem(placement: .principal) { + Group { + if viewModel.showSingleMemberDMView { + Text(viewModel.displayedParticipants.first?.chatUser.name ?? "") + .font(fonts.bodyBold) + .foregroundColor(Color(colors.navigationBarTitle)) + } else { + ChannelTitleView( + channel: viewModel.channel, + shouldShowTypingIndicator: false + ) + .id(viewModel.channelId) + } + } + } + + ToolbarItem(placement: .navigationBarTrailing) { + if viewModel.shouldShowAddUserButton { + Button { + viewModel.addUsersShown = true + } label: { + Image(systemName: "person.badge.plus") + .customizable() + .frame(width: glyphSize, height: glyphSize) + .foregroundColor(Color(colors.navigationBarGlyph)) + .padding(.all, 8) + .background(colors.navigationBarTintColor) + .clipShape(Circle()) + } + } + } + } +} diff --git a/Sources/StreamChatSwiftUI/ColorPalette.swift b/Sources/StreamChatSwiftUI/ColorPalette.swift index 2e7e7e32..5006ef98 100644 --- a/Sources/StreamChatSwiftUI/ColorPalette.swift +++ b/Sources/StreamChatSwiftUI/ColorPalette.swift @@ -8,6 +8,7 @@ import UIKit /// Provides the colors used throughout the SDK. public struct ColorPalette { public init() { + navigationBarGlyph = .white navigationBarTitle = text navigationBarSubtitle = textLowEmphasis navigationBarTintColor = tintColor @@ -104,6 +105,8 @@ public struct ColorPalette { // MARK: - Navigation Bar + public var navigationBarGlyph: UIColor + public var navigationBarTitle: UIColor { didSet { let attributes: [NSAttributedString.Key: Any] = [.foregroundColor: navigationBarTitle] diff --git a/StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/__Snapshots__/ChatChannelInfoView_Tests/test_chatChannelInfoView_navigationBarAppearance.1.png b/StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/__Snapshots__/ChatChannelInfoView_Tests/test_chatChannelInfoView_navigationBarAppearance.1.png index d3eeb6fa..ee9473b9 100644 Binary files a/StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/__Snapshots__/ChatChannelInfoView_Tests/test_chatChannelInfoView_navigationBarAppearance.1.png and b/StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/__Snapshots__/ChatChannelInfoView_Tests/test_chatChannelInfoView_navigationBarAppearance.1.png differ diff --git a/StreamChatSwiftUITests/Tests/StreamChatTestCase.swift b/StreamChatSwiftUITests/Tests/StreamChatTestCase.swift index 22897c1d..d807c986 100644 --- a/StreamChatSwiftUITests/Tests/StreamChatTestCase.swift +++ b/StreamChatSwiftUITests/Tests/StreamChatTestCase.swift @@ -41,6 +41,7 @@ open class StreamChatTestCase: XCTestCase { appearance.colors.navigationBarTitle = .blue appearance.colors.navigationBarSubtitle = .cyan appearance.colors.navigationBarBackground = .yellow + appearance.colors.navigationBarGlyph = .green } } }