Skip to content

Commit 7b0bd5c

Browse files
nuno-vieiraf3dm76
andauthored
Apply colors from the palette to poll views (#661)
* Apply colors from the palette to poll views * Update CHANGELOG.md * Use background8 for Poll background views --------- Co-authored-by: AlisaMylnikova <[email protected]>
1 parent b75eb97 commit 7b0bd5c

File tree

5 files changed

+14
-2
lines changed

5 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
88
### 🐞 Fixed
99
- Fix message long press taking too much time to show actions [#648](https://github.com/GetStream/stream-chat-swiftui/pull/648)
1010
- Fix rendering link attachment preview with other attachment types [#659](https://github.com/GetStream/stream-chat-swiftui/pull/659)
11+
- Fix not using colors from the palette in some of the poll views [#661](https://github.com/GetStream/stream-chat-swiftui/pull/661)
1112
### 🔄 Changed
1213
- Message composer now uses `.uploadFile` capability when showing attachment picker icon [#646](https://github.com/GetStream/stream-chat-swiftui/pull/646)
1314
- `ChannelInfoView` now uses `.updateChannelMembers` capability to show "Add Users" button [#651](https://github.com/GetStream/stream-chat-swiftui/pull/651)

Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAllOptionsView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ struct PollAllOptionsView: View {
3131
viewModel: viewModel,
3232
option: option,
3333
optionFont: fonts.headline,
34+
textColor: Color(colors.text),
3435
alternativeStyle: true,
3536
checkboxButtonSpacing: 8
3637
)

Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollAttachmentView.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public struct PollAttachmentView<Factory: ViewFactory>: View {
4040
HStack {
4141
Text(poll.name)
4242
.font(fonts.bodyBold)
43+
.foregroundColor(textColor(for: message))
4344
Spacer()
4445
}
4546

@@ -56,7 +57,8 @@ public struct PollAttachmentView<Factory: ViewFactory>: View {
5657
viewModel: viewModel,
5758
option: option,
5859
optionVotes: poll.voteCount(for: option),
59-
maxVotes: poll.currentMaximumVoteCount
60+
maxVotes: poll.currentMaximumVoteCount,
61+
textColor: textColor(for: message)
6062
)
6163
.layoutPriority(1) // do not compress long text
6264
}
@@ -188,6 +190,7 @@ struct PollOptionView: View {
188190
var optionFont: Font = InjectedValues[\.fonts].body
189191
var optionVotes: Int?
190192
var maxVotes: Int?
193+
var textColor: Color
191194
/// If true, only option name and vote count is shown, otherwise votes indicator and avatars appear as well.
192195
var alternativeStyle: Bool = false
193196
/// The spacing between the checkbox and the option name.
@@ -211,6 +214,7 @@ struct PollOptionView: View {
211214
HStack(alignment: .top) {
212215
Text(option.text)
213216
.font(optionFont)
217+
.foregroundColor(textColor)
214218
Spacer()
215219
if !alternativeStyle, viewModel.showVoterAvatars {
216220
HStack(spacing: -4) {
@@ -225,6 +229,7 @@ struct PollOptionView: View {
225229
}
226230
}
227231
Text("\(viewModel.poll.voteCountsByOption?[option.id] ?? 0)")
232+
.foregroundColor(textColor)
228233
}
229234
if !alternativeStyle {
230235
PollVotesIndicatorView(

Sources/StreamChatSwiftUI/ChatChannel/MessageList/Polls/PollResultsView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct PollResultsView: View {
5555
Spacer()
5656
}
5757
}
58+
.background(Color(colors.background8).ignoresSafeArea())
5859
.toolbar {
5960
ToolbarItem(placement: .principal) {
6061
Text(L10n.Message.Polls.Toolbar.resultsTitle)

Sources/StreamChatSwiftUI/ChatChannel/Polls/CreatePollView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ struct CreatePollView: View {
162162
Spacer()
163163
.modifier(ListRowModifier())
164164
}
165+
.background(Color(colors.background8).ignoresSafeArea())
165166
.listStyle(.plain)
166167
.id(listId)
167168
.toolbar {
@@ -229,11 +230,14 @@ struct CreatePollItemModifier: ViewModifier {
229230
}
230231

231232
struct ListRowModifier: ViewModifier {
232-
233+
234+
@Injected(\.colors) var colors
235+
233236
func body(content: Content) -> some View {
234237
if #available(iOS 15.0, *) {
235238
content
236239
.listRowSeparator(.hidden)
240+
.listRowBackground(Color(colors.background8))
237241
} else {
238242
content
239243
}

0 commit comments

Comments
 (0)