@sbaiahmed1/react-native-blur 0.2.1 → 0.3.0

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 (31) hide show
  1. package/README.md +345 -106
  2. package/ReactNativeBlur.podspec +2 -1
  3. package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerDelegate.java +18 -3
  4. package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeBlurViewManagerInterface.java +6 -1
  5. package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassEffectContainerManagerDelegate.java +53 -0
  6. package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/ReactNativeGlassEffectContainerManagerInterface.java +25 -0
  7. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.cpp +1 -1
  8. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ComponentDescriptors.h +1 -1
  9. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/EventEmitters.h +1 -1
  10. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.cpp +17 -7
  11. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/Props.h +55 -15
  12. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.cpp +1 -1
  13. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/ShadowNodes.h +7 -7
  14. package/android/app/build/generated/source/codegen/jni/react/renderer/components/ReactNativeBlurViewSpec/States.h +3 -3
  15. package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurView.kt +150 -46
  16. package/android/src/main/java/com/sbaiahmed1/reactnativeblur/ReactNativeBlurViewManager.kt +25 -0
  17. package/ios/ReactNativeBlurView.mm +197 -237
  18. package/ios/ReactNativeBlurView.swift +321 -0
  19. package/ios/ReactNativeBlurViewManager.h +5 -0
  20. package/ios/ReactNativeBlurViewManager.m +171 -0
  21. package/lib/module/BlurView.js +17 -2
  22. package/lib/module/BlurView.js.map +1 -1
  23. package/lib/module/ReactNativeBlurViewNativeComponent.ts +10 -3
  24. package/lib/typescript/src/BlurView.d.ts +36 -1
  25. package/lib/typescript/src/BlurView.d.ts.map +1 -1
  26. package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts +9 -3
  27. package/lib/typescript/src/ReactNativeBlurViewNativeComponent.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/src/BlurView.tsx +58 -3
  30. package/src/ReactNativeBlurViewNativeComponent.ts +10 -3
  31. package/ios/ReactNativeBlurViewManager.mm +0 -23
@@ -22,14 +22,29 @@ 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 "blurType":
26
- mViewManager.setBlurType(view, (String) value);
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());
27
30
  break;
28
31
  case "blurAmount":
29
32
  mViewManager.setBlurAmount(view, value == null ? 10f : ((Double) value).doubleValue());
30
33
  break;
34
+ case "type":
35
+ mViewManager.setType(view, (String) value);
36
+ break;
37
+ case "blurType":
38
+ mViewManager.setBlurType(view, (String) value);
39
+ break;
40
+ case "glassType":
41
+ mViewManager.setGlassType(view, (String) value);
42
+ break;
31
43
  case "reducedTransparencyFallbackColor":
32
- mViewManager.setReducedTransparencyFallbackColor(view, value == null ? null : (String) value);
44
+ mViewManager.setReducedTransparencyFallbackColor(view, value == null ? "#FFFFFF" : (String) value);
45
+ break;
46
+ case "isInteractive":
47
+ mViewManager.setIsInteractive(view, value == null ? true : (boolean) value);
33
48
  break;
34
49
  default:
35
50
  super.setProperty(view, propName, value);
@@ -14,7 +14,12 @@ 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 setBlurType(T view, @Nullable String value);
17
+ void setGlassTintColor(T view, @Nullable String value);
18
+ void setGlassOpacity(T view, double value);
18
19
  void setBlurAmount(T view, double value);
20
+ void setType(T view, @Nullable String value);
21
+ void setBlurType(T view, @Nullable String value);
22
+ void setGlassType(T view, @Nullable String value);
19
23
  void setReducedTransparencyFallbackColor(T view, @Nullable String value);
24
+ void setIsInteractive(T view, boolean value);
20
25
  }
@@ -0,0 +1,53 @@
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
+ }
@@ -0,0 +1,25 @@
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
+ }
@@ -17,7 +17,7 @@ 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<ReactNativeGlassViewComponentDescriptor>());
20
+ registry->add(concreteComponentDescriptorProvider<ReactNativeGlassEffectContainerComponentDescriptor>());
21
21
  }
22
22
 
23
23
  } // namespace facebook::react
