@sbaiahmed1/react-native-blur 4.6.4-beta.1 → 4.6.4-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,25 +6,16 @@ import UIKit
|
|
|
6
6
|
|
|
7
7
|
class BlurEffectView: UIVisualEffectView {
|
|
8
8
|
private var animator: UIViewPropertyAnimator?
|
|
9
|
-
private var blurStyle: UIBlurEffect.Style = .systemMaterial
|
|
10
|
-
private var intensity: Double = 1.0
|
|
11
|
-
private var currentEffectStyle: UIBlurEffect.Style?
|
|
12
9
|
|
|
13
10
|
override init(effect: UIVisualEffect?) {
|
|
14
11
|
super.init(effect: effect)
|
|
15
|
-
setupBlur()
|
|
16
12
|
}
|
|
17
13
|
|
|
18
14
|
required init?(coder: NSCoder) {
|
|
19
15
|
super.init(coder: coder)
|
|
20
|
-
setupBlur()
|
|
21
16
|
}
|
|
22
17
|
|
|
23
18
|
func updateBlur(style: UIBlurEffect.Style, intensity: Double) {
|
|
24
|
-
guard style != self.blurStyle || intensity != self.intensity else { return }
|
|
25
|
-
self.blurStyle = style
|
|
26
|
-
self.intensity = intensity
|
|
27
|
-
|
|
28
19
|
// Paused animators hang Detox indefinitely — use on/off blur when Detox is running
|
|
29
20
|
if isDetoxPresent() {
|
|
30
21
|
animator?.stopAnimation(true)
|
|
@@ -33,51 +24,16 @@ class BlurEffectView: UIVisualEffectView {
|
|
|
33
24
|
return
|
|
34
25
|
}
|
|
35
26
|
|
|
36
|
-
if intensity == 1.0 {
|
|
37
|
-
animator?.stopAnimation(true)
|
|
38
|
-
animator = nil
|
|
39
|
-
currentEffectStyle = style
|
|
40
|
-
effect = UIBlurEffect(style: style)
|
|
41
|
-
} else if intensity == 0.0 {
|
|
42
|
-
animator?.stopAnimation(true)
|
|
43
|
-
animator = nil
|
|
44
|
-
currentEffectStyle = nil
|
|
45
|
-
effect = nil
|
|
46
|
-
} else {
|
|
47
|
-
if let existing = animator,
|
|
48
|
-
(existing.state == .active || existing.state == .inactive),
|
|
49
|
-
currentEffectStyle == style {
|
|
50
|
-
existing.fractionComplete = intensity
|
|
51
|
-
} else {
|
|
52
|
-
setupBlur()
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
private func setupBlur() {
|
|
58
|
-
if let existing = animator, existing.state == .active {
|
|
59
|
-
existing.stopAnimation(true)
|
|
60
|
-
}
|
|
61
|
-
animator = nil
|
|
62
|
-
|
|
63
27
|
effect = nil
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
newAnimator.addAnimations { [weak self] in
|
|
68
|
-
self?.effect = UIBlurEffect(style: self?.blurStyle ?? .systemMaterial)
|
|
28
|
+
animator?.stopAnimation(true)
|
|
29
|
+
animator = UIViewPropertyAnimator(duration: 1, curve: .linear) { [weak self] in
|
|
30
|
+
self?.effect = UIBlurEffect(style: style)
|
|
69
31
|
}
|
|
70
|
-
|
|
71
|
-
newAnimator.startAnimation()
|
|
72
|
-
newAnimator.pauseAnimation()
|
|
73
|
-
newAnimator.fractionComplete = intensity
|
|
74
|
-
animator = newAnimator
|
|
32
|
+
animator?.fractionComplete = CGFloat(intensity)
|
|
75
33
|
}
|
|
76
34
|
|
|
77
35
|
deinit {
|
|
78
|
-
|
|
79
|
-
animator.stopAnimation(true)
|
|
80
|
-
}
|
|
36
|
+
animator?.stopAnimation(true)
|
|
81
37
|
}
|
|
82
38
|
}
|
|
83
39
|
|