@sbaiahmed1/react-native-blur 0.2.0 → 0.2.1

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.
Files changed (22) hide show
  1. package/README.md +151 -0
  2. package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerDelegate.java +38 -0
  3. package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerInterface.java +20 -0
  4. package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassViewManagerDelegate.java +38 -0
  5. package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassViewManagerInterface.java +20 -0
  6. package/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
  7. package/android/app/build/generated/source/codegen/jni/ReactNativeBlurViewSpec-generated.cpp +22 -0
  8. package/android/app/build/generated/source/codegen/jni/ReactNativeBlurViewSpec.h +24 -0
  9. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.cpp +23 -0
  10. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.h +25 -0
  11. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.cpp +17 -0
  12. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.h +30 -0
  13. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.cpp +36 -0
  14. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.h +91 -0
  15. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ReactNativeBlurViewSpecJSI-generated.cpp +17 -0
  16. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ReactNativeBlurViewSpecJSI.h +19 -0
  17. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.cpp +18 -0
  18. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.h +43 -0
  19. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/States.cpp +16 -0
  20. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/States.h +41 -0
  21. package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt +45 -16
  22. package/package.json +2 -2
package/README.md CHANGED
@@ -34,6 +34,137 @@ A modern React Native blur view component that provides native blur effects for
34
34
  - 🛠️ **Easy to Use**: Simple API for quick integration into your React Native projects
35
35
  - 📦 **Modern**: Uses Kotlin for Android implementation and *will* use Swift for iOS, ensuring modern development practices
36
36
 
