@sbaiahmed1/react-native-blur 4.6.1-beta.3 → 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.
- package/ios/Helpers/ReactNativeBlurViewHelper.swift +0 -12
- package/ios/Views/BlurEffectView.swift +21 -24
- package/lib/module/BlurView.js +6 -0
- package/lib/module/BlurView.js.map +1 -1
- package/lib/typescript/src/BlurView.d.ts +1 -1
- package/lib/typescript/src/BlurView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/BlurView.tsx +5 -1
|
@@ -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,
|
|
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(
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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/lib/module/BlurView.js
CHANGED
|
@@ -45,6 +45,8 @@ export const BlurView = ({
|
|
|
45
45
|
ignoreSafeArea,
|
|
46
46
|
reducedTransparencyFallbackColor
|
|
47
47
|
};
|
|
48
|
+
|
|
49
|
+
// If no children, render the blur view directly (for background use)
|
|
48
50
|
if (!Children.count(children)) {
|
|
49
51
|
return /*#__PURE__*/_jsx(ReactNativeBlurView, {
|
|
50
52
|
style: [style, overlay],
|
|
@@ -52,6 +54,8 @@ export const BlurView = ({
|
|
|
52
54
|
...props
|
|
53
55
|
});
|
|
54
56
|
}
|
|
57
|
+
|
|
58
|
+
// If children exist, use the style default for Android
|
|
55
59
|
if (Platform.OS === 'android') {
|
|
56
60
|
return /*#__PURE__*/_jsxs(ReactNativeBlurView, {
|
|
57
61
|
style: style,
|
|
@@ -62,6 +66,8 @@ export const BlurView = ({
|
|
|
62
66
|
}), children]
|
|
63
67
|
});
|
|
64
68
|
}
|
|
69
|
+
|
|
70
|
+
// If children exist, use the absolute positioning pattern for iOS and others
|
|
65
71
|
return /*#__PURE__*/_jsxs(View, {
|
|
66
72
|
style: [styles.container, style, overlay],
|
|
67
73
|
children: [/*#__PURE__*/_jsx(ReactNativeBlurView, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","Children","Platform","StyleSheet","View","ReactNativeBlurView","jsx","_jsx","jsxs","_jsxs","BlurView","blurType","blurAmount","reducedTransparencyFallbackColor","overlayColor","style","children","ignoreSafeArea","props","overlay","backgroundColor","commonProps","count","OS","absoluteFill","styles","container","create","position","overflow"],"sourceRoot":"../../src","sources":["BlurView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"names":["React","Children","Platform","StyleSheet","View","ReactNativeBlurView","jsx","_jsx","jsxs","_jsxs","BlurView","blurType","blurAmount","reducedTransparencyFallbackColor","overlayColor","style","children","ignoreSafeArea","props","overlay","backgroundColor","commonProps","count","OS","absoluteFill","styles","container","create","position","overflow"],"sourceRoot":"../../src","sources":["BlurView.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,QAAQ,EAAEC,UAAU,EAAEC,IAAI,QAAQ,cAAc;AAEzD,OAAOC,mBAAmB,MAEnB,sCAAsC;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAuD9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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AU,CAACwB,MAAM,CAAC;EAC/BD,SAAS,EAAE;IACTE,QAAQ,EAAE,UAAU;IACpBC,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ViewStyle, StyleProp, ColorValue } from 'react-native';
|
|
3
3
|
import { type BlurType } from './ReactNativeBlurViewNativeComponent';
|
|
4
4
|
export interface BlurViewProps {
|
|
5
5
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlurView.d.ts","sourceRoot":"","sources":["../../../src/BlurView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BlurView.d.ts","sourceRoot":"","sources":["../../../src/BlurView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACrE,OAA4B,EAC1B,KAAK,QAAQ,EACd,MAAM,sCAAsC,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAE1C;;;;OAIG;IACH,YAAY,CAAC,EAAE,UAAU,CAAC;IAE1B;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAE7B;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IAEzB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAoD5C,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/package.json
CHANGED
package/src/BlurView.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { Children } from 'react';
|
|
2
|
-
import type { ColorValue, StyleProp, ViewStyle } from 'react-native';
|
|
3
2
|
import { Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
import type { ViewStyle, StyleProp, ColorValue } from 'react-native';
|
|
4
4
|
import ReactNativeBlurView, {
|
|
5
5
|
type BlurType,
|
|
6
6
|
} from './ReactNativeBlurViewNativeComponent';
|
|
@@ -98,6 +98,7 @@ export const BlurView: React.FC<BlurViewProps> = ({
|
|
|
98
98
|
reducedTransparencyFallbackColor,
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
+
// If no children, render the blur view directly (for background use)
|
|
101
102
|
if (!Children.count(children)) {
|
|
102
103
|
return (
|
|
103
104
|
<ReactNativeBlurView
|
|
@@ -108,6 +109,7 @@ export const BlurView: React.FC<BlurViewProps> = ({
|
|
|
108
109
|
);
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
// If children exist, use the style default for Android
|
|
111
113
|
if (Platform.OS === 'android') {
|
|
112
114
|
return (
|
|
113
115
|
<ReactNativeBlurView style={style} {...commonProps} {...props}>
|
|
@@ -118,8 +120,10 @@ export const BlurView: React.FC<BlurViewProps> = ({
|
|
|
118
120
|
);
|
|
119
121
|
}
|
|
120
122
|
|
|
123
|
+
// If children exist, use the absolute positioning pattern for iOS and others
|
|
121
124
|
return (
|
|
122
125
|
<View style={[styles.container, style, overlay]}>
|
|
126
|
+
{/* Blur effect positioned absolutely behind content */}
|
|
123
127
|
<ReactNativeBlurView
|
|
124
128
|
style={StyleSheet.absoluteFill}
|
|
125
129
|
{...commonProps}
|