@sbaiahmed1/react-native-blur 4.6.3 → 4.6.4-beta.1
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.
- package/ios/Helpers/BlurStyleHelpers.swift +0 -1
- package/ios/Helpers/ReactNativeBlurViewHelper.swift +0 -1
- package/ios/Helpers/ReactNativeLiquidGlassViewHelper.swift +0 -1
- package/ios/Helpers/ReactNativeProgressiveBlurViewHelper.swift +0 -1
- package/ios/Views/AdvancedBlurView.swift +24 -89
- package/ios/Views/BlurEffectView.swift +12 -16
- package/ios/Views/ProgressiveBlurView.swift +0 -1
- package/ios/Views/VariableBlurView.swift +0 -1
- package/package.json +1 -1
- package/ios/Views/BasicColoredView.swift +0 -33
|
@@ -1,125 +1,60 @@
|
|
|
1
|
-
import SwiftUI
|
|
2
1
|
import UIKit
|
|
3
2
|
|
|
4
|
-
// MARK: - UIKit Wrapper for Blur
|
|
5
|
-
|
|
6
3
|
@objc public class AdvancedBlurView: UIView {
|
|
7
4
|
|
|
8
|
-
private
|
|
5
|
+
private let blurView = BlurEffectView(effect: nil)
|
|
9
6
|
|
|
10
7
|
@objc public var blurAmount: Double = 10.0 {
|
|
11
|
-
didSet {
|
|
12
|
-
updateView()
|
|
13
|
-
}
|
|
8
|
+
didSet { updateBlur() }
|
|
14
9
|
}
|
|
15
10
|
|
|
16
11
|
@objc public var blurTypeString: String = "xlight" {
|
|
17
|
-
didSet {
|
|
18
|
-
updateView()
|
|
19
|
-
}
|
|
12
|
+
didSet { updateBlur() }
|
|
20
13
|
}
|
|
21
14
|
|
|
22
15
|
@objc public var reducedTransparencyFallbackColor: UIColor = .white {
|
|
23
|
-
didSet {
|
|
24
|
-
updateView()
|
|
25
|
-
}
|
|
16
|
+
didSet { updateBlur() }
|
|
26
17
|
}
|
|
27
18
|
|
|
28
19
|
@objc public var ignoreSafeArea: Bool = false {
|
|
29
|
-
didSet {
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
}
|
|
20
|
+
didSet { updateBlur() }
|
|
21
|
+
}
|
|
33
22
|
|
|
34
23
|
public override init(frame: CGRect) {
|
|
35
24
|
super.init(frame: frame)
|
|
25
|
+
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
26
|
+
blurView.frame = bounds
|
|
27
|
+
addSubview(blurView)
|
|
36
28
|
}
|
|
37
29
|
|
|
38
30
|
required init?(coder: NSCoder) {
|
|
39
31
|
super.init(coder: coder)
|
|
32
|
+
blurView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
33
|
+
blurView.frame = bounds
|
|
34
|
+
addSubview(blurView)
|
|
40
35
|
}
|
|
41
36
|
|
|
42
37
|
public override func layoutSubviews() {
|
|
43
38
|
super.layoutSubviews()
|
|
44
|
-
|
|
45
|
-
// in complex layouts (e.g. FlashList with dynamic content)
|
|
46
|
-
if hostingController == nil && bounds.width > 0 && bounds.height > 0 {
|
|
47
|
-
setupHostingController()
|
|
48
|
-
}
|
|
39
|
+
blurView.frame = bounds
|
|
49
40
|
}
|
|
50
41
|
|
|
51
|
-
private func
|
|
52
|
-
if let oldHosting = hostingController {
|
|
53
|
-
oldHosting.view.removeFromSuperview()
|
|
54
|
-
oldHosting.removeFromParent()
|
|
55
|
-
}
|
|
56
|
-
hostingController = nil
|
|
57
|
-
|
|
58
|
-
let blurStyle = blurStyleFromString(blurTypeString)
|
|
59
|
-
let swiftUIView = BasicColoredView(
|
|
60
|
-
blurAmount: blurAmount,
|
|
61
|
-
blurStyle: blurStyle,
|
|
62
|
-
ignoreSafeArea: ignoreSafeArea,
|
|
63
|
-
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor
|
|
64
|
-
)
|
|
65
|
-
|
|
66
|
-
let hosting = UIHostingController(rootView: swiftUIView)
|
|
67
|
-
hosting.view.backgroundColor = .clear
|
|
68
|
-
hosting.view.translatesAutoresizingMaskIntoConstraints = false
|
|
69
|
-
|
|
42
|
+
private func updateBlur() {
|
|
70
43
|
let interfaceStyle = interfaceStyleForBlurType(blurTypeString) ?? .unspecified
|
|
71
44
|
overrideUserInterfaceStyle = interfaceStyle
|
|
72
|
-
|
|
45
|
+
blurView.overrideUserInterfaceStyle = interfaceStyle
|
|
73
46
|
|
|
74
|
-
if
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
47
|
+
if UIAccessibility.isReduceTransparencyEnabled {
|
|
48
|
+
blurView.isHidden = true
|
|
49
|
+
backgroundColor = reducedTransparencyFallbackColor
|
|
50
|
+
return
|
|
78
51
|
}
|
|
79
|
-
|
|
80
|
-
NSLayoutConstraint.activate([
|
|
81
|
-
hosting.view.topAnchor.constraint(equalTo: topAnchor),
|
|
82
|
-
hosting.view.leadingAnchor.constraint(equalTo: leadingAnchor),
|
|
83
|
-
hosting.view.trailingAnchor.constraint(equalTo: trailingAnchor),
|
|
84
|
-
hosting.view.bottomAnchor.constraint(equalTo: bottomAnchor)
|
|
85
|
-
])
|
|
86
52
|
|
|
87
|
-
|
|
88
|
-
|
|
53
|
+
blurView.isHidden = false
|
|
54
|
+
backgroundColor = .clear
|
|
89
55
|
|
|
90
|
-
|
|
91
|
-
let
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if let hosting = hostingController {
|
|
95
|
-
hosting.overrideUserInterfaceStyle = interfaceStyle
|
|
96
|
-
let blurStyle = blurStyleFromString(blurTypeString)
|
|
97
|
-
let swiftUIView = BasicColoredView(
|
|
98
|
-
blurAmount: blurAmount,
|
|
99
|
-
blurStyle: blurStyle,
|
|
100
|
-
ignoreSafeArea: ignoreSafeArea,
|
|
101
|
-
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor
|
|
102
|
-
)
|
|
103
|
-
hosting.rootView = swiftUIView
|
|
104
|
-
hosting.view.setNeedsLayout()
|
|
105
|
-
} else {
|
|
106
|
-
setupHostingController()
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
public override func didMoveToSuperview() {
|
|
111
|
-
super.didMoveToSuperview()
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public override func didMoveToWindow() {
|
|
115
|
-
super.didMoveToWindow()
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
deinit {
|
|
119
|
-
if let hosting = hostingController {
|
|
120
|
-
hosting.view.removeFromSuperview()
|
|
121
|
-
hosting.removeFromParent()
|
|
122
|
-
}
|
|
123
|
-
hostingController = nil
|
|
56
|
+
let style = blurStyleFromString(blurTypeString)
|
|
57
|
+
let intensity = mapBlurAmountToIntensity(blurAmount)
|
|
58
|
+
blurView.updateBlur(style: style, intensity: intensity)
|
|
124
59
|
}
|
|
125
60
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// BlurEffectView.swift
|
|
2
2
|
|
|
3
|
-
import SwiftUI
|
|
4
3
|
import UIKit
|
|
5
4
|
|
|
6
5
|
// MARK: - Blur View with proper intensity control
|
|
@@ -26,6 +25,14 @@ class BlurEffectView: UIVisualEffectView {
|
|
|
26
25
|
self.blurStyle = style
|
|
27
26
|
self.intensity = intensity
|
|
28
27
|
|
|
28
|
+
// Paused animators hang Detox indefinitely — use on/off blur when Detox is running
|
|
29
|
+
if isDetoxPresent() {
|
|
30
|
+
animator?.stopAnimation(true)
|
|
31
|
+
animator = nil
|
|
32
|
+
effect = intensity > 0 ? UIBlurEffect(style: style) : nil
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
29
36
|
if intensity == 1.0 {
|
|
30
37
|
animator?.stopAnimation(true)
|
|
31
38
|
animator = nil
|
|
@@ -74,19 +81,8 @@ class BlurEffectView: UIVisualEffectView {
|
|
|
74
81
|
}
|
|
75
82
|
}
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
var style: UIBlurEffect.Style = .systemMaterial
|
|
81
|
-
var intensity: Double = 1.0
|
|
82
|
-
|
|
83
|
-
func makeUIView(context: Context) -> BlurEffectView {
|
|
84
|
-
let effectView = BlurEffectView(effect: nil)
|
|
85
|
-
effectView.updateBlur(style: style, intensity: intensity)
|
|
86
|
-
return effectView
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
func updateUIView(_ uiView: BlurEffectView, context: Context) {
|
|
90
|
-
uiView.updateBlur(style: style, intensity: intensity)
|
|
91
|
-
}
|
|
84
|
+
private func isDetoxPresent() -> Bool {
|
|
85
|
+
let args = ProcessInfo.processInfo.arguments
|
|
86
|
+
return args.contains("-detoxServer") && args.contains("-detoxSessionId")
|
|
92
87
|
}
|
|
88
|
+
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
// BasicColoredView.swift
|
|
2
|
-
|
|
3
|
-
import SwiftUI
|
|
4
|
-
import UIKit
|
|
5
|
-
|
|
6
|
-
struct BasicColoredView: View {
|
|
7
|
-
let blurAmount: Double
|
|
8
|
-
let blurStyle: UIBlurEffect.Style
|
|
9
|
-
let blurIntensity: Double
|
|
10
|
-
let ignoreSafeArea: Bool
|
|
11
|
-
|
|
12
|
-
init(blurAmount: Double,
|
|
13
|
-
blurStyle: UIBlurEffect.Style,
|
|
14
|
-
ignoreSafeArea: Bool,
|
|
15
|
-
reducedTransparencyFallbackColor: UIColor) {
|
|
16
|
-
self.blurAmount = blurAmount
|
|
17
|
-
self.blurStyle = blurStyle
|
|
18
|
-
self.ignoreSafeArea = ignoreSafeArea
|
|
19
|
-
self.blurIntensity = mapBlurAmountToIntensity(blurAmount)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var body: some View {
|
|
23
|
-
regularBlurView
|
|
24
|
-
.ignoresSafeArea(ignoreSafeArea ? .all : [])
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
private var regularBlurView: some View {
|
|
28
|
-
Rectangle()
|
|
29
|
-
.fill(Color(.clear))
|
|
30
|
-
.background(Blur(style: blurStyle, intensity: blurIntensity))
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|