Skip to content

Commit b1c83bc

Browse files
authored
Respect navigationBarTitle color in file, media and pinned messages view. Turn off applying tint color to navigation stack (#944)
1 parent da0003d commit b1c83bc

File tree

10 files changed

+87
-6
lines changed

10 files changed

+87
-6
lines changed

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/FileAttachmentsView.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,15 @@ public struct FileAttachmentsView: View {
7070
}
7171
}
7272
}
73-
.navigationTitle(L10n.ChatInfo.Files.title)
73+
.toolbar {
74+
ToolbarItem(placement: .principal) {
75+
Text(L10n.ChatInfo.Files.title)
76+
.font(fonts.bodyBold)
77+
.foregroundColor(Color(colors.navigationBarTitle))
78+
}
79+
}
7480
.navigationBarBackground()
81+
.navigationBarTitleDisplayMode(.inline)
7582
}
7683
}
7784

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/MediaAttachmentsView.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import SwiftUI
77

88
/// View displaying media attachments.
99
public struct MediaAttachmentsView<Factory: ViewFactory>: View {
10+
@Injected(\.colors) private var colors
11+
@Injected(\.fonts) private var fonts
1012
@Injected(\.images) private var images
1113

1214
@StateObject private var viewModel: MediaAttachmentsViewModel
@@ -98,8 +100,15 @@ public struct MediaAttachmentsView<Factory: ViewFactory>: View {
98100
}
99101
}
100102
}
101-
.navigationTitle(L10n.ChatInfo.Media.title)
103+
.toolbar {
104+
ToolbarItem(placement: .principal) {
105+
Text(L10n.ChatInfo.Media.title)
106+
.font(fonts.bodyBold)
107+
.foregroundColor(Color(colors.navigationBarTitle))
108+
}
109+
}
102110
.navigationBarBackground()
111+
.navigationBarTitleDisplayMode(.inline)
103112
}
104113
}
105114

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/PinnedMessagesView.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import SwiftUI
77

88
/// View displaying pinned messages in the chat info screen.
99
public struct PinnedMessagesView<Factory: ViewFactory>: View {
10+
@Injected(\.colors) private var colors
11+
@Injected(\.fonts) private var fonts
1012
@Injected(\.images) private var images
1113
@Injected(\.utils) private var utils
1214
@Injected(\.chatClient) private var chatClient
@@ -71,8 +73,15 @@ public struct PinnedMessagesView<Factory: ViewFactory>: View {
7173
)
7274
}
7375
}
74-
.navigationTitle(L10n.ChatInfo.PinnedMessages.title)
76+
.toolbar {
77+
ToolbarItem(placement: .principal) {
78+
Text(L10n.ChatInfo.PinnedMessages.title)
79+
.font(fonts.bodyBold)
80+
.foregroundColor(Color(colors.navigationBarTitle))
81+
}
82+
}
7583
.navigationBarBackground()
84+
.navigationBarTitleDisplayMode(.inline)
7685
}
7786

7887
private func makeMessageDestination(message: ChatMessage) -> ChatChannelView<Factory> {

Sources/StreamChatSwiftUI/Utils/NavigationContainerView.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@ struct NavigationContainerView<Content: View>: View {
1818
.accentColor(colors.tintColor)
1919
.navigationBarBackground()
2020
}
21-
// Tint for back and other system buttons
22-
.accentColor(colors.navigationBarTintColor)
2321
} else {
2422
NavigationView {
2523
content()
2624
.accentColor(colors.tintColor)
2725
.navigationBarBackground()
2826
}
29-
.accentColor(colors.navigationBarTintColor)
3027
}
3128
} else {
3229
content()

StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/FileAttachmentsView_Tests.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,24 @@ class FileAttachmentsView_Tests: StreamChatTestCase {
6767
// Then
6868
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
6969
}
70+
71+
func test_fileAttachmentsView_themedSnapshot() {
72+
// Given
73+
customizedNavigationBarAppearance()
74+
let messages = ChannelInfoMockUtils.generateMessagesWithFileAttachments(count: 20)
75+
let messageSearchController = ChatMessageSearchController_Mock.mock(client: chatClient)
76+
messageSearchController.messages_mock = messages
77+
let viewModel = FileAttachmentsViewModel(
78+
channel: .mockDMChannel(),
79+
messageSearchController: messageSearchController
80+
)
81+
82+
// When
83+
let view = NavigationContainerView(embedInNavigationView: true) {
84+
FileAttachmentsView(viewModel: viewModel)
85+
}.applyDefaultSize()
86+
87+
// Then
88+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
89+
}
7090
}

StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/MediaAttachmentsView_Tests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,27 @@ class MediaAttachmentsView_Tests: StreamChatTestCase {
5757
// Then
5858
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
5959
}
60+
61+
func test_mediaAttachmentsView_themedSnapshot() {
62+
// Given
63+
customizedNavigationBarAppearance()
64+
let messages = ChannelInfoMockUtils.generateMessagesWithAttachments(
65+
withImages: 10,
66+
withVideos: 5
67+
)
68+
let messageSearchController = ChatMessageSearchController_Mock.mock(client: chatClient)
69+
messageSearchController.messages_mock = messages
70+
let viewModel = MediaAttachmentsViewModel(
71+
channel: .mockDMChannel(),
72+
messageSearchController: messageSearchController
73+
)
74+
75+
// When
76+
let view = NavigationContainerView(embedInNavigationView: true) {
77+
MediaAttachmentsView(viewModel: viewModel)
78+
}.applyDefaultSize()
79+
80+
// Then
81+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
82+
}
6083
}

StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/PinnedMessagesView_Tests.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ class PinnedMessagesView_Tests: StreamChatTestCase {
113113
// Then
114114
AssertSnapshot(view, size: defaultScreenSize)
115115
}
116+
117+
func test_pinnedMessagesView_themedSnapshot() {
118+
// Given
119+
customizedNavigationBarAppearance()
120+
let channel = ChatChannel.mockDMChannel(
121+
pinnedMessages: [ChannelInfoMockUtils.pinnedMessage]
122+
)
123+
124+
// When
125+
let view = NavigationContainerView(embedInNavigationView: true) {
126+
PinnedMessagesView(channel: channel)
127+
}.applyDefaultSize()
128+
129+
// Then
130+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
131+
}
116132
}
117133

118134
// Temp solution for failing tests.
132 KB
Loading
1.42 MB
Loading
78.1 KB
Loading

0 commit comments

Comments
 (0)