Skip to content

Commit dd82ad7

Browse files
Exposed adding background of a selected reaction
1 parent 0153290 commit dd82ad7

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayContainer.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ struct ReactionsAnimatableView: View {
118118
.foregroundColor(color(for: reaction))
119119
.frame(width: useLargeIcons ? 25 : 20, height: useLargeIcons ? 27 : 20)
120120
}
121+
.background(reactionSelectedBackgroundColor(for: reaction).cornerRadius(8))
121122
.scaleEffect(index(for: reaction) != nil ? animationStates[index(for: reaction)!] : 1)
122123
.onAppear {
123124
guard let index = index(for: reaction) else {
@@ -142,6 +143,16 @@ struct ReactionsAnimatableView: View {
142143
.reactionsBubble(for: message, background: colors.background8)
143144
}
144145

146+
private func reactionSelectedBackgroundColor(for reaction: MessageReactionType) -> Color? {
147+
var colors = colors
148+
guard let color = colors.selectedReactionBackgroundColor else {
149+
return nil
150+
}
151+
152+
let backgroundColor: Color? = userReactionIDs.contains(reaction) ? Color(color) : nil
153+
return backgroundColor
154+
}
155+
145156
private func index(for reaction: MessageReactionType) -> Int? {
146157
let index = reactions.firstIndex(where: { type in
147158
type == reaction

Sources/StreamChatSwiftUI/ColorPalette.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public struct ColorPalette {
7676
public lazy var quotedMessageBackgroundOtherUser: UIColor = background8
7777
public lazy var reactionCurrentUserColor: UIColor? = UIColor(tintColor)
7878
public lazy var reactionOtherUserColor: UIColor? = textLowEmphasis
79+
public lazy var selectedReactionBackgroundColor: UIColor? = nil
7980
}
8081

8182
// Those colors are default defined stream constants, which are fallback values if you don't implement your color theme.

0 commit comments

Comments
 (0)