Skip to content

Commit 73b636f

Browse files
authored
Merge pull request #2267 from nextcloud/feat/noid/glass-emoji
feat: Use glass view for emoji context menu
2 parents 0bb8a8d + 1291d4b commit 73b636f

File tree

2 files changed

+39
-4
lines changed

2 files changed

+39
-4
lines changed

NextcloudTalk/Chat/ChatViewController.swift

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,10 @@ import SwiftUI
21262126

21272127
emojiShortcutButton.titleLabel?.font = .systemFont(ofSize: 20)
21282128
emojiShortcutButton.setTitle(emoji, for: .normal)
2129-
emojiShortcutButton.backgroundColor = .systemBackground
2129+
2130+
if #unavailable(iOS 26.0) {
2131+
emojiShortcutButton.backgroundColor = .systemBackground
2132+
}
21302133

21312134
emojiShortcutButton.addAction { [weak self] in
21322135
guard let self else { return }
@@ -2157,7 +2160,11 @@ import SwiftUI
21572160
addReactionButton.titleLabel?.font = .systemFont(ofSize: 22)
21582161
addReactionButton.setImage(.init(systemName: "plus"), for: .normal)
21592162
addReactionButton.tintColor = .label
2160-
addReactionButton.backgroundColor = .systemBackground
2163+
2164+
if #unavailable(iOS 26.0) {
2165+
addReactionButton.backgroundColor = .systemBackground
2166+
}
2167+
21612168
addReactionButton.addAction { [weak self] in
21622169
guard let self else { return }
21632170
self.tableView?.contextMenuInteraction?.dismissMenu()
@@ -2171,8 +2178,14 @@ import SwiftUI
21712178

21722179
// The reactionView will be shown after the animation finishes, otherwise we see the view already when animating and this looks odd
21732180
reactionView.alpha = 0
2174-
reactionView.layer.cornerRadius = CGFloat(emojiButtonSize) / 2
2175-
reactionView.backgroundColor = .systemBackground
2181+
2182+
if #available(iOS 26.0, *) {
2183+
let effectView = reactionView.addGlassView()
2184+
effectView.layer.cornerRadius = CGFloat(emojiButtonSize) / 2
2185+
} else {
2186+
reactionView.layer.cornerRadius = CGFloat(emojiButtonSize) / 2
2187+
reactionView.backgroundColor = .systemBackground
2188+
}
21762189

21772190
return reactionView
21782191
}

NextcloudTalk/User Interface/Extensions/UIViewExtensions.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,26 @@ extension UIView {
2121
layer.render(in: rendererContext.cgContext)
2222
}
2323
}
24+
25+
@available(iOS 26.0, *)
26+
@discardableResult
27+
func addGlassView(withStyle style: UIGlassEffect.Style = .regular) -> UIVisualEffectView {
28+
self.backgroundColor = .clear
29+
30+
let effectView = UIVisualEffectView()
31+
self.insertSubview(effectView, at: 0)
32+
33+
let glassEffect = UIGlassEffect(style: style)
34+
effectView.effect = glassEffect
35+
effectView.translatesAutoresizingMaskIntoConstraints = false
36+
37+
NSLayoutConstraint.activate([
38+
effectView.leftAnchor.constraint(equalTo: self.leftAnchor),
39+
effectView.rightAnchor.constraint(equalTo: self.rightAnchor),
40+
effectView.topAnchor.constraint(equalTo: self.topAnchor),
41+
effectView.bottomAnchor.constraint(equalTo: self.bottomAnchor)
42+
])
43+
44+
return effectView
45+
}
2446
}

0 commit comments

Comments
 (0)