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

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,9 +1,5 @@
1
- // BlurEffectView.swift
2
-
3
- import SwiftUI
4
1
  import UIKit
5
-
6
- // MARK: - Blur View with proper intensity control
2
+ import SwiftUI
7
3
 
8
4
  class BlurEffectView: UIVisualEffectView {
9
5
  private var animator: UIViewPropertyAnimator?
@@ -33,19 +29,33 @@ class BlurEffectView: UIVisualEffectView {
33
29
 
34
30
  func updateBlur(style: UIBlurEffect.Style, intensity: Double) {
35
31
  blurStyle = style
36
- self.intensity = max(0.0, min(1.0, intensity))
32
+ self.intensity = min(max(intensity, 0.0), 1.0)
37
33
  setNeedsDisplay()
38
34
  }
39
35
 
40
36
  override func draw(_ rect: CGRect) {
41
37
  super.draw(rect)
38
+
39
+ // Avoid animator-based blur during Detox so tests don't hang waiting for app idleness.
40
+ if isDetoxPresent() {
41
+ effect = intensity > 0 ? visualEffect : nil
42
+ return
43
+ }
44
+
45
+ if intensity <= 0 {
46
+ effect = nil
47
+ animator?.stopAnimation(true)
48
+ return
49
+ }
50
+
51
+ let normalizedIntensity = max(0.01, min(1.0, intensity))
52
+
42
53
  effect = nil
43
54
  animator?.stopAnimation(true)
44
- animator = UIViewPropertyAnimator(duration: 1, curve: .linear)
45
- animator?.addAnimations { [unowned self] in
55
+ animator = UIViewPropertyAnimator(duration: 1, curve: .linear) { [unowned self] in
46
56
  self.effect = visualEffect
47
57
  }
48
- animator?.fractionComplete = CGFloat(intensity)
58
+ animator?.fractionComplete = CGFloat(normalizedIntensity)
49
59
  }
50
60
 
51
61
  deinit {
@@ -53,7 +63,10 @@ class BlurEffectView: UIVisualEffectView {
53
63
  }
54
64
  }
55
65
 
56
- // MARK: - SwiftUI Blur Wrapper
66
+ private func isDetoxPresent() -> Bool {
67
+ let args = ProcessInfo.processInfo.arguments
68
+ return args.contains("-detoxServer") && args.contains("-detoxSessionId")
69
+ }
57
70
 
58
71
  struct Blur: UIViewRepresentable {
59
72
  var style: UIBlurEffect.Style = .systemMaterial
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.6",
4
4
  "description": "React native modern blur view",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",