@@ -17,7 +17,7 @@
17
17
  namespace facebook::react {
18
18
 
19
19
  using ReactNativeBlurViewComponentDescriptor = ConcreteComponentDescriptor<ReactNativeBlurViewShadowNode>;
20
- using ReactNativeGlassViewComponentDescriptor = ConcreteComponentDescriptor<ReactNativeGlassViewShadowNode>;
20
+ using ReactNativeGlassEffectContainerComponentDescriptor = ConcreteComponentDescriptor<ReactNativeGlassEffectContainerShadowNode>;
21
21
 
22
22
  void ReactNativeBlurViewSpec_registerComponentDescriptorsFromCodegen(
23
23
  std::shared_ptr<const ComponentDescriptorProviderRegistry> registry);
@@ -20,7 +20,7 @@ class ReactNativeBlurViewEventEmitter : public ViewEventEmitter {
20
20
 
21
21
 
22
22
  };
23
- class ReactNativeGlassViewEventEmitter : public ViewEventEmitter {
23
+ class ReactNativeGlassEffectContainerEventEmitter : public ViewEventEmitter {
24
24
  public:
25
25
  using ViewEventEmitter::ViewEventEmitter;
26
26
 
@@ -19,18 +19,28 @@ ReactNativeBlurViewProps::ReactNativeBlurViewProps(
19
19
  const ReactNativeBlurViewProps &sourceProps,
20
20
  const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
21
21
 
22
- blurType(convertRawProp(context, rawProps, "blurType", sourceProps.blurType, {ReactNativeBlurViewBlurType::Light})),
22
+ glassTintColor(convertRawProp(context, rawProps, "glassTintColor", sourceProps.glassTintColor, {"clear"})),
23
+ glassOpacity(convertRawProp(context, rawProps, "glassOpacity", sourceProps.glassOpacity, {1.0})),
23
24
  blurAmount(convertRawProp(context, rawProps, "blurAmount", sourceProps.blurAmount, {10.0})),
24
- reducedTransparencyFallbackColor(convertRawProp(context, rawProps, "reducedTransparencyFallbackColor", sourceProps.reducedTransparencyFallbackColor, {}))
25
+ type(convertRawProp(context, rawProps, "type", sourceProps.type, {ReactNativeBlurViewType::Blur})),
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}))
25
30
  {}
26
- ReactNativeGlassViewProps::ReactNativeGlassViewProps(
31
+ ReactNativeGlassEffectContainerProps::ReactNativeGlassEffectContainerProps(
27
32
  const PropsParserContext &context,
28
- const ReactNativeGlassViewProps &sourceProps,
33
+ const ReactNativeGlassEffectContainerProps &sourceProps,
29
34
  const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
30
35
 
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, {}))
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"}))
34
44
  {}
35
45
 
36
46
  } // namespace facebook::react
@@ -14,6 +14,21 @@
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
+ }
17
32
  enum class ReactNativeBlurViewBlurType { Xlight, Light, Dark, ExtraDark, Regular, Prominent, SystemUltraThinMaterial, SystemThinMaterial, SystemMaterial, SystemThickMaterial, SystemChromeMaterial };
18
33
 
19
34
  static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNativeBlurViewBlurType &result) {
@@ -47,6 +62,21 @@ static inline std::string toString(const ReactNativeBlurViewBlurType &value) {
47
62
  case ReactNativeBlurViewBlurType::SystemChromeMaterial: return "systemChromeMaterial";
48
63
  }
49
64
  }
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
+ }
50
80
 
