Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/View/FluidBackgroundView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ internal class FluidBlurredBackgroundView: UIView, FluidBackgroundCompatible {
private func applyVisibility() {
let clampedVisibility = self.visibility.clamped(0, 1)
self.blurRadius = self.baseBlurRadius * clampedVisibility
if clampedVisibility > 0, self.blurView.image == nil {
if self.blurView.image == nil {
self.updateSnapshot()
}
self.blurView.alpha = clampedVisibility
Expand Down
21 changes: 21 additions & 0 deletions Tests/UIKitSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1460,6 +1460,27 @@ final class UIKitSpec: QuickSpec {
expect(waitForBlurredImage(in: backgroundView)).notTo(beNil())
}

it("prepares blurred snapshots before becoming visible") {
let container = UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 120))
let window = UIWindow(frame: container.bounds)
let sourceView = UIView(frame: container.bounds)
let backgroundView = FluidBlurredBackgroundView(radius: 20, color: .clear, alpha: 0)
let blurView = backgroundView.subviews.compactMap { $0 as? UIImageView }.first

sourceView.backgroundColor = .red
window.addSubview(container)
window.isHidden = false
defer { window.isHidden = true }
container.addSubview(sourceView)
container.addSubview(backgroundView)

container.updateConstraintsAndLayoutImmediately()

expect(backgroundView.visibility).to(beCloseTo(0))
expect(blurView?.alpha).to(beCloseTo(0))
expect(waitForBlurredImage(in: backgroundView, timeout: 0.5)).notTo(beNil())
}

it("captures background behind transition containers") {
let bounds = CGRect(x: 0, y: 0, width: 200, height: 120)
let window = UIWindow(frame: bounds)
Expand Down