@sbaiahmed1/react-native-blur 4.6.3 → 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.
@@ -1,6 +1,5 @@
1
1
  // BlurStyleHelpers.swift
2
2
 
3
- import SwiftUI
4
3
  import UIKit
5
4
 
6
5
  // MARK: - Style Mapping Helper Functions
@@ -1,6 +1,5 @@
1
1
  // ReactNativeBlurViewHelper.swift
2
2
 
3
- import SwiftUI
4
3
  import UIKit
5
4
 
6
5
  // MARK: - Objective-C Bridging Helpers
@@ -1,6 +1,5 @@
1
1
  // ReactNativeLiquidGlassViewHelper.swift
2
2
 
3
- import SwiftUI
4
3
  import UIKit
5
4
 
6
5
  // MARK: - Objective-C Bridging Helpers for Liquid Glass
@@ -1,6 +1,5 @@
1
1
  // ReactNativeProgressiveBlurViewHelper.swift
2
2
 
3
- import SwiftUI
4
3
  import UIKit
5
4
 
6
5
  // MARK: - Objective-C Bridging Helpers for Progressive Blur
@@ -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 var hostingController: UIHostingController<BasicColoredView>?
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
- updateView()
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
- // Defer controller setup until we have a valid frame to avoid issues with initial render
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 setupHostingController() {
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
- hosting.overrideUserInterfaceStyle = interfaceStyle
45
+ blurView.overrideUserInterfaceStyle = interfaceStyle
73
46
 
74
- if !subviews.isEmpty {
75
- insertSubview(hosting.view, at: 0)
76
- } else {
77
- addSubview(hosting.view)
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
- self.hostingController = hosting
88
- }
53
+ blurView.isHidden = false
54
+ backgroundColor = .clear
89
55
 
90
- private func updateView() {
91
- let interfaceStyle = interfaceStyleForBlurType(blurTypeString) ?? .unspecified
92
- overrideUserInterfaceStyle = interfaceStyle
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,92 +1,44 @@
1
1
  // BlurEffectView.swift
2
2
 
3
- import SwiftUI
4
3
  import UIKit
5
4
 
6
5
  // MARK: - Blur View with proper intensity control
7
6
 
8
7
  class BlurEffectView: UIVisualEffectView {
9
8
  private var animator: UIViewPropertyAnimator?
10
- private var blurStyle: UIBlurEffect.Style = .systemMaterial
11
- private var intensity: Double = 1.0
12
- private var currentEffectStyle: UIBlurEffect.Style?
13
9
 
14
10
  override init(effect: UIVisualEffect?) {
15
11
  super.init(effect: effect)
16
- setupBlur()
17
12
  }
18
13
 
19
14
  required init?(coder: NSCoder) {
20
15
  super.init(coder: coder)
21
- setupBlur()
22
16
  }
23
17
 
24
18
  func updateBlur(style: UIBlurEffect.Style, intensity: Double) {
25
- guard style != self.blurStyle || intensity != self.intensity else { return }
26
- self.blurStyle = style
27
- self.intensity = intensity
28
-
29
- if intensity == 1.0 {
30
- animator?.stopAnimation(true)
31
- animator = nil
32
- currentEffectStyle = style
33
- effect = UIBlurEffect(style: style)
34
- } else if intensity == 0.0 {
19
+ // Paused animators hang Detox indefinitely use on/off blur when Detox is running
20
+ if isDetoxPresent() {
35
21
  animator?.stopAnimation(true)
36
22
  animator = nil
37
- currentEffectStyle = nil
38
- effect = nil
39
- } else {
40
- if let existing = animator,
41
- (existing.state == .active || existing.state == .inactive),
42
- currentEffectStyle == style {
43
- existing.fractionComplete = intensity
44
- } else {
45
- setupBlur()
46
- }
23
+ effect = intensity > 0 ? UIBlurEffect(style: style) : nil
24
+ return
47
25
  }
48
- }
49
-
50
- private func setupBlur() {
51
- if let existing = animator, existing.state == .active {
52
- existing.stopAnimation(true)
53
- }
54
- animator = nil
55
26
 
56
27
  effect = nil
57
- currentEffectStyle = blurStyle
58
-
59
- let newAnimator = UIViewPropertyAnimator(duration: 1, curve: .linear)
60
- newAnimator.addAnimations { [weak self] in
61
- 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)
62
31
  }
63
- newAnimator.pausesOnCompletion = true
64
- newAnimator.startAnimation()
65
- newAnimator.pauseAnimation()
66
- newAnimator.fractionComplete = intensity
67
- animator = newAnimator
32
+ animator?.fractionComplete = CGFloat(intensity)
68
33
  }
69
34
 
70
35
  deinit {
71
- if let animator = animator, animator.state == .active {
72
- animator.stopAnimation(true)
73
- }
36
+ animator?.stopAnimation(true)
74
37
  }
75
38
  }
76
39
 
77
- // MARK: - SwiftUI Blur Wrapper
78
-
79
- struct Blur: UIViewRepresentable {
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
- }
40
+ private func isDetoxPresent() -> Bool {
41
+ let args = ProcessInfo.processInfo.arguments
42
+ return args.contains("-detoxServer") && args.contains("-detoxSessionId")
92
43
  }
44
+
@@ -1,7 +1,6 @@
1
1
  // ProgressiveBlurView.swift
2
2
  // React Native wrapper for VariableBlurView
3
3
 
4
- import SwiftUI
5
4
  import UIKit
6
5
 
7
6
  @objc public class ProgressiveBlurView: UIView {
@@ -1,7 +1,6 @@
1
1
  // VariableBlurView.swift
2
2
  // Progressive/Variable Blur implementation based on VariableBlur library
3
3
 
4
- import SwiftUI
5
4
  import UIKit
6
5
  import CoreImage.CIFilterBuiltins
7
6
  import QuartzCore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sbaiahmed1/react-native-blur",
3
- "version": "4.6.3",
3
+ "version": "4.6.4-beta.02",
4
4
  "description": "React native modern blur view",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -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
-