Skip to content

Commit c7547c2

Browse files
authored
Add ColorPalette.navigationBarGlyph and fix add member toolbar item on iOS 26 (#999)
1 parent 95ebc7f commit c7547c2

File tree

6 files changed

+68
-33
lines changed

6 files changed

+68
-33
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1010
- Add support for overriding `onImageTap` in `LinkAttachmentView` [#986](https://github.com/GetStream/stream-chat-swiftui/pull/986)
1111
- Add support for customizing text colors in `LinkAttachmentView` [#992](https://github.com/GetStream/stream-chat-swiftui/pull/992)
1212
- Expose `MediaAttachment` properties and initializer [#1000](https://github.com/GetStream/stream-chat-swiftui/pull/1000)
13+
- Add `ColorPalette.navigationBarGlyph` for configuring the glyph color for buttons in navigation bars [#999](https://github.com/GetStream/stream-chat-swiftui/pull/999)
14+
- Allow overriding `ChatChannelInfoViewModel` properties: `shouldShowLeaveConversationButton`, `canRenameChannel`, and `shouldShowAddUserButton` [#995](https://github.com/GetStream/stream-chat-swiftui/pull/995)
1315

1416
### 🐞 Fixed
1517
- 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/).
2022
- Fix random scroll after marking a message unread [#989](https://github.com/GetStream/stream-chat-swiftui/pull/989)
2123
- 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)
2224
- Fix replying to unread messages marking them instantly as read [#989](https://github.com/GetStream/stream-chat-swiftui/pull/989)
25+
- Fix rendering of the add users button on iOS 26 [#999](https://github.com/GetStream/stream-chat-swiftui/pull/999)
26+
- Use `ColorPalette.navigationBarTint` for the background of the add users button [#999](https://github.com/GetStream/stream-chat-swiftui/pull/999)
2327

2428
# [4.89.1](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.89.1)
2529
_September 23, 2025_

DemoAppSwiftUI/ChannelHeader/CustomChannelHeader.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public struct CustomChannelHeader: ToolbarContent {
3131
.resizable()
3232
.scaledToFit()
3333
.frame(width: 24, height: 24)
34-
.foregroundColor(Color.white)
34+
.foregroundColor(Color(colors.navigationBarGlyph))
3535
.padding(.all, 8)
3636
.background(colors.navigationBarTintColor)
3737
.clipShape(Circle())

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift

Lines changed: 59 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -141,38 +141,7 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
141141
}
142142
}
143143
}
144-
.toolbarThemed {
145-
ToolbarItem(placement: .principal) {
146-
Group {
147-
if viewModel.showSingleMemberDMView {
148-
Text(viewModel.displayedParticipants.first?.chatUser.name ?? "")
149-
.font(fonts.bodyBold)
150-
.foregroundColor(Color(colors.navigationBarTitle))
151-
} else {
152-
ChannelTitleView(
153-
channel: viewModel.channel,
154-
shouldShowTypingIndicator: false
155-
)
156-
.id(viewModel.channelId)
157-
}
158-
}
159-
}
160-
161-
ToolbarItem(placement: .navigationBarTrailing) {
162-
if viewModel.shouldShowAddUserButton {
163-
Button {
164-
viewModel.addUsersShown = true
165-
} label: {
166-
Image(systemName: "person.badge.plus")
167-
.customizable()
168-
.foregroundColor(Color.white)
169-
.padding(.all, 8)
170-
.background(colors.tintColor)
171-
.clipShape(Circle())
172-
}
173-
}
174-
}
175-
}
144+
.modifier(ChatChannelInfoViewHeaderViewModifier(viewModel: viewModel))
176145
.onReceive(keyboardWillChangePublisher) { visible in
177146
viewModel.keyboardShown = visible
178147
}
@@ -184,3 +153,61 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
184153
viewModel.addUsersShown || viewModel.selectedParticipant != nil
185154
}
186155
}
156+
157+
struct ChatChannelInfoViewHeaderViewModifier: ViewModifier {
158+
@Injected(\.colors) private var colors
159+
@Injected(\.fonts) private var fonts
160+
161+
let viewModel: ChatChannelInfoViewModel
162+
163+
func body(content: Content) -> some View {
164+
if #available(iOS 26.0, *) {
165+
content
166+
.toolbarThemed {
167+
toolbar(glyphSize: 24)
168+
#if compiler(>=6.2)
169+
.sharedBackgroundVisibility(.hidden)
170+
#endif
171+
}
172+
} else {
173+
content
174+
.toolbarThemed {
175+
toolbar()
176+
}
177+
}
178+
}
179+
180+
@ToolbarContentBuilder func toolbar(glyphSize: CGFloat? = nil) -> some ToolbarContent {
181+
ToolbarItem(placement: .principal) {
182+
Group {
183+
if viewModel.showSingleMemberDMView {
184+
Text(viewModel.displayedParticipants.first?.chatUser.name ?? "")
185+
.font(fonts.bodyBold)
186+
.foregroundColor(Color(colors.navigationBarTitle))
187+
} else {
188+
ChannelTitleView(
189+
channel: viewModel.channel,
190+
shouldShowTypingIndicator: false
191+
)
192+
.id(viewModel.channelId)
193+
}
194+
}
195+
}
196+
197+
ToolbarItem(placement: .navigationBarTrailing) {
198+
if viewModel.shouldShowAddUserButton {
199+
Button {
200+
viewModel.addUsersShown = true
201+
} label: {
202+
Image(systemName: "person.badge.plus")
203+
.customizable()
204+
.frame(width: glyphSize, height: glyphSize)
205+
.foregroundColor(Color(colors.navigationBarGlyph))
206+
.padding(.all, 8)
207+
.background(colors.navigationBarTintColor)
208+
.clipShape(Circle())
209+
}
210+
}
211+
}
212+
}
213+
}

Sources/StreamChatSwiftUI/ColorPalette.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import UIKit
88
/// Provides the colors used throughout the SDK.
99
public struct ColorPalette {
1010
public init() {
11+
navigationBarGlyph = .white
1112
navigationBarTitle = text
1213
navigationBarSubtitle = textLowEmphasis
1314
navigationBarTintColor = tintColor
@@ -104,6 +105,8 @@ public struct ColorPalette {
104105

105106
// MARK: - Navigation Bar
106107

108+
public var navigationBarGlyph: UIColor
109+
107110
public var navigationBarTitle: UIColor {
108111
didSet {
109112
let attributes: [NSAttributedString.Key: Any] = [.foregroundColor: navigationBarTitle]
Loading

StreamChatSwiftUITests/Tests/StreamChatTestCase.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ open class StreamChatTestCase: XCTestCase {
4141
appearance.colors.navigationBarTitle = .blue
4242
appearance.colors.navigationBarSubtitle = .cyan
4343
appearance.colors.navigationBarBackground = .yellow
44+
appearance.colors.navigationBarGlyph = .green
4445
}
4546
}
4647
}

0 commit comments

Comments
 (0)