Skip to content

Commit 39f3e87

Browse files
Bugfix FXIOS-13359 [iOS 26] Glass effect is not applied to toast notifications (#29153)
* FXIOS-13359 #29056 [iOS 26] Glass effect is not applied to toast notifications * Add mask to prevent shadow * Fix compilation * Remove unnecessary check * Remove unnecessary check
1 parent 95c3d68 commit 39f3e87

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed

BrowserKit/Sources/ComponentLibrary/BottomSheet/BottomSheetViewController.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,9 @@ public class BottomSheetViewController: UIViewController,
196196
let effectView = UIVisualEffectView()
197197

198198
#if canImport(FoundationModels)
199-
if #available(iOS 26, *) {
200-
let glassEffect = UIGlassEffect()
201-
glassEffect.isInteractive = true
202-
effectView.effect = glassEffect
203-
} else {
204-
effectView.effect = UIBlurEffect(style: .systemUltraThinMaterial)
205-
}
199+
let glassEffect = UIGlassEffect()
200+
glassEffect.isInteractive = true
201+
effectView.effect = glassEffect
206202
#else
207203
effectView.effect = UIBlurEffect(style: .systemUltraThinMaterial)
208204
#endif

firefox-ios/Client/Frontend/Browser/Toast.swift

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Toast: UIView, ThemeApplicable, Notifiable {
3232
weak var viewController: UIViewController?
3333

3434
var dismissed = false
35+
private var glassEffectView: UIVisualEffectView?
3536

3637
lazy var gestureRecognizer: UITapGestureRecognizer = {
3738
let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(handleTap))
@@ -62,10 +63,12 @@ class Toast: UIView, ThemeApplicable, Notifiable {
6263

6364
override func layoutSubviews() {
6465
super.layoutSubviews()
65-
layer.shadowPath = UIBezierPath(
66-
roundedRect: self.toastView.bounds,
67-
cornerRadius: UX.toastCornerRadius
68-
).cgPath
66+
if #unavailable(iOS 26.0) {
67+
layer.shadowPath = UIBezierPath(
68+
roundedRect: self.toastView.bounds,
69+
cornerRadius: UX.toastCornerRadius
70+
).cgPath
71+
}
6972
}
7073

7174
func showToast(viewController: UIViewController? = nil,
@@ -125,8 +128,44 @@ class Toast: UIView, ThemeApplicable, Notifiable {
125128
}
126129

127130
func applyTheme(theme: Theme) {
128-
toastView.backgroundColor = theme.colors.actionPrimary
129-
setupShadow(theme: theme)
131+
if #available(iOS 26.0, *) {
132+
setupGlassEffect(theme: theme)
133+
} else {
134+
toastView.backgroundColor = theme.colors.actionPrimary
135+
setupShadow(theme: theme)
136+
}
137+
}
138+
139+
@available(iOS 26.0, *)
140+
private func setupGlassEffect(theme: Theme) {
141+
// Only add glass effect if it doesn't already exist
142+
guard glassEffectView == nil else { return }
143+
144+
let effectView = UIVisualEffectView()
145+
146+
#if canImport(FoundationModels)
147+
let glassEffect = UIGlassEffect()
148+
glassEffect.tintColor = theme.colors.actionPrimary
149+
effectView.effect = glassEffect
150+
#else
151+
effectView.effect = UIBlurEffect(style: .systemUltraThinMaterial)
152+
#endif
153+
154+
effectView.layer.cornerRadius = UX.toastCornerRadius
155+
effectView.clipsToBounds = true
156+
effectView.translatesAutoresizingMaskIntoConstraints = false
157+
158+
toastView.layer.masksToBounds = true
159+
toastView.insertSubview(effectView, at: 0)
160+
161+
NSLayoutConstraint.activate([
162+
effectView.topAnchor.constraint(equalTo: toastView.topAnchor),
163+
effectView.leadingAnchor.constraint(equalTo: toastView.leadingAnchor),
164+
effectView.trailingAnchor.constraint(equalTo: toastView.trailingAnchor),
165+
effectView.bottomAnchor.constraint(equalTo: toastView.bottomAnchor)
166+
])
167+
168+
glassEffectView = effectView
130169
}
131170

132171
private func setupShadow(theme: Theme) {

0 commit comments

Comments
 (0)