51
81
  class ReactNativeBlurViewProps final : public ViewProps {
52
82
  public:
@@ -55,37 +85,47 @@ class ReactNativeBlurViewProps final : public ViewProps {
55
85
 
56
86
  #pragma mark - Props
57
87
 
58
- ReactNativeBlurViewBlurType blurType{ReactNativeBlurViewBlurType::Light};
88
+ std::string glassTintColor{"clear"};
89
+ double glassOpacity{1.0};
59
90
  double blurAmount{10.0};
60
- std::string reducedTransparencyFallbackColor{};
91
+ ReactNativeBlurViewType type{ReactNativeBlurViewType::Blur};
92
+ ReactNativeBlurViewBlurType blurType{ReactNativeBlurViewBlurType::Xlight};
93
+ ReactNativeBlurViewGlassType glassType{ReactNativeBlurViewGlassType::Clear};
94
+ std::string reducedTransparencyFallbackColor{"#FFFFFF"};
95
+ bool isInteractive{true};
61
96
  };
62
97
 
63
- enum class ReactNativeGlassViewGlassType { Clear, Default };
98
+ enum class ReactNativeGlassEffectContainerGlassType { Clear, Regular };
64
99
 
65
- static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNativeGlassViewGlassType &result) {
100
+ static inline void fromRawValue(const PropsParserContext& context, const RawValue &value, ReactNativeGlassEffectContainerGlassType &result) {
66
101
  auto string = (std::string)value;
67
- if (string == "clear") { result = ReactNativeGlassViewGlassType::Clear; return; }
68
- if (string == "default") { result = ReactNativeGlassViewGlassType::Default; return; }
102
+ if (string == "clear") { result = ReactNativeGlassEffectContainerGlassType::Clear; return; }
103
+ if (string == "regular") { result = ReactNativeGlassEffectContainerGlassType::Regular; return; }
69
104
  abort();
70
105
  }
71
106
 
72
- static inline std::string toString(const ReactNativeGlassViewGlassType &value) {
107
+ static inline std::string toString(const ReactNativeGlassEffectContainerGlassType &value) {
73
108
  switch (value) {
74
- case ReactNativeGlassViewGlassType::Clear: return "clear";
75
- case ReactNativeGlassViewGlassType::Default: return "default";
109
+ case ReactNativeGlassEffectContainerGlassType::Clear: return "clear";
110
+ case ReactNativeGlassEffectContainerGlassType::Regular: return "regular";
76
111
  }
77
112
  }
78
113
 
79
- class ReactNativeGlassViewProps final : public ViewProps {
114
+ class ReactNativeGlassEffectContainerProps final : public ViewProps {
80
115
  public:
81
- ReactNativeGlassViewProps() = default;
82
- ReactNativeGlassViewProps(const PropsParserContext& context, const ReactNativeGlassViewProps &sourceProps, const RawProps &rawProps);
116
+ ReactNativeGlassEffectContainerProps() = default;
117
+ ReactNativeGlassEffectContainerProps(const PropsParserContext& context, const ReactNativeGlassEffectContainerProps &sourceProps, const RawProps &rawProps);
83
118
 
84
119
  #pragma mark - Props
85
120
 
86
- ReactNativeGlassViewGlassType glassType{ReactNativeGlassViewGlassType::Default};
87
- double glassAmount{50.0};
88
- std::string reducedTransparencyFallbackColor{};
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"};
89
129
  };
90
130
 
91
131
  } // namespace facebook::react
@@ -13,6 +13,6 @@
13
13
  namespace facebook::react {
14
14
 
15
15
  extern const char ReactNativeBlurViewComponentName[] = "ReactNativeBlurView";
16
- extern const char ReactNativeGlassViewComponentName[] = "ReactNativeGlassView";
16
+ extern const char ReactNativeGlassEffectContainerComponentName[] = "ReactNativeGlassEffectContainer";
17
17
 
18
18
  } // namespace facebook::react
@@ -29,15 +29,15 @@ using ReactNativeBlurViewShadowNode = ConcreteViewShadowNode<
29
29
  ReactNativeBlurViewEventEmitter,
30
30
  ReactNativeBlurViewState>;
31
31
 
32
- JSI_EXPORT extern const char ReactNativeGlassViewComponentName[];
32
+ JSI_EXPORT extern const char ReactNativeGlassEffectContainerComponentName[];
33
33
 
34
34
  /*
35
- * `ShadowNode` for <ReactNativeGlassView> component.
35
+ * `ShadowNode` for <ReactNativeGlassEffectContainer> component.
36
36
  */
37
- using ReactNativeGlassViewShadowNode = ConcreteViewShadowNode<
38
- ReactNativeGlassViewComponentName,
39
- ReactNativeGlassViewProps,
40
- ReactNativeGlassViewEventEmitter,
41
- ReactNativeGlassViewState>;
37
+ using ReactNativeGlassEffectContainerShadowNode = ConcreteViewShadowNode<
38
+ ReactNativeGlassEffectContainerComponentName,
39
+ ReactNativeGlassEffectContainerProps,
40
+ ReactNativeGlassEffectContainerEventEmitter,
41
+ ReactNativeGlassEffectContainerState>;
42
42
 
43
43
  } // namespace facebook::react
@@ -26,12 +26,12 @@ public:
26
26
  #endif
27
27
  };
28
28
 
29
- class ReactNativeGlassViewState {
29
+ class ReactNativeGlassEffectContainerState {
30
30
  public:
31
- ReactNativeGlassViewState() = default;
31
+ ReactNativeGlassEffectContainerState() = default;
32
32
 
33
33
  #ifdef ANDROID
34
- ReactNativeGlassViewState(ReactNativeGlassViewState const &previousState, folly::dynamic data){};
34
+ ReactNativeGlassEffectContainerState(ReactNativeGlassEffectContainerState const &previousState, folly::dynamic data){};
35
35
  folly::dynamic getDynamic() const {
36
36
  return {};
37
37
  };