From 727bc52793624bb9986c900d742d53576e96ba74 Mon Sep 17 00:00:00 2001 From: AlisaMylnikova Date: Wed, 20 Nov 2024 12:49:29 +0700 Subject: [PATCH 1/3] Apply colors from the palette to poll views --- .../ChatChannel/MessageList/Polls/PollAllOptionsView.swift | 1 + .../ChatChannel/MessageList/Polls/PollAttachmentView.swift | 7 ++++++- .../ChatChannel/MessageList/Polls/PollResultsView.swift | 1 + .../ChatChannel/Polls/CreatePollView.swift | 6 +++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAllOptionsView.swift b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAllOptionsView.swift index e8a2de2fb..e52fa6a89 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAllOptionsView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAllOptionsView.swift @@ -31,6 +31,7 @@ struct PollAllOptionsView: View { viewModel: viewModel, option: option, optionFont: fonts.headline, + textColor: Color(colors.text), alternativeStyle: true, checkboxButtonSpacing: 8 ) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAttachmentView.swift b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAttachmentView.swift index ad17f8401..f56d82d91 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAttachmentView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAttachmentView.swift @@ -40,6 +40,7 @@ public struct PollAttachmentView: View { HStack { Text(poll.name) .font(fonts.bodyBold) + .foregroundColor(textColor(for: message)) Spacer() } @@ -56,7 +57,8 @@ public struct PollAttachmentView: View { viewModel: viewModel, option: option, optionVotes: poll.voteCount(for: option), - maxVotes: poll.currentMaximumVoteCount + maxVotes: poll.currentMaximumVoteCount, + textColor: textColor(for: message) ) .layoutPriority(1) // do not compress long text } @@ -188,6 +190,7 @@ struct PollOptionView: View { var optionFont: Font = InjectedValues[\.fonts].body var optionVotes: Int? var maxVotes: Int? + var textColor: Color /// If true, only option name and vote count is shown, otherwise votes indicator and avatars appear as well. var alternativeStyle: Bool = false /// The spacing between the checkbox and the option name. @@ -211,6 +214,7 @@ struct PollOptionView: View { HStack(alignment: .top) { Text(option.text) .font(optionFont) + .foregroundColor(textColor) Spacer() if !alternativeStyle, viewModel.showVoterAvatars { HStack(spacing: -4) { @@ -225,6 +229,7 @@ struct PollOptionView: View { } } Text("\(viewModel.poll.voteCountsByOption?[option.id] ?? 0)") + .foregroundColor(textColor) } if !alternativeStyle { PollVotesIndicatorView( diff --git a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift index 46b1b3e29..de710fbea 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift @@ -55,6 +55,7 @@ struct PollResultsView: View { Spacer() } } + .background(Color(colors.background).ignoresSafeArea()) .toolbar { ToolbarItem(placement: .principal) { Text(L10n.Message.Polls.Toolbar.resultsTitle) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift b/Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift index d9cf63671..8a90e1eb7 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift @@ -162,6 +162,7 @@ struct CreatePollView: View { Spacer() .modifier(ListRowModifier()) } + .background(Color(colors.background).ignoresSafeArea()) .listStyle(.plain) .id(listId) .toolbar { @@ -229,11 +230,14 @@ struct CreatePollItemModifier: ViewModifier { } struct ListRowModifier: ViewModifier { - + + @Injected(\.colors) var colors + func body(content: Content) -> some View { if #available(iOS 15.0, *) { content .listRowSeparator(.hidden) + .listRowBackground(Color(colors.background)) } else { content } From b1d93e033e3f51550075f02b2dfc3ad042c1c182 Mon Sep 17 00:00:00 2001 From: Nuno Vieira Date: Thu, 21 Nov 2024 13:01:07 +0000 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fed3c685f..0778ac213 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Make `VoiceRecordingButton` public [#658](https://github.com/GetStream/stream-chat-swiftui/pull/658) ### 🐞 Fixed - Fix message long press taking too much time to show actions [#648](https://github.com/GetStream/stream-chat-swiftui/pull/648) +- Fix not using colors from the palette in poll views [#661](https://github.com/GetStream/stream-chat-swiftui/pull/661) ### 🔄 Changed - Message composer now uses `.uploadFile` capability when showing attachment picker icon [#646](https://github.com/GetStream/stream-chat-swiftui/pull/646) - `ChannelInfoView` now uses `.updateChannelMembers` capability to show "Add Users" button [#651](https://github.com/GetStream/stream-chat-swiftui/pull/651) From e502ff971e1d4707dde3e0e6cba0fdc897f2ae98 Mon Sep 17 00:00:00 2001 From: Nuno Vieira Date: Thu, 21 Nov 2024 15:15:05 +0000 Subject: [PATCH 3/3] Use background8 for Poll background views --- .../ChatChannel/MessageList/Polls/PollResultsView.swift | 2 +- .../StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift index de710fbea..0ca9e5803 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift @@ -55,7 +55,7 @@ struct PollResultsView: View { Spacer() } } - .background(Color(colors.background).ignoresSafeArea()) + .background(Color(colors.background8).ignoresSafeArea()) .toolbar { ToolbarItem(placement: .principal) { Text(L10n.Message.Polls.Toolbar.resultsTitle) diff --git a/Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift b/Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift index 8a90e1eb7..180219be1 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift @@ -162,7 +162,7 @@ struct CreatePollView: View { Spacer() .modifier(ListRowModifier()) } - .background(Color(colors.background).ignoresSafeArea()) + .background(Color(colors.background8).ignoresSafeArea()) .listStyle(.plain) .id(listId) .toolbar { @@ -237,7 +237,7 @@ struct ListRowModifier: ViewModifier { if #available(iOS 15.0, *) { content .listRowSeparator(.hidden) - .listRowBackground(Color(colors.background)) + .listRowBackground(Color(colors.background8)) } else { content }