Skip to content

Commit dd85b6f

Browse files
authored
Merge pull request #779 from Adamant-im/trello.com/c/ArzACuYT
[trello.com/c/46S4GSZ5] onHover for reactions in menu macOS
2 parents a64a2b8 + 104efb7 commit dd85b6f

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

Adamant/Modules/Chat/View/Helpers/ChatReactionsView.swift

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ struct ChatReactionsView: View {
2323

2424
var didSelectEmoji: ((_ emoji: String, _ messageId: String) -> Void)?
2525
var didSelectMore: (() -> Void)?
26+
27+
@State private var isPlusHovered = false
2628

2729
init(
2830
emojis: [String]?,
@@ -40,16 +42,9 @@ struct ChatReactionsView: View {
4042
HStack(spacing: 5) {
4143
ForEach(emojis.prefix(6), id: \.self) { emoji in
4244
ChatReactionButton(
43-
emoji: emoji
45+
emoji: emoji,
46+
isSelected: selectedEmoji == emoji
4447
)
45-
.padding(.leading, 1)
46-
.frame(width: 40, height: 40)
47-
.background(
48-
selectedEmoji == emoji
49-
? Color.init(uiColor: .gray.withAlphaComponent(0.75))
50-
: .clear
51-
)
52-
.clipShape(Circle())
5348
.onTapGesture {
5449
didSelectEmoji?(emoji, messageId)
5550
}
@@ -66,9 +61,19 @@ struct ChatReactionsView: View {
6661
.padding(6)
6762
}
6863
.frame(width: 30, height: 30)
69-
.background(Color.init(uiColor: .adamant.moreReactionsBackground))
64+
.background(
65+
isPlusHovered
66+
? Color.init(uiColor: .adamant.contextMenuSelectColor)
67+
: Color.init(uiColor: .adamant.moreReactionsBackground)
68+
)
7069
.clipShape(Circle())
70+
.scaleEffect(isPlusHovered ? 1.15 : 1.0)
71+
.onHover { hovering in
72+
isPlusHovered = hovering
73+
}
74+
.animation(.easeInOut(duration: 0.2), value: isPlusHovered)
7175
.padding([.top, .bottom], 5)
76+
7277
Spacer()
7378
}
7479
.padding(.leading, 5)
@@ -79,10 +84,20 @@ struct ChatReactionsView: View {
7984

8085
struct ChatReactionButton: View {
8186
let emoji: String
87+
let isSelected: Bool
88+
89+
@State private var isHovered = false
8290

8391
var body: some View {
8492
Text(emoji)
8593
.font(.title)
94+
.frame(width: 40, height: 40)
95+
.background( isHovered ? Color.init(uiColor: .adamant.contextMenuSelectColor) :
96+
(isSelected ? Color.init(uiColor: .gray.withAlphaComponent(0.75)) : Color.clear))
8697
.clipShape(Circle())
98+
.onHover { hovering in
99+
isHovered = hovering
100+
}
101+
.animation(.easeInOut(duration: 0.1), value: isHovered)
87102
}
88103
}

0 commit comments

Comments
 (0)