Skip to content

Commit 0153290

Browse files
Exposed reaction color for animated rection
1 parent 12ab83b commit 0153290

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsOverlayContainer.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ struct ReactionsAnimatableView: View {
113113
onReactionTap(reaction)
114114
} label: {
115115
Image(uiImage: image)
116-
.customizable()
116+
.resizable()
117+
.scaledToFit()
117118
.foregroundColor(color(for: reaction))
118119
.frame(width: useLargeIcons ? 25 : 20, height: useLargeIcons ? 27 : 20)
119120
}
@@ -157,9 +158,16 @@ struct ReactionsAnimatableView: View {
157158
}
158159
}
159160

160-
private func color(for reaction: MessageReactionType) -> Color {
161-
userReactionIDs
162-
.contains(reaction) ? Color(colors.highlightedAccentBackground) : Color(colors.textLowEmphasis)
161+
private func color(for reaction: MessageReactionType) -> Color? {
162+
var colors = colors
163+
let containsUserReaction = userReactionIDs.contains(reaction)
164+
let color = containsUserReaction ? colors.reactionCurrentUserColor : colors.reactionOtherUserColor
165+
166+
if let color = color {
167+
return Color(color)
168+
} else {
169+
return nil
170+
}
163171
}
164172

165173
private var userReactionIDs: Set<MessageReactionType> {

Sources/StreamChatSwiftUI/ChatChannel/Reactions/ReactionsView.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ struct ReactionsView: View {
7474
ForEach(reactions) { reaction in
7575
if let image = iconProvider(for: reaction) {
7676
Image(uiImage: image)
77-
.customizable()
77+
.resizable()
78+
.scaledToFit()
7879
.foregroundColor(color(for: reaction))
7980
.frame(width: useLargeIcons ? 25 : 20, height: useLargeIcons ? 27 : 20)
8081
.gesture(
@@ -98,9 +99,16 @@ struct ReactionsView: View {
9899
}
99100
}
100101

101-
private func color(for reaction: MessageReactionType) -> Color {
102-
userReactionIDs
103-
.contains(reaction) ? Color(colors.highlightedAccentBackground) : Color(colors.textLowEmphasis)
102+
private func color(for reaction: MessageReactionType) -> Color? {
103+
var colors = colors
104+
let containsUserReaction = userReactionIDs.contains(reaction)
105+
let color = containsUserReaction ? colors.reactionCurrentUserColor : colors.reactionOtherUserColor
106+
107+
if let color = color {
108+
return Color(color)
109+
} else {
110+
return nil
111+
}
104112
}
105113

106114
private var userReactionIDs: Set<MessageReactionType> {

0 commit comments

Comments
 (0)