Skip to content

Commit 76d8a73

Browse files
authored
Fix tinting navigation bar and other content differently (#953)
1 parent a168ba8 commit 76d8a73

File tree

52 files changed

+119
-145
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+119
-145
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
44
# Upcoming
55

66
### ✅ Added
7+
- Add `toolbarThemed(content:)` for creating custom views with themed navigation bar [#953](https://github.com/GetStream/stream-chat-swiftui/pull/953)
8+
### 🐞 Fixed
9+
- Fix updating back button tint with `ColorPalette.navigationBarTintColor` [#953](https://github.com/GetStream/stream-chat-swiftui/pull/953)
710
- Add support for downloading file attachments [#952](https://github.com/GetStream/stream-chat-swiftui/pull/952)
811

912
# [4.88.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.88.0)

DemoAppSwiftUI/ChannelHeader/CustomChannelHeader.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public struct CustomChannelHeader: ToolbarContent {
3333
.frame(width: 24, height: 24)
3434
.foregroundColor(Color.white)
3535
.padding(.all, 8)
36-
.background(colors.tintColor)
36+
.background(colors.navigationBarTintColor)
3737
.clipShape(Circle())
3838
}
3939
.accessibilityLabel(Text("New Channel"))
@@ -67,7 +67,7 @@ struct CustomChannelModifier: ChannelListHeaderViewModifier {
6767
func body(content: Content) -> some View {
6868
ZStack {
6969
if #available(iOS 26, *) {
70-
content.toolbar {
70+
content.toolbarThemed {
7171
CustomChannelHeader(
7272
title: title,
7373
currentUserController: chatClient.currentUserController(),
@@ -79,7 +79,7 @@ struct CustomChannelModifier: ChannelListHeaderViewModifier {
7979
#endif
8080
}
8181
} else {
82-
content.toolbar {
82+
content.toolbarThemed {
8383
CustomChannelHeader(
8484
title: title,
8585
currentUserController: chatClient.currentUserController(),

DemoAppSwiftUI/ChannelHeader/NewChatView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ struct NewChatView: View, KeyboardReadable {
9696
Spacer()
9797
}
9898
}
99-
.navigationTitle("New Chat")
99+
.toolbarThemed {
100+
ToolbarItem(placement: .principal) {
101+
Text("New Chat")
102+
.font(fonts.bodyBold)
103+
.foregroundColor(Color(colors.navigationBarTitle))
104+
}
105+
}
100106
.onReceive(keyboardWillChangePublisher) { visible in
101107
keyboardShown = visible
102108
}

DemoAppSwiftUI/CreateGroupView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct CreateGroupView: View, KeyboardReadable {
4949
}
5050
.listStyle(.plain)
5151
}
52-
.toolbar(content: {
52+
.toolbarThemed(content: {
5353
ToolbarItem(placement: .navigationBarTrailing) {
5454
NavigationLink {
5555
GroupNameView(

Sources/StreamChatSwiftUI/ChatChannel/ChannelHeader/ChatChannelHeaderViewModifier.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public struct DefaultChatChannelHeader<Factory: ViewFactory>: ToolbarContent {
7777
)
7878
.offset(x: 4)
7979
}
80-
.accentColor(colors.navigationBarTintColor)
8180
.accessibilityLabel(Text(L10n.Channel.Header.Info.title))
8281

8382
NavigationLink(isActive: $isActive) {
@@ -111,8 +110,7 @@ public struct DefaultChannelHeaderModifier<Factory: ViewFactory>: ChatChannelHea
111110
public func body(content: Content) -> some View {
112111
if #available(iOS 26, *) {
113112
content
114-
.navigationBarBackground()
115-
.toolbar {
113+
.toolbarThemed {
116114
DefaultChatChannelHeader(
117115
factory: factory,
118116
channel: channel,
@@ -125,8 +123,7 @@ public struct DefaultChannelHeaderModifier<Factory: ViewFactory>: ChatChannelHea
125123
}
126124
} else {
127125
content
128-
.navigationBarBackground()
129-
.toolbar {
126+
.toolbarThemed {
130127
DefaultChatChannelHeader(
131128
factory: factory,
132129
channel: channel,

Sources/StreamChatSwiftUI/ChatChannel/ChannelHeader/MessageThreadHeaderViewModifier.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public struct DefaultMessageThreadHeader: ToolbarContent {
3131
public struct DefaultMessageThreadHeaderModifier: MessageThreadHeaderViewModifier {
3232
public func body(content: Content) -> some View {
3333
content
34-
.navigationBarBackground()
35-
.toolbar {
34+
.toolbarThemed {
3635
DefaultMessageThreadHeader()
3736
}
3837
}

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
132132
}
133133
}
134134
}
135-
.navigationBarBackground()
136-
.toolbar {
135+
.toolbarThemed {
137136
ToolbarItem(placement: .principal) {
138137
Group {
139138
if viewModel.showSingleMemberDMView {
@@ -162,7 +161,6 @@ public struct ChatChannelInfoView<Factory: ViewFactory>: View, KeyboardReadable
162161
.background(colors.tintColor)
163162
.clipShape(Circle())
164163
}
165-
.accentColor(colors.navigationBarTintColor)
166164
}
167165
}
168166
}

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/FileAttachmentsView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,13 @@ public struct FileAttachmentsView: View {
7878
}
7979
}
8080
}
81-
.toolbar {
81+
.toolbarThemed {
8282
ToolbarItem(placement: .principal) {
8383
Text(L10n.ChatInfo.Files.title)
8484
.font(fonts.bodyBold)
8585
.foregroundColor(Color(colors.navigationBarTitle))
8686
}
8787
}
88-
.navigationBarBackground()
8988
.navigationBarTitleDisplayMode(.inline)
9089
}
9190
}

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/MediaAttachmentsView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,13 @@ public struct MediaAttachmentsView<Factory: ViewFactory>: View {
100100
}
101101
}
102102
}
103-
.toolbar {
103+
.toolbarThemed {
104104
ToolbarItem(placement: .principal) {
105105
Text(L10n.ChatInfo.Media.title)
106106
.font(fonts.bodyBold)
107107
.foregroundColor(Color(colors.navigationBarTitle))
108108
}
109109
}
110-
.navigationBarBackground()
111110
.navigationBarTitleDisplayMode(.inline)
112111
}
113112
}

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/PinnedMessagesView.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,13 @@ public struct PinnedMessagesView<Factory: ViewFactory>: View {
7373
)
7474
}
7575
}
76-
.toolbar {
76+
.toolbarThemed {
7777
ToolbarItem(placement: .principal) {
7878
Text(L10n.ChatInfo.PinnedMessages.title)
7979
.font(fonts.bodyBold)
8080
.foregroundColor(Color(colors.navigationBarTitle))
8181
}
8282
}
83-
.navigationBarBackground()
8483
.navigationBarTitleDisplayMode(.inline)
8584
}
8685

0 commit comments

Comments
 (0)