@sbaiahmed1/react-native-blur 3.1.0 → 3.1.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.
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerDelegate.java +3 -18
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerInterface.java +1 -6
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.cpp +0 -1
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.h +0 -1
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.cpp +0 -1
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.h +0 -7
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.cpp +2 -21
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.h +2 -70
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.cpp +0 -1
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.h +0 -11
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/States.h +0 -12
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt +49 -6
- package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurViewManager.kt +10 -0
- package/ios/Views/AdvancedBlurView.swift +49 -8
- package/ios/Views/BlurEffectView.swift +4 -2
- package/package.json +1 -1
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassEffectContainerManagerDelegate.java +0 -53
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassEffectContainerManagerInterface.java +0 -25
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassViewManagerDelegate.java +0 -38
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassViewManagerInterface.java +0 -20
|
@@ -22,29 +22,14 @@ public class ReactNativeBlurViewManagerDelegate<T extends View, U extends BaseVi
|
|
|
22
22
|
@Override
|
|
23
23
|
public void setProperty(T view, String propName, @Nullable Object value) {
|
|
24
24
|
switch (propName) {
|
|
25
|
-
case "glassTintColor":
|
|
26
|
-
mViewManager.setGlassTintColor(view, value == null ? "clear" : (String) value);
|
|
27
|
-
break;
|
|
28
|
-
case "glassOpacity":
|
|
29
|
-
mViewManager.setGlassOpacity(view, value == null ? 1f : ((Double) value).doubleValue());
|
|
30
|
-
break;
|
|
31
|
-
case "blurAmount":
|
|
32
|
-
mViewManager.setBlurAmount(view, value == null ? 10f : ((Double) value).doubleValue());
|
|
33
|
-
break;
|
|
34
|
-
case "type":
|
|
35
|
-
mViewManager.setType(view, (String) value);
|
|
36
|
-
break;
|
|
37
25
|
case "blurType":
|
|
38
26
|
mViewManager.setBlurType(view, (String) value);
|
|
39
27
|
break;
|
|
40
|
-
case "
|
|
41
|
-
mViewManager.
|
|
28
|
+
case "blurAmount":
|
|
29
|
+
mViewManager.setBlurAmount(view, value == null ? 10f : ((Double) value).doubleValue());
|
|
42
30
|
break;
|
|
43
31
|
case "reducedTransparencyFallbackColor":
|
|
44
|
-
mViewManager.setReducedTransparencyFallbackColor(view, value == null ?
|
|
45
|
-
break;
|
|
46
|
-
case "isInteractive":
|
|
47
|
-
mViewManager.setIsInteractive(view, value == null ? true : (boolean) value);
|
|
32
|
+
mViewManager.setReducedTransparencyFallbackColor(view, value == null ? null : (String) value);
|
|
48
33
|
break;
|
|
49
34
|
default:
|
|
50
35
|
super.setProperty(view, propName, value);
|
|
@@ -14,12 +14,7 @@ import androidx.annotation.Nullable;
|
|
|
14
14
|
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
|
|
15
15
|
|
|
16
16
|
public interface ReactNativeBlurViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
|
|
17
|
-
void setGlassTintColor(T view, @Nullable String value);
|
|
18
|
-
void setGlassOpacity(T view, double value);
|
|
19
|
-
void setBlurAmount(T view, double value);
|
|
20
|
-
void setType(T view, @Nullable String value);
|
|
21
17
|
void setBlurType(T view, @Nullable String value);
|
|
22
|
-
void
|
|
18
|
+
void setBlurAmount(T view, double value);
|
|
23
19
|
void setReducedTransparencyFallbackColor(T view, @Nullable String value);
|
|
24
|
-
void setIsInteractive(T view, boolean value);
|
|
25
20
|
}
|
|
@@ -17,7 +17,6 @@ namespace facebook::react {
|
|
|
17
17
|
void ReactNativeBlurViewSpec_registerComponentDescriptorsFromCodegen(
|
|
18
18
|
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
|
|
19
19
|
registry->add(concreteComponentDescriptorProvider<ReactNativeBlurViewComponentDescriptor>());
|
|
20
|
-
registry->add(concreteComponentDescriptorProvider<ReactNativeGlassEffectContainerComponentDescriptor>());
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
} // namespace facebook::react
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
namespace facebook::react {
|
|
18
18
|
|
|
19
19
|
using ReactNativeBlurViewComponentDescriptor = ConcreteComponentDescriptor<ReactNativeBlurViewShadowNode>;
|
|
20
|
-
using ReactNativeGlassEffectContainerComponentDescriptor = ConcreteComponentDescriptor<ReactNativeGlassEffectContainerShadowNode>;
|
|
21
20
|
|
|
22
21
|
void ReactNativeBlurViewSpec_registerComponentDescriptorsFromCodegen(
|
|
23
22
|
std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
|
|
@@ -19,12 +19,5 @@ class ReactNativeBlurViewEventEmitter : public ViewEventEmitter {
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
};
|
|
23
|
-
class ReactNativeGlassEffectContainerEventEmitter : public ViewEventEmitter {
|
|
24
|
-
public:
|
|
25
|
-
using ViewEventEmitter::ViewEventEmitter;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
22
|
};
|
|
30
23
|
} // namespace facebook::react
|
|
@@ -19,28 +19,9 @@ ReactNativeBlurViewProps::ReactNativeBlurViewProps(
|
|
|
19
19
|
const ReactNativeBlurViewProps &sourceProps,
|
|
20
20
|
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
glassOpacity(convertRawProp(context, rawProps, "glassOpacity", sourceProps.glassOpacity, {1.0})),
|
|
22
|
+
blurType(convertRawProp(context, rawProps, "blurType", sourceProps.blurType, {ReactNativeBlurViewBlurType::Light})),
|
|
24
23
|
blurAmount(convertRawProp(context, rawProps, "blurAmount", sourceProps.blurAmount, {10.0})),
|
|
25
|
-
|
|
26
|
-
blurType(convertRawProp(context, rawProps, "blurType", sourceProps.blurType, {ReactNativeBlurViewBlurType::Xlight})),
|
|
27
|
-
glassType(convertRawProp(context, rawProps, "glassType", sourceProps.glassType, {ReactNativeBlurViewGlassType::Clear})),
|
|
28
|
-
reducedTransparencyFallbackColor(convertRawProp(context, rawProps, "reducedTransparencyFallbackColor", sourceProps.reducedTransparencyFallbackColor, {"#FFFFFF"})),
|
|
29
|
-
isInteractive(convertRawProp(context, rawProps, "isInteractive", sourceProps.isInteractive, {true}))
|
|
30
|
-
{}
|
|
31
|
-
ReactNativeGlassEffectContainerProps::ReactNativeGlassEffectContainerProps(
|
|
32
|
-
const PropsParserContext &context,
|
|
33
|
-
const ReactNativeGlassEffectContainerProps &sourceProps,
|
|
34
|
-
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
|
|
35
|
-
|
|
36
|
-
glassType(convertRawProp(context, rawProps, "glassType", sourceProps.glassType, {ReactNativeGlassEffectContainerGlassType::Clear})),
|
|
37
|
-
glassTintColor(convertRawProp(context, rawProps, "glassTintColor", sourceProps.glassTintColor, {"clear"})),
|
|
38
|
-
glassOpacity(convertRawProp(context, rawProps, "glassOpacity", sourceProps.glassOpacity, {1.0})),
|
|
39
|
-
isInteractive(convertRawProp(context, rawProps, "isInteractive", sourceProps.isInteractive, {true})),
|
|
40
|
-
spacing(convertRawProp(context, rawProps, "spacing", sourceProps.spacing, {8.0})),
|
|
41
|
-
enableMorphing(convertRawProp(context, rawProps, "enableMorphing", sourceProps.enableMorphing, {true})),
|
|
42
|
-
morphingDuration(convertRawProp(context, rawProps, "morphingDuration", sourceProps.morphingDuration, {300})),
|
|
43
|
-
reducedTransparencyFallbackColor(convertRawProp(context, rawProps, "reducedTransparencyFallbackColor", sourceProps.reducedTransparencyFallbackColor, {"#FFFFFF"}))
|
|
24
|
+
reducedTransparencyFallbackColor(convertRawProp(context, rawProps, "reducedTransparencyFallbackColor", sourceProps.reducedTransparencyFallbackColor, {}))
|
|
44
25
|
{}
|
|
45
26
|
|
|
46
27
|
} // namespace facebook::react
|
|
@@ -14,21 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
namespace facebook::react {
|
|
16
16
|
|
|
17
|
-
enum class ReactNativeBlurViewType { Blur, LiquidGlass };
|
|
18
|
-
|
|
19
|
-
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNativeBlurViewType &result) {
|
|
20
|
-
auto string = (std::string)value;
|
|
21
|
-
if (string == "blur") { result = ReactNativeBlurViewType::Blur; return; }
|
|
22
|
-
if (string == "liquidGlass") { result = ReactNativeBlurViewType::LiquidGlass; return; }
|
|
23
|
-
abort();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
static inline std::string toString(const ReactNativeBlurViewType &value) {
|
|
27
|
-
switch (value) {
|
|
28
|
-
case ReactNativeBlurViewType::Blur: return "blur";
|
|
29
|
-
case ReactNativeBlurViewType::LiquidGlass: return "liquidGlass";
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
17
|
enum class ReactNativeBlurViewBlurType { Xlight, Light, Dark, ExtraDark, Regular, Prominent, SystemUltraThinMaterial, SystemThinMaterial, SystemMaterial, SystemThickMaterial, SystemChromeMaterial };
|
|
33
18
|
|
|
34
19
|
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNativeBlurViewBlurType &result) {
|
|
@@ -62,21 +47,6 @@ static inline std::string toString(const ReactNativeBlurViewBlurType &value) {
|
|
|
62
47
|
case ReactNativeBlurViewBlurType::SystemChromeMaterial: return "systemChromeMaterial";
|
|
63
48
|
}
|
|
64
49
|
}
|
|
65
|
-
enum class ReactNativeBlurViewGlassType { Clear, Regular };
|
|
66
|
-
|
|
67
|
-
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNativeBlurViewGlassType &result) {
|
|
68
|
-
auto string = (std::string)value;
|
|
69
|
-
if (string == "clear") { result = ReactNativeBlurViewGlassType::Clear; return; }
|
|
70
|
-
if (string == "regular") { result = ReactNativeBlurViewGlassType::Regular; return; }
|
|
71
|
-
abort();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static inline std::string toString(const ReactNativeBlurViewGlassType &value) {
|
|
75
|
-
switch (value) {
|
|
76
|
-
case ReactNativeBlurViewGlassType::Clear: return "clear";
|
|
77
|
-
case ReactNativeBlurViewGlassType::Regular: return "regular";
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
50
|
|
|
81
51
|
class ReactNativeBlurViewProps final : public ViewProps {
|
|
82
52
|
public:
|
|
@@ -85,47 +55,9 @@ class ReactNativeBlurViewProps final : public ViewProps {
|
|
|
85
55
|
|
|
86
56
|
#pragma mark - Props
|
|
87
57
|
|
|
88
|
-
|
|
89
|
-
double glassOpacity{1.0};
|
|
58
|
+
ReactNativeBlurViewBlurType blurType{ReactNativeBlurViewBlurType::Light};
|
|
90
59
|
double blurAmount{10.0};
|
|
91
|
-
|
|
92
|
-
ReactNativeBlurViewBlurType blurType{ReactNativeBlurViewBlurType::Xlight};
|
|
93
|
-
ReactNativeBlurViewGlassType glassType{ReactNativeBlurViewGlassType::Clear};
|
|
94
|
-
std::string reducedTransparencyFallbackColor{"#FFFFFF"};
|
|
95
|
-
bool isInteractive{true};
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
enum class ReactNativeGlassEffectContainerGlassType { Clear, Regular };
|
|
99
|
-
|
|
100
|
-
static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNativeGlassEffectContainerGlassType &result) {
|
|
101
|
-
auto string = (std::string)value;
|
|
102
|
-
if (string == "clear") { result = ReactNativeGlassEffectContainerGlassType::Clear; return; }
|
|
103
|
-
if (string == "regular") { result = ReactNativeGlassEffectContainerGlassType::Regular; return; }
|
|
104
|
-
abort();
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
static inline std::string toString(const ReactNativeGlassEffectContainerGlassType &value) {
|
|
108
|
-
switch (value) {
|
|
109
|
-
case ReactNativeGlassEffectContainerGlassType::Clear: return "clear";
|
|
110
|
-
case ReactNativeGlassEffectContainerGlassType::Regular: return "regular";
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
class ReactNativeGlassEffectContainerProps final : public ViewProps {
|
|
115
|
-
public:
|
|
116
|
-
ReactNativeGlassEffectContainerProps() = default;
|
|
117
|
-
ReactNativeGlassEffectContainerProps(const PropsParserContext& context, const ReactNativeGlassEffectContainerProps &sourceProps, const RawProps &rawProps);
|
|
118
|
-
|
|
119
|
-
#pragma mark - Props
|
|
120
|
-
|
|
121
|
-
ReactNativeGlassEffectContainerGlassType glassType{ReactNativeGlassEffectContainerGlassType::Clear};
|
|
122
|
-
std::string glassTintColor{"clear"};
|
|
123
|
-
double glassOpacity{1.0};
|
|
124
|
-
bool isInteractive{true};
|
|
125
|
-
double spacing{8.0};
|
|
126
|
-
bool enableMorphing{true};
|
|
127
|
-
int morphingDuration{300};
|
|
128
|
-
std::string reducedTransparencyFallbackColor{"#FFFFFF"};
|
|
60
|
+
std::string reducedTransparencyFallbackColor{};
|
|
129
61
|
};
|
|
130
62
|
|
|
131
63
|
} // namespace facebook::react
|
|
@@ -29,15 +29,4 @@ using ReactNativeBlurViewShadowNode = ConcreteViewShadowNode<
|
|
|
29
29
|
ReactNativeBlurViewEventEmitter,
|
|
30
30
|
ReactNativeBlurViewState>;
|
|
31
31
|
|
|
32
|
-
JSI_EXPORT extern const char ReactNativeGlassEffectContainerComponentName[];
|
|
33
|
-
|
|
34
|
-
/*
|
|
35
|
-
* `ShadowNode` for <ReactNativeGlassEffectContainer> component.
|
|
36
|
-
*/
|
|
37
|
-
using ReactNativeGlassEffectContainerShadowNode = ConcreteViewShadowNode<
|
|
38
|
-
ReactNativeGlassEffectContainerComponentName,
|
|
39
|
-
ReactNativeGlassEffectContainerProps,
|
|
40
|
-
ReactNativeGlassEffectContainerEventEmitter,
|
|
41
|
-
ReactNativeGlassEffectContainerState>;
|
|
42
|
-
|
|
43
32
|
} // namespace facebook::react
|
|
@@ -26,16 +26,4 @@ public:
|
|
|
26
26
|
#endif
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
class ReactNativeGlassEffectContainerState {
|
|
30
|
-
public:
|
|
31
|
-
ReactNativeGlassEffectContainerState() = default;
|
|
32
|
-
|
|
33
|
-
#ifdef ANDROID
|
|
34
|
-
ReactNativeGlassEffectContainerState(ReactNativeGlassEffectContainerState const &previousState, folly::dynamic data){};
|
|
35
|
-
folly::dynamic getDynamic() const {
|
|
36
|
-
return {};
|
|
37
|
-
};
|
|
38
|
-
#endif
|
|
39
|
-
};
|
|
40
|
-
|
|
41
29
|
} // namespace facebook::react
|
|
@@ -19,6 +19,7 @@ class ReactNativeBlurView : BlurView {
|
|
|
19
19
|
private var blurRadius = mapBlurAmountToRadius(DEFAULT_BLUR_AMOUNT)
|
|
20
20
|
private var overlayColor = Color.TRANSPARENT
|
|
21
21
|
private var isSetup = false
|
|
22
|
+
private var isConfigured = false
|
|
22
23
|
private var pendingStyleUpdate: Boolean = false
|
|
23
24
|
private var originalBackgroundColor: Int? = null
|
|
24
25
|
private var hasExplicitBackground: Boolean = false
|
|
@@ -179,15 +180,23 @@ class ReactNativeBlurView : BlurView {
|
|
|
179
180
|
*/
|
|
180
181
|
override fun onAttachedToWindow() {
|
|
181
182
|
super.onAttachedToWindow()
|
|
182
|
-
|
|
183
|
+
|
|
184
|
+
// Now we can safely walk the parent hierarchy
|
|
185
|
+
if (!this.isConfigured) {
|
|
186
|
+
this.isConfigured = true
|
|
187
|
+
setupBlurView()
|
|
188
|
+
}
|
|
183
189
|
}
|
|
184
190
|
|
|
185
191
|
/**
|
|
186
192
|
* Called when the view is detached from a window.
|
|
187
|
-
* Performs cleanup to prevent memory leaks.
|
|
193
|
+
* Performs cleanup to prevent memory leaks and navigation transition issues.
|
|
188
194
|
*/
|
|
189
195
|
override fun onDetachedFromWindow() {
|
|
190
196
|
super.onDetachedFromWindow()
|
|
197
|
+
|
|
198
|
+
this.isConfigured = false
|
|
199
|
+
this.removeCallbacks(null)
|
|
191
200
|
cleanup()
|
|
192
201
|
}
|
|
193
202
|
|
|
@@ -195,7 +204,7 @@ class ReactNativeBlurView : BlurView {
|
|
|
195
204
|
* Cleanup method to reset state and remove pending callbacks.
|
|
196
205
|
* Helps prevent memory leaks and ensures clean state.
|
|
197
206
|
*/
|
|
198
|
-
|
|
207
|
+
fun cleanup() {
|
|
199
208
|
isSetup = false
|
|
200
209
|
hasExplicitBackground = false
|
|
201
210
|
originalBackgroundColor = null
|
|
@@ -213,7 +222,7 @@ class ReactNativeBlurView : BlurView {
|
|
|
213
222
|
if (isSetup) return
|
|
214
223
|
|
|
215
224
|
try {
|
|
216
|
-
val rootView =
|
|
225
|
+
val rootView = findOptimalBlurRoot()
|
|
217
226
|
|
|
218
227
|
rootView?.let { root ->
|
|
219
228
|
try {
|
|
@@ -248,7 +257,8 @@ class ReactNativeBlurView : BlurView {
|
|
|
248
257
|
super.setBackgroundColor(originalBackgroundColor!!)
|
|
249
258
|
}
|
|
250
259
|
|
|
251
|
-
logDebug("Blur setup successful with root: ${root.javaClass.simpleName}")
|
|
260
|
+
logDebug("Blur setup successful with root: ${root.javaClass.simpleName}")
|
|
261
|
+
} catch (e: Exception) {
|
|
252
262
|
logWarning("Failed to setup blur algorithm: ${e.message}")
|
|
253
263
|
// Fallback: use semi-transparent overlay when blur is unsupported
|
|
254
264
|
super.setBackgroundColor(overlayColor)
|
|
@@ -261,12 +271,45 @@ class ReactNativeBlurView : BlurView {
|
|
|
261
271
|
isSetup = true
|
|
262
272
|
}
|
|
263
273
|
} catch (e: Exception) {
|
|
264
|
-
//
|
|
274
|
+
// Final fallback: set transparent background to prevent visual artifacts
|
|
265
275
|
super.setBackgroundColor(overlayColor)
|
|
266
276
|
logError("Failed to setup blur: ${e.message}", e)
|
|
267
277
|
}
|
|
268
278
|
}
|
|
269
279
|
|
|
280
|
+
/**
|
|
281
|
+
* Find the optimal blur root view by walking up the parent hierarchy.
|
|
282
|
+
* This method is crucial for proper blur rendering during navigation transitions.
|
|
283
|
+
* @return The optimal ViewGroup to use as blur root or null if not found
|
|
284
|
+
*/
|
|
285
|
+
private fun findOptimalBlurRoot(): ViewGroup? {
|
|
286
|
+
var current = this.parent
|
|
287
|
+
|
|
288
|
+
// Walk up the parent hierarchy to find the best blur root
|
|
289
|
+
while (current != null) {
|
|
290
|
+
if (current is ViewGroup) {
|
|
291
|
+
// Prefer content view as it's the most stable during transitions
|
|
292
|
+
if (current.id == android.R.id.content) {
|
|
293
|
+
return current
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// Look for other suitable container views
|
|
297
|
+
val className = current.javaClass.simpleName
|
|
298
|
+
if (className.contains("DecorView") ||
|
|
299
|
+
className.contains("ContentFrameLayout") ||
|
|
300
|
+
(className.contains("LinearLayout") && current.parent == null)) {
|
|
301
|
+
// For LinearLayout, only consider it if it's the root of the hierarchy (parent == null)
|
|
302
|
+
// This avoids misidentifying containers in complex layouts
|
|
303
|
+
return current
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
current = current.parent
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Fallback: try to get activity's content view
|
|
310
|
+
return findRootView()
|
|
311
|
+
}
|
|
312
|
+
|
|
270
313
|
/**
|
|
271
314
|
* Find the root view using multiple strategies.
|
|
272
315
|
* @return The root ViewGroup or null if not found
|
|
@@ -69,6 +69,16 @@ class ReactNativeBlurViewManager : ViewGroupManager<ReactNativeBlurView>(),
|
|
|
69
69
|
view?.setIsInteractive(isInteractive)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
/**
|
|
73
|
+
* Called when view is detached from view hierarchy and allows for cleanup.
|
|
74
|
+
* This prevents the white screen issue during navigation transitions on Android.
|
|
75
|
+
*/
|
|
76
|
+
override fun onDropViewInstance(view: ReactNativeBlurView) {
|
|
77
|
+
super.onDropViewInstance(view)
|
|
78
|
+
// Call cleanup to reset state and prevent white screen artifacts
|
|
79
|
+
view.cleanup()
|
|
80
|
+
}
|
|
81
|
+
|
|
72
82
|
companion object {
|
|
73
83
|
const val NAME = "ReactNativeBlurView"
|
|
74
84
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// AdvancedBlurView.swift
|
|
2
|
-
|
|
3
1
|
import SwiftUI
|
|
4
2
|
import UIKit
|
|
5
3
|
|
|
@@ -67,11 +65,34 @@ import UIKit
|
|
|
67
65
|
setupHostingController()
|
|
68
66
|
}
|
|
69
67
|
|
|
68
|
+
public override func layoutSubviews() {
|
|
69
|
+
super.layoutSubviews()
|
|
70
|
+
if hostingController == nil {
|
|
71
|
+
setupHostingController()
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
70
75
|
private func setupHostingController() {
|
|
76
|
+
// Completely remove old hosting controller
|
|
77
|
+
if let oldHosting = hostingController {
|
|
78
|
+
oldHosting.view.removeFromSuperview()
|
|
79
|
+
oldHosting.removeFromParent()
|
|
80
|
+
}
|
|
81
|
+
hostingController = nil
|
|
82
|
+
|
|
71
83
|
let blurStyle = blurStyleFromString(blurTypeString)
|
|
72
|
-
let swiftUIView = BasicColoredView(
|
|
73
|
-
|
|
84
|
+
let swiftUIView = BasicColoredView(
|
|
85
|
+
glassTintColor: glassTintColor,
|
|
86
|
+
glassOpacity: glassOpacity,
|
|
87
|
+
blurAmount: blurAmount,
|
|
88
|
+
blurStyle: blurStyle,
|
|
89
|
+
type: type,
|
|
90
|
+
glassType: glassType,
|
|
91
|
+
reducedTransparencyFallbackColor: reducedTransparencyFallbackColor,
|
|
92
|
+
isInteractive: isInteractive
|
|
93
|
+
)
|
|
74
94
|
|
|
95
|
+
let hosting = UIHostingController(rootView: swiftUIView)
|
|
75
96
|
hosting.view.backgroundColor = .clear
|
|
76
97
|
hosting.view.translatesAutoresizingMaskIntoConstraints = false
|
|
77
98
|
|
|
@@ -87,8 +108,28 @@ import UIKit
|
|
|
87
108
|
}
|
|
88
109
|
|
|
89
110
|
private func updateView() {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
111
|
+
setupHostingController()
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public override func didMoveToSuperview() {
|
|
115
|
+
super.didMoveToSuperview()
|
|
116
|
+
if superview != nil {
|
|
117
|
+
setupHostingController()
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
public override func didMoveToWindow() {
|
|
122
|
+
super.didMoveToWindow()
|
|
123
|
+
if window != nil {
|
|
124
|
+
setupHostingController()
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
deinit {
|
|
129
|
+
if let hosting = hostingController {
|
|
130
|
+
hosting.view.removeFromSuperview()
|
|
131
|
+
hosting.removeFromParent()
|
|
132
|
+
}
|
|
133
|
+
hostingController = nil
|
|
93
134
|
}
|
|
94
|
-
}
|
|
135
|
+
}
|
|
@@ -28,8 +28,10 @@ class BlurEffectView: UIVisualEffectView {
|
|
|
28
28
|
|
|
29
29
|
private func setupBlur() {
|
|
30
30
|
// Clean up existing animator
|
|
31
|
-
animator
|
|
32
|
-
|
|
31
|
+
if let animator = animator {
|
|
32
|
+
animator.stopAnimation(true)
|
|
33
|
+
animator.finishAnimation(at: .current)
|
|
34
|
+
}
|
|
33
35
|
animator = nil
|
|
34
36
|
|
|
35
37
|
// Reset effect
|
package/package.json
CHANGED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
-
*
|
|
4
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
-
* once the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
package com.facebook.react.viewmanagers;
|
|
11
|
-
|
|
12
|
-
import android.view.View;
|
|
13
|
-
import androidx.annotation.Nullable;
|
|
14
|
-
import com.facebook.react.uimanager.BaseViewManager;
|
|
15
|
-
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
16
|
-
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
17
|
-
|
|
18
|
-
public class ReactNativeGlassEffectContainerManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ReactNativeGlassEffectContainerManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
19
|
-
public ReactNativeGlassEffectContainerManagerDelegate(U viewManager) {
|
|
20
|
-
super(viewManager);
|
|
21
|
-
}
|
|
22
|
-
@Override
|
|
23
|
-
public void setProperty(T view, String propName, @Nullable Object value) {
|
|
24
|
-
switch (propName) {
|
|
25
|
-
case "glassType":
|
|
26
|
-
mViewManager.setGlassType(view, (String) value);
|
|
27
|
-
break;
|
|
28
|
-
case "glassTintColor":
|
|
29
|
-
mViewManager.setGlassTintColor(view, value == null ? "clear" : (String) value);
|
|
30
|
-
break;
|
|
31
|
-
case "glassOpacity":
|
|
32
|
-
mViewManager.setGlassOpacity(view, value == null ? 1f : ((Double) value).doubleValue());
|
|
33
|
-
break;
|
|
34
|
-
case "isInteractive":
|
|
35
|
-
mViewManager.setIsInteractive(view, value == null ? true : (boolean) value);
|
|
36
|
-
break;
|
|
37
|
-
case "spacing":
|
|
38
|
-
mViewManager.setSpacing(view, value == null ? 8f : ((Double) value).doubleValue());
|
|
39
|
-
break;
|
|
40
|
-
case "enableMorphing":
|
|
41
|
-
mViewManager.setEnableMorphing(view, value == null ? true : (boolean) value);
|
|
42
|
-
break;
|
|
43
|
-
case "morphingDuration":
|
|
44
|
-
mViewManager.setMorphingDuration(view, value == null ? 300 : ((Double) value).intValue());
|
|
45
|
-
break;
|
|
46
|
-
case "reducedTransparencyFallbackColor":
|
|
47
|
-
mViewManager.setReducedTransparencyFallbackColor(view, value == null ? "#FFFFFF" : (String) value);
|
|
48
|
-
break;
|
|
49
|
-
default:
|
|
50
|
-
super.setProperty(view, propName, value);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
-
*
|
|
4
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
-
* once the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
package com.facebook.react.viewmanagers;
|
|
11
|
-
|
|
12
|
-
import android.view.View;
|
|
13
|
-
import androidx.annotation.Nullable;
|
|
14
|
-
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
|
|
15
|
-
|
|
16
|
-
public interface ReactNativeGlassEffectContainerManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
|
|
17
|
-
void setGlassType(T view, @Nullable String value);
|
|
18
|
-
void setGlassTintColor(T view, @Nullable String value);
|
|
19
|
-
void setGlassOpacity(T view, double value);
|
|
20
|
-
void setIsInteractive(T view, boolean value);
|
|
21
|
-
void setSpacing(T view, double value);
|
|
22
|
-
void setEnableMorphing(T view, boolean value);
|
|
23
|
-
void setMorphingDuration(T view, int value);
|
|
24
|
-
void setReducedTransparencyFallbackColor(T view, @Nullable String value);
|
|
25
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
-
*
|
|
4
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
-
* once the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @generated by codegen project: GeneratePropsJavaDelegate.js
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
package com.facebook.react.viewmanagers;
|
|
11
|
-
|
|
12
|
-
import android.view.View;
|
|
13
|
-
import androidx.annotation.Nullable;
|
|
14
|
-
import com.facebook.react.uimanager.BaseViewManager;
|
|
15
|
-
import com.facebook.react.uimanager.BaseViewManagerDelegate;
|
|
16
|
-
import com.facebook.react.uimanager.LayoutShadowNode;
|
|
17
|
-
|
|
18
|
-
public class ReactNativeGlassViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ReactNativeGlassViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
|
|
19
|
-
public ReactNativeGlassViewManagerDelegate(U viewManager) {
|
|
20
|
-
super(viewManager);
|
|
21
|
-
}
|
|
22
|
-
@Override
|
|
23
|
-
public void setProperty(T view, String propName, @Nullable Object value) {
|
|
24
|
-
switch (propName) {
|
|
25
|
-
case "glassType":
|
|
26
|
-
mViewManager.setGlassType(view, (String) value);
|
|
27
|
-
break;
|
|
28
|
-
case "glassAmount":
|
|
29
|
-
mViewManager.setGlassAmount(view, value == null ? 50f : ((Double) value).doubleValue());
|
|
30
|
-
break;
|
|
31
|
-
case "reducedTransparencyFallbackColor":
|
|
32
|
-
mViewManager.setReducedTransparencyFallbackColor(view, value == null ? null : (String) value);
|
|
33
|
-
break;
|
|
34
|
-
default:
|
|
35
|
-
super.setProperty(view, propName, value);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
3
|
-
*
|
|
4
|
-
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
5
|
-
* once the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @generated by codegen project: GeneratePropsJavaInterface.js
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
package com.facebook.react.viewmanagers;
|
|
11
|
-
|
|
12
|
-
import android.view.View;
|
|
13
|
-
import androidx.annotation.Nullable;
|
|
14
|
-
import com.facebook.react.uimanager.ViewManagerWithGeneratedInterface;
|
|
15
|
-
|
|
16
|
-
public interface ReactNativeGlassViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
|
|
17
|
-
void setGlassType(T view, @Nullable String value);
|
|
18
|
-
void setGlassAmount(T view, double value);
|
|
19
|
-
void setReducedTransparencyFallbackColor(T view, @Nullable String value);
|
|
20
|
-
}
|