37
+ ## 📊 Library Comparison
38
+
39
+ This section provides a detailed comparison between `@sbaiahmed1/react-native-blur` and other popular blur libraries in the React Native ecosystem.
40
+
41
+ ### vs. [@react-native-community/blur](https://www.npmjs.com/package/@react-native-community/blur)
42
+
43
+ | Feature | @sbaiahmed1/react-native-blur | @react-native-community/blur |
44
+ |------------------------------|-------------------------------------|---------------------------------------|
45
+ | **New Architecture Support** | ✅ Full Fabric/Turbo Module support | ❌ Limited support (crashes on android |
46
+ | **Android Real Blur** | ✅ Hardware-accelerated real blur | ✅ Hardware-accelerated real blur |
47
+ | **iOS Blur Quality** | ✅ Native UIVisualEffectView | ✅ Native UIVisualEffectView |
48
+ | **TypeScript Support** | ✅ Full TypeScript definitions | ⚠️ Basic TypeScript support |
49
+ | **Maintenance Status** | ✅ Actively maintained | ⚠️ Community-maintained |
50
+ | **Bundle Size** | 🟡 Moderate (includes BlurView lib) | 🟡 Moderate (includes BlurView lib) |
51
+ | **API Complexity** | ✅ Simple, intuitive API | ✅ Simple API |
52
+ | **Performance** | ✅ Hardware-accelerated | 🟡 iOS: Good, Android: Limited |
53
+ | **Accessibility** | ✅ Full reduced transparency support | ✅ Reduced transparency support |
54
+ | **Documentation** | ✅ Comprehensive with examples | 🟡 Basic documentation |
55
+
56
+ **Advantages of @sbaiahmed1/react-native-blur:**
57
+ - **True Android Blur**: Unlike the community version which only provides semi-transparent overlays on Android, our library delivers real hardware-accelerated blur effects on both platforms
58
+ - **Future-Ready**: Built from the ground up with React Native's new architecture (Fabric) in mind
59
+ - **Modern Codebase**: Uses the latest development practices with Kotlin for Android
60
+ - ** Uses Swift**: Use of Swift for iOS, ensuring modern and efficient native code
61
+ - **Better Performance**: Hardware acceleration on both platforms ensures smooth rendering
62
+ - **Active Development**: Regular updates and feature additions
63
+
64
+ **When to choose @react-native-community/blur:**
65
+ - If you need a battle-tested library with extensive community usage
66
+ - If bundle size is a critical concern
67
+ - If you're working with older React Native versions
68
+
69
+ ### vs. [expo-blur](https://www.npmjs.com/package/expo-blur)
70
+
71
+ | Feature | @sbaiahmed1/react-native-blur | expo-blur |
72
+ |---------|------------------------------|----------|
73
+ | **Expo Dependency** | ✅ No Expo required | ❌ Requires Expo SDK |
74
+ | **Bare React Native** | ✅ Works with any RN project | ⚠️ Requires Expo configuration |
75
+ | **Android Support** | ✅ Real blur effects | ❌ Semi-transparent view only |
76
+ | **iOS Support** | ✅ Full native blur support | ✅ Full native blur support |
77
+ | **Bundle Size** | 🟡 Moderate | ✅ Lightweight (when using Expo) |
78
+ | **Setup Complexity** | ✅ Simple npm install | 🟡 Requires Expo setup |
79
+ | **Customization** | ✅ Extensive blur type options | 🟡 Limited blur types |
80
+ | **New Architecture** | ✅ Full Fabric support | ✅ Expo handles compatibility |
81
+ | **Development Experience** | ✅ Standard RN development | ✅ Excellent with Expo tools |
82
+ | **Production Flexibility** | ✅ Any deployment method | 🟡 Expo-specific deployment |
83
+
84
+ **Advantages of @sbaiahmed1/react-native-blur:**
85
+ - **No Vendor Lock-in**: Works with any React Native project without requiring Expo ecosystem
86
+ - **Real Android Blur**: Provides actual blur effects on Android, not just transparency
87
+ - **Flexibility**: Can be used in brownfield apps, custom native modules, and any deployment scenario
88
+ - **More Blur Types**: Extensive support for iOS system materials and custom blur types
89
+ - **Direct Control**: Full control over native implementation without abstraction layers
90
+
91
+ **When to choose expo-blur:**
92
+ - If you're already using Expo and want ecosystem consistency
93
+ - If you prefer Expo's managed workflow and tooling
94
+ - If you only need basic blur effects and iOS-focused functionality
95
+ - If you want the simplicity of Expo's managed dependencies
96
+
97
+ ### Performance Comparison
98
+
99
+ | Metric | @sbaiahmed1/react-native-blur | @react-native-community/blur | expo-blur |
100
+ |--------|------------------------------|------------------------------|----------|
101
+ | **iOS Rendering** | Hardware-accelerated | Hardware-accelerated | Hardware-accelerated |
102
+ | **Android Rendering** | Hardware-accelerated real blur | Software overlay | Software overlay |
103
+ | **Memory Usage** | Optimized with BlurView | Low | Low |
104
+ | **CPU Impact** | Low (GPU-based) | iOS: Low, Android: Minimal | iOS: Low, Android: Minimal |
105
+ | **Frame Rate Impact** | Minimal on both platforms | iOS: Minimal, Android: None | iOS: Minimal, Android: None |
106
+
107
+ ### Community & Support
108
+
109
+ | Aspect | @sbaiahmed1/react-native-blur | @react-native-community/blur | expo-blur |
110
+ |--------|------------------------------|------------------------------|----------|
111
+ | **GitHub Stars** | 🆕 Growing | 🌟 Established (3.8k+) | 🌟 Part of Expo ecosystem |
112
+ | **Issue Response** | ✅ Active maintainer | 🟡 Community-driven | ✅ Expo team support |
113
+ | **Documentation Quality** | ✅ Comprehensive | 🟡 Basic | ✅ Excellent (Expo docs) |
114
+ | **Update Frequency** | ✅ Regular updates | 🟡 Sporadic | ✅ Regular (with Expo releases) |
115
+ | **Breaking Changes** | ✅ Semantic versioning | ⚠️ Occasional | ✅ Managed by Expo |
116
+
117
+ ### Migration Guide
118
+
119
+ #### From @react-native-community/blur
120
+
121
+ ```tsx
122
+ // Before
123
+ import { BlurView } from '@react-native-community/blur';
124
+
125
+ // After
126
+ import { BlurView } from '@sbaiahmed1/react-native-blur';
127
+
128
+ // API is largely compatible, main differences:
129
+ // - Better Android blur quality
130
+ // - Additional iOS system material types
131
+ // - Improved TypeScript support
132
+ ```
133
+
134
+ #### From expo-blur
135
+
136
+ ```tsx
137
+ // Before
138
+ import { BlurView } from 'expo-blur';
139
+
140
+ // After
141
+ import { BlurView } from '@sbaiahmed1/react-native-blur';
142
+
143
+ // Key differences:
144
+ // - More blur type options available
145
+ // - Real Android blur instead of transparency
146
+ // - No Expo dependency required
147
+ ```
148
+
149
+ ### Recommendation
150
+
151
+ **Choose @sbaiahmed1/react-native-blur if:**
152
+ - You want real blur effects on Android
153
+ - You're building for the new React Native architecture
154
+ - You need maximum flexibility and don't want vendor lock-in
155
+ - You want the latest performance optimizations
156
+ - You're starting a new project or can afford migration time
157
+
158
+ **Choose @react-native-community/blur if:**
159
+ - You have an existing project that works well with it
160
+ - Bundle size is critical and Android blur quality is not important
161
+ - You need maximum stability and community testing
162
+
163
+ **Choose expo-blur if:**
164
+ - You're already committed to the Expo ecosystem
165
+ - You only need iOS blur effects
166
+ - You prefer managed dependencies and simplified setup
167
+
37
168
  ## Architecture Compatibility
38
169
 
39
170
  This library is fully compatible with both React Native architectures:
@@ -84,6 +215,26 @@ The Android implementation leverages the BlurView library to provide real blur e
84
215
  - **Fallback Handling:** Gracefully handles devices with limited graphics capabilities
85
216
  - **No Extra Permissions:** Does not require additional Android permissions
86
217
 
218
+ ### Android Version Compatibility
219
+
220
+ This library automatically handles Android version compatibility to prevent `NoClassDefFoundError` issues:
221
+
222
+ - **Android 12+ (API 31+):** Uses `RenderEffectBlur` for optimal performance and modern blur effects
223
+ - **Android 10-11 (API 29-30):** Automatically falls back to `RenderScriptBlur` for compatibility
224
+ - **Older Android versions:** Graceful fallback to semi-transparent overlay when blur is not supported
225
+
226
+ **Note:** The library includes automatic API level detection and will choose the appropriate blur algorithm based on the device's Android version. This ensures compatibility across all supported Android versions without requiring any additional configuration.
227
+
228
+ #### Troubleshooting Android Issues
229
+
230
+ If you encounter `java.lang.NoClassDefFoundError: Failed resolution of: Landroid/graphics/RenderEffect;` on Android 10 or 11:
231
+
232
+ 1. **This is automatically handled** - The library now includes fallback mechanisms
233
+ 2. **Update to latest version** - Ensure you're using the latest version of this library
234
+ 3. **Clean and rebuild** - Run `cd android && ./gradlew clean` then rebuild your project
235
+
236
+ The error occurs because `RenderEffect` was introduced in Android 12 (API 31), but the library now automatically detects the API level and uses compatible alternatives on older versions.
237
+
87
238
  ## Usage
88
239
 
89
240
  ### Basic Usage
@@ -0,0 +1,38 @@
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 ReactNativeBlurViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ReactNativeBlurViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
19
+ public ReactNativeBlurViewManagerDelegate(U viewManager) {
20
+ super(viewManager);
21
+ }
22
+ @Override
23
+ public void setProperty(T view, String propName, @Nullable Object value) {
24
+ switch (propName) {
25
+ case "blurType":
26
+ mViewManager.setBlurType(view, (String) value);
27
+ break;
28
+ case "blurAmount":
29
+ mViewManager.setBlurAmount(view, value == null ? 10f : ((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
+ }
@@ -0,0 +1,20 @@
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 ReactNativeBlurViewManagerInterface<T extends View> extends ViewManagerWithGeneratedInterface {
17
+ void setBlurType(T view, @Nullable String value);
18
+ void setBlurAmount(T view, double value);
19
+ void setReducedTransparencyFallbackColor(T view, @Nullable String value);
20
+ }
@@ -0,0 +1,38 @@
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
+ }
@@ -0,0 +1,20 @@
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
+ }
@@ -0,0 +1,36 @@
1
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
2
+ #
3
+ # This source code is licensed under the MIT license found in the
4
+ # LICENSE file in the root directory of this source tree.
5
+
6
+ cmake_minimum_required(VERSION 3.13)
7
+ set(CMAKE_VERBOSE_MAKEFILE on)
8
+
9
+ file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/ReactNativeBlurViewSpec/*.cpp)
10
+
11
+ add_library(
12
+ react_codegen_ReactNativeBlurViewSpec
13
+ OBJECT
14
+ ${react_codegen_SRCS}
15
+ )
16
+
17
+ target_include_directories(react_codegen_ReactNativeBlurViewSpec PUBLIC . react/renderer/components/ReactNativeBlurViewSpec)
18
+
19
+ target_link_libraries(
20
+ react_codegen_ReactNativeBlurViewSpec
21
+ fbjni
22
+ jsi
23
+ # We need to link different libraries based on whether we are building rncore or not, that's necessary
24
+ # because we want to break a circular dependency between react_codegen_rncore and reactnative
25
+ reactnative
26
+ )
27
+
28
+ target_compile_options(
29
+ react_codegen_ReactNativeBlurViewSpec
30
+ PRIVATE
31
+ -DLOG_TAG=\"ReactNative\"
32
+ -fexceptions
33
+ -frtti
34
+ -std=c++20
35
+ -Wall
36
+ )
@@ -0,0 +1,22 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniCpp.js
9
+ */
10
+
11
+ #include "ReactNativeBlurViewSpec.h"
12
+
13
+ namespace facebook::react {
14
+
15
+
16
+
17
+ std::shared_ptr<TurboModule> ReactNativeBlurViewSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
18
+
19
+ return nullptr;
20
+ }
21
+
22
+ } // namespace facebook::react
@@ -0,0 +1,24 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateModuleJniH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <ReactCommon/JavaTurboModule.h>
14
+ #include <ReactCommon/TurboModule.h>
15
+ #include <jsi/jsi.h>
16
+
17
+ namespace facebook::react {
18
+
19
+
20
+
21
+ JSI_EXPORT
22
+ std::shared_ptr<TurboModule> ReactNativeBlurViewSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
23
+
24
+ } // namespace facebook::react
@@ -0,0 +1,23 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorCpp.js
9
+ */
10
+
11
+ #include <react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.h>
12
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
13
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
14
+
15
+ namespace facebook::react {
16
+
17
+ void ReactNativeBlurViewSpec_registerComponentDescriptorsFromCodegen(
18
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry) {
19
+ registry->add(concreteComponentDescriptorProvider<ReactNativeBlurViewComponentDescriptor>());
20
+ registry->add(concreteComponentDescriptorProvider<ReactNativeGlassViewComponentDescriptor>());
21
+ }
22
+
23
+ } // namespace facebook::react
@@ -0,0 +1,25 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateComponentDescriptorH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.h>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
16
+
17
+ namespace facebook::react {
18
+
19
+ using ReactNativeBlurViewComponentDescriptor = ConcreteComponentDescriptor<ReactNativeBlurViewShadowNode>;
20
+ using ReactNativeGlassViewComponentDescriptor = ConcreteComponentDescriptor<ReactNativeGlassViewShadowNode>;
21
+
22
+ void ReactNativeBlurViewSpec_registerComponentDescriptorsFromCodegen(
23
+ std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
24
+
25
+ } // namespace facebook::react
@@ -0,0 +1,17 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterCpp.js
9
+ */
10
+
11
+ #include <react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.h>
12
+
13
+
14
+ namespace facebook::react {
15
+
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,30 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateEventEmitterH.js
9
+ */
10
+ #pragma once
11
+
12
+ #include <react/renderer/components/view/ViewEventEmitter.h>
13
+
14
+
15
+ namespace facebook::react {
16
+ class ReactNativeBlurViewEventEmitter : public ViewEventEmitter {
17
+ public:
18
+ using ViewEventEmitter::ViewEventEmitter;
19
+
20
+
21
+
22
+ };
23
+ class ReactNativeGlassViewEventEmitter : public ViewEventEmitter {
24
+ public:
25
+ using ViewEventEmitter::ViewEventEmitter;
26
+
27
+
28
+
29
+ };
30
+ } // namespace facebook::react
@@ -0,0 +1,36 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GeneratePropsCpp.js
9
+ */
10
+
11
+ #include <react/renderer/components/ReactNativeBlurViewSpec/Props.h>
12
+ #include <react/renderer/core/PropsParserContext.h>
13
+ #include <react/renderer/core/propsConversions.h>
14
+
15
+ namespace facebook::react {
16
+
17
+ ReactNativeBlurViewProps::ReactNativeBlurViewProps(
18
+ const PropsParserContext &context,
19
+ const ReactNativeBlurViewProps &sourceProps,
20
+ const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
21
+
22
+ blurType(convertRawProp(context, rawProps, "blurType", sourceProps.blurType, {ReactNativeBlurViewBlurType::Light})),
23
+ blurAmount(convertRawProp(context, rawProps, "blurAmount", sourceProps.blurAmount, {10.0})),
24
+ reducedTransparencyFallbackColor(convertRawProp(context, rawProps, "reducedTransparencyFallbackColor", sourceProps.reducedTransparencyFallbackColor, {}))
25
+ {}
26
+ ReactNativeGlassViewProps::ReactNativeGlassViewProps(
27
+ const PropsParserContext &context,
28
+ const ReactNativeGlassViewProps &sourceProps,
29
+ const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
30
+
31
+ glassType(convertRawProp(context, rawProps, "glassType", sourceProps.glassType, {ReactNativeGlassViewGlassType::Default})),
32
+ glassAmount(convertRawProp(context, rawProps, "glassAmount", sourceProps.glassAmount, {50.0})),
33
+ reducedTransparencyFallbackColor(convertRawProp(context, rawProps, "reducedTransparencyFallbackColor", sourceProps.reducedTransparencyFallbackColor, {}))
34
+ {}
35
+
36
+ } // namespace facebook::react
@@ -0,0 +1,91 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GeneratePropsH.js
9
+ */
10
+ #pragma once
11
+
12
+ #include <react/renderer/components/view/ViewProps.h>
13
+ #include <react/renderer/core/PropsParserContext.h>
14
+
15
+ namespace facebook::react {
16
+
17
+ enum class ReactNativeBlurViewBlurType { Xlight, Light, Dark, ExtraDark, Regular, Prominent, SystemUltraThinMaterial, SystemThinMaterial, SystemMaterial, SystemThickMaterial, SystemChromeMaterial };
18
+
19
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNativeBlurViewBlurType &result) {
20
+ auto string = (std::string)value;
21
+ if (string == "xlight") { result = ReactNativeBlurViewBlurType::Xlight; return; }
22
+ if (string == "light") { result = ReactNativeBlurViewBlurType::Light; return; }
23
+ if (string == "dark") { result = ReactNativeBlurViewBlurType::Dark; return; }
24
+ if (string == "extraDark") { result = ReactNativeBlurViewBlurType::ExtraDark; return; }
25
+ if (string == "regular") { result = ReactNativeBlurViewBlurType::Regular; return; }
26
+ if (string == "prominent") { result = ReactNativeBlurViewBlurType::Prominent; return; }
27
+ if (string == "systemUltraThinMaterial") { result = ReactNativeBlurViewBlurType::SystemUltraThinMaterial; return; }
28
+ if (string == "systemThinMaterial") { result = ReactNativeBlurViewBlurType::SystemThinMaterial; return; }
29
+ if (string == "systemMaterial") { result = ReactNativeBlurViewBlurType::SystemMaterial; return; }
30
+ if (string == "systemThickMaterial") { result = ReactNativeBlurViewBlurType::SystemThickMaterial; return; }
31
+ if (string == "systemChromeMaterial") { result = ReactNativeBlurViewBlurType::SystemChromeMaterial; return; }
32
+ abort();
33
+ }
34
+
35
+ static inline std::string toString(const ReactNativeBlurViewBlurType &value) {
36
+ switch (value) {
37
+ case ReactNativeBlurViewBlurType::Xlight: return "xlight";
38
+ case ReactNativeBlurViewBlurType::Light: return "light";
39
+ case ReactNativeBlurViewBlurType::Dark: return "dark";
40
+ case ReactNativeBlurViewBlurType::ExtraDark: return "extraDark";
41
+ case ReactNativeBlurViewBlurType::Regular: return "regular";
42
+ case ReactNativeBlurViewBlurType::Prominent: return "prominent";
43
+ case ReactNativeBlurViewBlurType::SystemUltraThinMaterial: return "systemUltraThinMaterial";
44
+ case ReactNativeBlurViewBlurType::SystemThinMaterial: return "systemThinMaterial";
45
+ case ReactNativeBlurViewBlurType::SystemMaterial: return "systemMaterial";
46
+ case ReactNativeBlurViewBlurType::SystemThickMaterial: return "systemThickMaterial";
47
+ case ReactNativeBlurViewBlurType::SystemChromeMaterial: return "systemChromeMaterial";
48
+ }
49
+ }
50
+
51
+ class ReactNativeBlurViewProps final : public ViewProps {
52
+ public:
53
+ ReactNativeBlurViewProps() = default;
54
+ ReactNativeBlurViewProps(const PropsParserContext& context, const ReactNativeBlurViewProps &sourceProps, const RawProps &rawProps);
55
+
56
+ #pragma mark - Props
57
+
58
+ ReactNativeBlurViewBlurType blurType{ReactNativeBlurViewBlurType::Light};
59
+ double blurAmount{10.0};
60
+ std::string reducedTransparencyFallbackColor{};
61
+ };
62
+
63
+ enum class ReactNativeGlassViewGlassType { Clear, Default };
64
+
65
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNativeGlassViewGlassType &result) {
66
+ auto string = (std::string)value;
67
+ if (string == "clear") { result = ReactNativeGlassViewGlassType::Clear; return; }
68
+ if (string == "default") { result = ReactNativeGlassViewGlassType::Default; return; }
69
+ abort();
70
+ }
71
+
72
+ static inline std::string toString(const ReactNativeGlassViewGlassType &value) {
73
+ switch (value) {
74
+ case ReactNativeGlassViewGlassType::Clear: return "clear";
75
+ case ReactNativeGlassViewGlassType::Default: return "default";
76
+ }
77
+ }
78
+
79
+ class ReactNativeGlassViewProps final : public ViewProps {
80
+ public:
81
+ ReactNativeGlassViewProps() = default;
82
+ ReactNativeGlassViewProps(const PropsParserContext& context, const ReactNativeGlassViewProps &sourceProps, const RawProps &rawProps);
83
+
84
+ #pragma mark - Props
85
+
86
+ ReactNativeGlassViewGlassType glassType{ReactNativeGlassViewGlassType::Default};
87
+ double glassAmount{50.0};
88
+ std::string reducedTransparencyFallbackColor{};
89
+ };
90
+
91
+ } // namespace facebook::react
@@ -0,0 +1,17 @@
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: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "ReactNativeBlurViewSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+
15
+
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,19 @@
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: GenerateModuleH.js
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include <ReactCommon/TurboModule.h>
13
+ #include <react/bridging/Bridging.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+
19
+ } // namespace facebook::react
@@ -0,0 +1,18 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateShadowNodeCpp.js
9
+ */
10
+
11
+ #include <react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.h>
12
+
13
+ namespace facebook::react {
14
+
15
+ extern const char ReactNativeBlurViewComponentName[] = "ReactNativeBlurView";
16
+ extern const char ReactNativeGlassViewComponentName[] = "ReactNativeGlassView";
17
+
18
+ } // namespace facebook::react
@@ -0,0 +1,43 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateShadowNodeH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include <react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.h>
14
+ #include <react/renderer/components/ReactNativeBlurViewSpec/Props.h>
15
+ #include <react/renderer/components/ReactNativeBlurViewSpec/States.h>
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <jsi/jsi.h>
18
+
19
+ namespace facebook::react {
20
+
21
+ JSI_EXPORT extern const char ReactNativeBlurViewComponentName[];
22
+
23
+ /*
24
+ * `ShadowNode` for <ReactNativeBlurView> component.
25
+ */
26
+ using ReactNativeBlurViewShadowNode = ConcreteViewShadowNode<
27
+ ReactNativeBlurViewComponentName,
28
+ ReactNativeBlurViewProps,
29
+ ReactNativeBlurViewEventEmitter,
30
+ ReactNativeBlurViewState>;
31
+
32
+ JSI_EXPORT extern const char ReactNativeGlassViewComponentName[];
33
+
34
+ /*
35
+ * `ShadowNode` for <ReactNativeGlassView> component.
36
+ */
37
+ using ReactNativeGlassViewShadowNode = ConcreteViewShadowNode<
38
+ ReactNativeGlassViewComponentName,
39
+ ReactNativeGlassViewProps,
40
+ ReactNativeGlassViewEventEmitter,
41
+ ReactNativeGlassViewState>;
42
+
43
+ } // namespace facebook::react
@@ -0,0 +1,16 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateStateCpp.js
9
+ */
10
+ #include <react/renderer/components/ReactNativeBlurViewSpec/States.h>
11
+
12
+ namespace facebook::react {
13
+
14
+
15
+
16
+ } // namespace facebook::react
@@ -0,0 +1,41 @@
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: GenerateStateH.js
8
+ */
9
+ #pragma once
10
+
11
+ #ifdef ANDROID
12
+ #include <folly/dynamic.h>
13
+ #endif
14
+
15
+ namespace facebook::react {
16
+
17
+ class ReactNativeBlurViewState {
18
+ public:
19
+ ReactNativeBlurViewState() = default;
20
+
21
+ #ifdef ANDROID
22
+ ReactNativeBlurViewState(ReactNativeBlurViewState const &previousState, folly::dynamic data){};
23
+ folly::dynamic getDynamic() const {
24
+ return {};
25
+ };
26
+ #endif
27
+ };
28
+
29
+ class ReactNativeGlassViewState {
30
+ public:
31
+ ReactNativeGlassViewState() = default;
32
+
33
+ #ifdef ANDROID
34
+ ReactNativeGlassViewState(ReactNativeGlassViewState const &previousState, folly::dynamic data){};
35
+ folly::dynamic getDynamic() const {
36
+ return {};
37
+ };
38
+ #endif
39
+ };
40
+
41
+ } // namespace facebook::react
@@ -3,11 +3,13 @@ package com.sbaiahmed1.reactnativeblur
3
3
  import android.content.Context
4
4
  import android.graphics.Color
5
5
  import android.graphics.drawable.ColorDrawable
6
+ import android.os.Build
6
7
  import android.util.AttributeSet
7
8
  import android.util.Log
8
9
  import android.view.ViewGroup
9
10
  import eightbitlab.com.blurview.BlurView
10
11
  import eightbitlab.com.blurview.RenderEffectBlur
12
+ import eightbitlab.com.blurview.RenderScriptBlur
11
13
 
12
14
  /**
13
15
  * Android implementation of React Native BlurView component.
@@ -210,27 +212,54 @@ class ReactNativeBlurView : BlurView {
210
212
  val rootView = findRootView()
211
213
 
212
214
  rootView?.let { root ->
213
- // Setup the blur view with RenderEffect for better performance and modern API
214
- this.setupWith(root, RenderEffectBlur())
215
- .setBlurRadius(blurRadius)
216
- .setOverlayColor(overlayColor)
217
-
218
- isSetup = true
219
- pendingStyleUpdate = false
220
-
221
- // Apply any pending background color after blur setup
222
- if (hasExplicitBackground && originalBackgroundColor != null) {
223
- logDebug("Applying pending background color: $originalBackgroundColor")
224
- super.setBackgroundColor(originalBackgroundColor!!)
215
+ try {
216
+ // Choose blur algorithm based on Android API level
217
+ val blurAlgorithm = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
218
+ // Android 12+ (API 31+): Use RenderEffectBlur for better performance
219
+ logDebug("Using RenderEffectBlur for API ${Build.VERSION.SDK_INT}")
220
+ RenderEffectBlur()
221
+ } else {
222
+ // Android 10-11 (API < 31): Use RenderScriptBlur for compatibility
223
+ logDebug("Using RenderScriptBlur for API ${Build.VERSION.SDK_INT}")
224
+ try {
225
+ RenderScriptBlur(context)
226
+ } catch (e: Exception) {
227
+ logWarning("RenderScriptBlur not supported on this device: ${e.message}")
228
+ // Fallback: return null to trigger transparent background fallback
229
+ throw UnsupportedOperationException("Blur not supported on this device", e)
230
+ }
231
+ }
232
+
233
+ // Setup the blur view with the appropriate algorithm
234
+ this.setupWith(root, blurAlgorithm)
235
+ .setBlurRadius(blurRadius)
236
+ .setOverlayColor(overlayColor)
237
+
238
+ isSetup = true
239
+ pendingStyleUpdate = false
240
+
241
+ // Apply any pending background color after blur setup
242
+ if (hasExplicitBackground && originalBackgroundColor != null) {
243
+ logDebug("Applying pending background color: $originalBackgroundColor")
244
+ super.setBackgroundColor(originalBackgroundColor!!)
245
+ }
246
+
247
+ logDebug("Blur setup successful with root: ${root.javaClass.simpleName}")
248
+ } catch (e: Exception) {
249
+ logWarning("Failed to setup blur algorithm: ${e.message}")
250
+ // Fallback: use semi-transparent overlay when blur is unsupported
251
+ super.setBackgroundColor(overlayColor)
252
+ isSetup = true // Mark as setup to prevent retry loops
225
253
  }
226
-
227
- logDebug("Blur setup successful with root: ${root.javaClass.simpleName}")
228
254
  } ?: run {
229
255
  logWarning("No suitable root view found for blur setup")
256
+ // Use semi-transparent overlay when no root view is available
257
+ super.setBackgroundColor(overlayColor)
258
+ isSetup = true
230
259
  }
231
260
  } catch (e: Exception) {
232
- // Fallback: set transparent background to avoid yellow tint
233
- super.setBackgroundColor(Color.TRANSPARENT)
261
+ // Fallback: use semi-transparent overlay to avoid visual issues
262
+ super.setBackgroundColor(overlayColor)
234
263
  logError("Failed to setup blur: ${e.message}", e)
235
264
  }
236
265
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sbaiahmed1/react-native-blur",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React native modern blur view",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -38,7 +38,7 @@
38
38
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
39
39
  "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
40
40
  "prepare": "bob build",
41
- "release": "release-it --only-version"
41
+ "release": "release-it"
42
42
  },
43
43
  "keywords": [
44
44
  "react-native",