@sbaiahmed1/react-native-blur 4.6.1-beta.4 → 4.6.1-beta.5

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,35 +1,23 @@
1
- // ReactNativeBlurViewHelper.swift
2
-
3
- import SwiftUI
4
1
  import UIKit
5
2
 
6
- // MARK: - Objective-C Bridging Helpers
7
-
8
3
  @objc public class ReactNativeBlurViewHelper: NSObject {
9
-
10
- /// Creates and returns a blur view.
11
4
  @objc public static func createBlurViewWithFrame(_ frame: CGRect) -> AdvancedBlurView {
12
5
  return AdvancedBlurView(frame: frame)
13
6
  }
14
7
 
15
- /// Updates the blur view with a new blur amount.
16
8
  @objc public static func updateBlurView(_ blurView: AdvancedBlurView, withBlurAmount blurAmount: Double) {
17
9
  blurView.blurAmount = blurAmount
18
10
  }
19
11
 
20
- /// Updates the blur view with a new blur type.
21
12
  @objc public static func updateBlurView(_ blurView: AdvancedBlurView, withBlurType blurType: String) {
22
13
  blurView.blurTypeString = blurType
23
14
  }
24
15
 
25
- /// Updates the blur view with a new reduced transparency fallback color.
26
16
  @objc public static func updateBlurView(_ blurView: AdvancedBlurView, withReducedTransparencyFallbackColor reducedTransparencyFallbackColor: UIColor) {
27
17
  blurView.reducedTransparencyFallbackColor = reducedTransparencyFallbackColor
28
18
  }
29
19
 
30
- /// Updates the blur view with a new ignoreSafeArea value.
31
20
  @objc public static func updateBlurView(_ blurView: AdvancedBlurView, withIgnoringSafeArea ignoreSafeArea: Bool) {
32
21
  blurView.ignoreSafeArea = ignoreSafeArea
33
22
  }
34
23
  }
35
-
@@ -1,10 +1,5 @@
1
- // BlurEffectView.swift
2
-
3
- import SwiftUI
4
1
  import UIKit
5
2
 
6
- // MARK: - Blur View with proper intensity control
7
-
8
3
  class BlurEffectView: UIVisualEffectView {
9
4
  private var animator: UIViewPropertyAnimator?
10
5
  private var blurStyle: UIBlurEffect.Style = .systemMaterial {
@@ -33,19 +28,33 @@ class BlurEffectView: UIVisualEffectView {
33
28
 
34
29
  func updateBlur(style: UIBlurEffect.Style, intensity: Double) {
35
30
  blurStyle = style
36
- self.intensity = max(0.0, min(1.0, intensity))
31
+ self.intensity = min(max(intensity, 0.0), 1.0)
37
32
  setNeedsDisplay()
38
33
  }
39
34
 
40
35
  override func draw(_ rect: CGRect) {
41
36
  super.draw(rect)
37
+
38
+ // Avoid animator-based blur during Detox so tests don't hang waiting for app idleness.
39
+ if isDetoxPresent() {
40
+ effect = intensity > 0 ? visualEffect : nil
41
+ return
42
+ }
43
+
44
+ if intensity <= 0 {
45
+ effect = nil
46
+ animator?.stopAnimation(true)
47
+ return
48
+ }
49
+
50
+ let normalizedIntensity = max(0.01, min(1.0, intensity))
51
+
42
52
  effect = nil
43
53
  animator?.stopAnimation(true)
44
- animator = UIViewPropertyAnimator(duration: 1, curve: .linear)
45
- animator?.addAnimations { [unowned self] in
54
+ animator = UIViewPropertyAnimator(duration: 1, curve: .linear) { [unowned self] in
46
55
  self.effect = visualEffect
47
56
  }
48
- animator?.fractionComplete = CGFloat(intensity)
57
+ animator?.fractionComplete = CGFloat(normalizedIntensity)
49
58
  }
50
59
 
51
60
  deinit {
@@ -53,19 +62,7 @@ class BlurEffectView: UIVisualEffectView {
53
62
  }
54
63
  }
55
64
 
56
- // MARK: - SwiftUI Blur Wrapper
57
-
58
- struct Blur: UIViewRepresentable {
59
- var style: UIBlurEffect.Style = .systemMaterial
60
- var intensity: Double = 1.0
61
-
62
- func makeUIView(context: Context) -> BlurEffectView {
63
- let effectView = BlurEffectView(effect: nil)
64
- effectView.updateBlur(style: style, intensity: intensity)
65
- return effectView
66
- }
67
-
68
- func updateUIView(_ uiView: BlurEffectView, context: Context) {
69
- uiView.updateBlur(style: style, intensity: intensity)
70
- }
65
+ private func isDetoxPresent() -> Bool {
66
+ let args = ProcessInfo.processInfo.arguments
67
+ return args.contains("-detoxServer") && args.contains("-detoxSessionId")
71
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sbaiahmed1/react-native-blur",
3
- "version": "4.6.1-beta.4",
3
+ "version": "4.6.1-beta.5",
4
4
  "description": "React native modern blur view",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",