expo-blur 12.0.1 → 12.2.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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 12.2.0 — 2023-02-03
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Add `-webkit-backdrop-filter` to support blurring on Safari. ([#21003](https://github.com/expo/expo/pull/21003) by [@EvanBacon](https://github.com/EvanBacon))
18
+
19
+ ## 12.1.0 — 2022-12-30
20
+
21
+ ### 🎉 New features
22
+
23
+ - Migrated iOS codebase to Swift and the new Expo modules API. ([#19786](https://github.com/expo/expo/pull/19786) by [@tsapeta](https://github.com/tsapeta))
24
+
13
25
  ## 12.0.1 — 2022-11-02
14
26
 
15
27
  _This version does not introduce any user-facing changes._
package/README.md CHANGED
@@ -4,7 +4,7 @@ A component that renders a native blur view on iOS and falls back to a semi-tran
4
4
 
5
5
  # API documentation
6
6
 
7
- - [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/blur-view.md)
7
+ - [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/blur-view.mdx)
8
8
  - [Documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/blur-view/)
9
9
 
10
10
  # Installation in managed Expo projects
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
2
  import { View } from 'react-native';
3
+ /**
4
+ * A React component that blurs everything underneath the view.
5
+ */
3
6
  declare const BlurViewWithForwardedRef: React.ForwardRefExoticComponent<{
4
7
  tint?: import("./BlurView.types").BlurTint | undefined;
5
8
  intensity?: number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"BlurView.d.ts","sourceRoot":"","sources":["../src/BlurView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAA8B,MAAM,cAAc,CAAC;AAiFhE,QAAA,MAAM,wBAAwB;;;iEAE5B,CAAC;AAEH,eAAe,wBAAwB,CAAC"}
1
+ {"version":3,"file":"BlurView.d.ts","sourceRoot":"","sources":["../src/BlurView.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAA8B,MAAM,cAAc,CAAC;AAgFhE;;GAEG;AACH,QAAA,MAAM,wBAAwB;;;iEAI7B,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
package/build/BlurView.js CHANGED
@@ -1,4 +1,4 @@
1
- import { NativeModulesProxy, requireNativeViewManager } from 'expo-modules-core';
1
+ import { requireNativeModule, requireNativeViewManager } from 'expo-modules-core';
2
2
  import React from 'react';
3
3
  import { View, StyleSheet, findNodeHandle } from 'react-native';
4
4
  class BlurView extends React.Component {
@@ -22,11 +22,12 @@ class BlurView extends React.Component {
22
22
  const originalSetNativeProps = view.setNativeProps.bind(view);
23
23
  // Override `setNativeProps` (https://reactnative.dev/docs/animations#setnativeprops)
24
24
  view.setNativeProps = ({ tint, intensity, ...nativeProps }) => {
25
+ const ExpoBlurView = requireNativeModule('ExpoBlurView');
25
26
  // Call the original method with all View-based props
26
27
  view && originalSetNativeProps(nativeProps);
27
- // Invoke `setNativeProps` native expo method defined by `ExpoBlurViewManager`
28
+ // Invoke `setNativeProps` native expo method defined by `ExpoBlurView` module
28
29
  this.blurViewRef.current &&
29
- NativeModulesProxy.ExpoBlurViewManager.setNativeProps({ tint, intensity }, findNodeHandle(this.blurViewRef.current));
30
+ ExpoBlurView.setNativeProps({ tint, intensity }, findNodeHandle(this.blurViewRef.current));
30
31
  };
31
32
  // mimic `forwardedRef` logic
32
33
  if (typeof this.props.forwardedRef === 'function') {
@@ -49,6 +50,9 @@ const styles = StyleSheet.create({
49
50
  const NativeBlurView = requireNativeViewManager('ExpoBlurView');
50
51
  // This `forwardedRef` mechanism is necessary to make this component work properly
51
52
  // with React's `ref` prop and to react to props updates as expected.
53
+ /**
54
+ * A React component that blurs everything underneath the view.
55
+ */
52
56
  const BlurViewWithForwardedRef = React.forwardRef((props, forwardRef) => (React.createElement(BlurView, { ...props, forwardedRef: forwardRef })));
53
57
  export default BlurViewWithForwardedRef;
54
58
  //# sourceMappingURL=BlurView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlurView.js","sourceRoot":"","sources":["../src/BlurView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQhE,MAAM,QAAS,SAAQ,KAAK,CAAC,SAAmD;IACtE,WAAW,GAAG,KAAK,CAAC,SAAS,EAAQ,CAAC;IAE9C;;;;;;;;;;OAUG;IACK,WAAW,GAAG,CAAC,IAAiB,EAAE,EAAE;QAC1C,IAAI,CAAC,IAAI,EAAE;YACT,OAAO;SACR;QAED,wFAAwF;QACxF,MAAM,sBAAsB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9D,qFAAqF;QACrF,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,WAAW,EAAiB,EAAE,EAAE;YAC3E,qDAAqD;YACrD,IAAI,IAAI,sBAAsB,CAAC,WAAW,CAAC,CAAC;YAC5C,8EAA8E;YAC9E,IAAI,CAAC,WAAW,CAAC,OAAO;gBACtB,kBAAkB,CAAC,mBAAmB,CAAC,cAAc,CACnD,EAAE,IAAI,EAAE,SAAS,EAAE,EACnB,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CACzC,CAAC;QACN,CAAC,CAAC;QAEF,6BAA6B;QAC7B,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,KAAK,UAAU,EAAE;YACjD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SAC/B;aAAM,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;YAClC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;SACxC;IACH,CAAC,CAAC;IAEF,MAAM;QACJ,MAAM,EACJ,IAAI,GAAG,SAAS,EAChB,SAAS,GAAG,EAAE,EACd,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,GAAG,KAAK,EACT,GAAG,IAAI,CAAC,KAAK,CAAC;QACf,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC;YACtE,oBAAC,cAAc,IACb,GAAG,EAAE,IAAI,CAAC,WAAW,EACrB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,UAAU,CAAC,YAAY,GAC9B;YACD,QAAQ,CACJ,CACR,CAAC;IACJ,CAAC;CACF;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE;CAC9C,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,wBAAwB,CAAC,cAAc,CAAC,CAAC;AAEhE,kFAAkF;AAClF,qEAAqE;AACrE,MAAM,wBAAwB,GAAG,KAAK,CAAC,UAAU,CAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,CAAC,CAC5F,oBAAC,QAAQ,OAAK,KAAK,EAAE,YAAY,EAAE,UAAU,GAAI,CAClD,CAAC,CAAC;AAEH,eAAe,wBAAwB,CAAC","sourcesContent":["import { NativeModulesProxy, requireNativeViewManager } from 'expo-modules-core';\nimport React from 'react';\nimport { View, StyleSheet, findNodeHandle } from 'react-native';\n\nimport { BlurViewProps } from './BlurView.types';\n\ntype BlurViewForwardedRefProp = {\n forwardedRef: React.ForwardedRef<View>;\n};\n\nclass BlurView extends React.Component<BlurViewProps & BlurViewForwardedRefProp> {\n private blurViewRef = React.createRef<View>();\n\n /**\n * This component is a composition of the two components, but from the outside it's\n * just a simple View with additional properties. To properly handle `setNativeProps`\n * method (used when animating props), we need to properly separate `ViewProps` from `BlurViewProps`\n * and pass them to the proper underlying views.\n *\n * This method handles the native view reference obtained from the parent View component\n * and overrides it's original `setNativeProps` method that is available as it's property.\n * When the `NativeBlurView` native ref is available `BlurView`-only props are forwarded\n * to this view using `setNativeProps` method exposed by the native runtime.\n */\n private onRefChange = (view: View | null) => {\n if (!view) {\n return;\n }\n\n // Save the reference to the original method already bound to the proper calling context\n const originalSetNativeProps = view.setNativeProps.bind(view);\n\n // Override `setNativeProps` (https://reactnative.dev/docs/animations#setnativeprops)\n view.setNativeProps = ({ tint, intensity, ...nativeProps }: BlurViewProps) => {\n // Call the original method with all View-based props\n view && originalSetNativeProps(nativeProps);\n // Invoke `setNativeProps` native expo method defined by `ExpoBlurViewManager`\n this.blurViewRef.current &&\n NativeModulesProxy.ExpoBlurViewManager.setNativeProps(\n { tint, intensity },\n findNodeHandle(this.blurViewRef.current)\n );\n };\n\n // mimic `forwardedRef` logic\n if (typeof this.props.forwardedRef === 'function') {\n this.props.forwardedRef(view);\n } else if (this.props.forwardedRef) {\n this.props.forwardedRef.current = view;\n }\n };\n\n render() {\n const {\n tint = 'default',\n intensity = 50,\n style,\n children,\n forwardedRef,\n ...props\n } = this.props;\n return (\n <View {...props} ref={this.onRefChange} style={[styles.container, style]}>\n <NativeBlurView\n ref={this.blurViewRef}\n tint={tint}\n intensity={intensity}\n style={StyleSheet.absoluteFill}\n />\n {children}\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: { backgroundColor: 'transparent' },\n});\n\nconst NativeBlurView = requireNativeViewManager('ExpoBlurView');\n\n// This `forwardedRef` mechanism is necessary to make this component work properly\n// with React's `ref` prop and to react to props updates as expected.\nconst BlurViewWithForwardedRef = React.forwardRef<View, BlurViewProps>((props, forwardRef) => (\n <BlurView {...props} forwardedRef={forwardRef} />\n));\n\nexport default BlurViewWithForwardedRef;\n"]}
1
+ {"version":3,"file":"BlurView.js","sourceRoot":"","sources":["../src/BlurView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAQhE,MAAM,QAAS,SAAQ,KAAK,CAAC,SAAmD;IACtE,WAAW,GAAG,KAAK,CAAC,SAAS,EAAQ,CAAC;IAE9C;;;;;;;;;;OAUG;IACK,WAAW,GAAG,CAAC,IAAiB,EAAE,EAAE;QAC1C,IAAI,CAAC,IAAI,EAAE;YACT,OAAO;SACR;QAED,wFAAwF;QACxF,MAAM,sBAAsB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9D,qFAAqF;QACrF,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,WAAW,EAAiB,EAAE,EAAE;YAC3E,MAAM,YAAY,GAAG,mBAAmB,CAAC,cAAc,CAAC,CAAC;YAEzD,qDAAqD;YACrD,IAAI,IAAI,sBAAsB,CAAC,WAAW,CAAC,CAAC;YAC5C,8EAA8E;YAC9E,IAAI,CAAC,WAAW,CAAC,OAAO;gBACtB,YAAY,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,cAAc,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/F,CAAC,CAAC;QAEF,6BAA6B;QAC7B,IAAI,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,KAAK,UAAU,EAAE;YACjD,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;SAC/B;aAAM,IAAI,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE;YAClC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,OAAO,GAAG,IAAI,CAAC;SACxC;IACH,CAAC,CAAC;IAEF,MAAM;QACJ,MAAM,EACJ,IAAI,GAAG,SAAS,EAChB,SAAS,GAAG,EAAE,EACd,KAAK,EACL,QAAQ,EACR,YAAY,EACZ,GAAG,KAAK,EACT,GAAG,IAAI,CAAC,KAAK,CAAC;QACf,OAAO,CACL,oBAAC,IAAI,OAAK,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC;YACtE,oBAAC,cAAc,IACb,GAAG,EAAE,IAAI,CAAC,WAAW,EACrB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,UAAU,CAAC,YAAY,GAC9B;YACD,QAAQ,CACJ,CACR,CAAC;IACJ,CAAC;CACF;AAED,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE,EAAE,eAAe,EAAE,aAAa,EAAE;CAC9C,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,wBAAwB,CAAC,cAAc,CAAC,CAAC;AAEhE,kFAAkF;AAClF,qEAAqE;AACrE;;GAEG;AACH,MAAM,wBAAwB,GAAG,KAAK,CAAC,UAAU,CAC/C,CAAC,KAAoB,EAAE,UAAoC,EAAE,EAAE,CAAC,CAC9D,oBAAC,QAAQ,OAAK,KAAK,EAAE,YAAY,EAAE,UAAU,GAAI,CAClD,CACF,CAAC;AAEF,eAAe,wBAAwB,CAAC","sourcesContent":["import { requireNativeModule, requireNativeViewManager } from 'expo-modules-core';\nimport React from 'react';\nimport { View, StyleSheet, findNodeHandle } from 'react-native';\n\nimport { BlurViewProps } from './BlurView.types';\n\ntype BlurViewForwardedRefProp = {\n forwardedRef: React.ForwardedRef<View>;\n};\n\nclass BlurView extends React.Component<BlurViewProps & BlurViewForwardedRefProp> {\n private blurViewRef = React.createRef<View>();\n\n /**\n * This component is a composition of the two components, but from the outside it's\n * just a simple View with additional properties. To properly handle `setNativeProps`\n * method (used when animating props), we need to properly separate `ViewProps` from `BlurViewProps`\n * and pass them to the proper underlying views.\n *\n * This method handles the native view reference obtained from the parent View component\n * and overrides it's original `setNativeProps` method that is available as it's property.\n * When the `NativeBlurView` native ref is available `BlurView`-only props are forwarded\n * to this view using `setNativeProps` method exposed by the native runtime.\n */\n private onRefChange = (view: View | null) => {\n if (!view) {\n return;\n }\n\n // Save the reference to the original method already bound to the proper calling context\n const originalSetNativeProps = view.setNativeProps.bind(view);\n\n // Override `setNativeProps` (https://reactnative.dev/docs/animations#setnativeprops)\n view.setNativeProps = ({ tint, intensity, ...nativeProps }: BlurViewProps) => {\n const ExpoBlurView = requireNativeModule('ExpoBlurView');\n\n // Call the original method with all View-based props\n view && originalSetNativeProps(nativeProps);\n // Invoke `setNativeProps` native expo method defined by `ExpoBlurView` module\n this.blurViewRef.current &&\n ExpoBlurView.setNativeProps({ tint, intensity }, findNodeHandle(this.blurViewRef.current));\n };\n\n // mimic `forwardedRef` logic\n if (typeof this.props.forwardedRef === 'function') {\n this.props.forwardedRef(view);\n } else if (this.props.forwardedRef) {\n this.props.forwardedRef.current = view;\n }\n };\n\n render() {\n const {\n tint = 'default',\n intensity = 50,\n style,\n children,\n forwardedRef,\n ...props\n } = this.props;\n return (\n <View {...props} ref={this.onRefChange} style={[styles.container, style]}>\n <NativeBlurView\n ref={this.blurViewRef}\n tint={tint}\n intensity={intensity}\n style={StyleSheet.absoluteFill}\n />\n {children}\n </View>\n );\n }\n}\n\nconst styles = StyleSheet.create({\n container: { backgroundColor: 'transparent' },\n});\n\nconst NativeBlurView = requireNativeViewManager('ExpoBlurView');\n\n// This `forwardedRef` mechanism is necessary to make this component work properly\n// with React's `ref` prop and to react to props updates as expected.\n/**\n * A React component that blurs everything underneath the view.\n */\nconst BlurViewWithForwardedRef = React.forwardRef<View, BlurViewProps>(\n (props: BlurViewProps, forwardRef: React.ForwardedRef<View>) => (\n <BlurView {...props} forwardedRef={forwardRef} />\n )\n);\n\nexport default BlurViewWithForwardedRef;\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ViewProps } from 'react-native';
2
- export declare type BlurViewProps = {
2
+ export type BlurViewProps = {
3
3
  /**
4
4
  * A tint mode which will be applied to the view.
5
5
  * @default 'default'
@@ -15,5 +15,5 @@ export declare type BlurViewProps = {
15
15
  */
16
16
  intensity?: number;
17
17
  } & ViewProps;
18
- export declare type BlurTint = 'light' | 'dark' | 'default';
18
+ export type BlurTint = 'light' | 'dark' | 'default';
19
19
  //# sourceMappingURL=BlurView.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BlurView.types.d.ts","sourceRoot":"","sources":["../src/BlurView.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,oBAAY,aAAa,GAAG;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,SAAS,CAAC;AAEd,oBAAY,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC"}
1
+ {"version":3,"file":"BlurView.types.d.ts","sourceRoot":"","sources":["../src/BlurView.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,SAAS,CAAC;AAEd,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC"}
@@ -20,7 +20,10 @@ function getBlurStyle({ intensity, tint }) {
20
20
  backgroundColor: getBackgroundColor(intensity, tint),
21
21
  };
22
22
  if (isBlurSupported()) {
23
- style.backdropFilter = `saturate(180%) blur(${intensity * 0.2}px)`;
23
+ const blur = `saturate(180%) blur(${intensity * 0.2}px)`;
24
+ style.backdropFilter = blur;
25
+ // Safari support
26
+ style['-webkit-backdrop-filter'] = blur;
24
27
  }
25
28
  return style;
26
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BlurView.web.js","sourceRoot":"","sources":["../src/BlurView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,KAAK,CAAC,SAAwB;IAClE,MAAM;QACJ,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACzE,MAAM,SAAS,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9E,OAAO,oBAAC,IAAI,OAAK,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,GAAI,CAAC;IACxD,CAAC;CACF;AAED,SAAS,eAAe;IACtB,gEAAgE;IAChE,yFAAyF;IACzF,OAAO,CACL,OAAO,GAAG,KAAK,WAAW;QAC1B,CAAC,GAAG,CAAC,QAAQ,CAAC,yBAAyB,EAAE,WAAW,CAAC;YACnD,GAAG,CAAC,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAChD,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE;IACvC,MAAM,KAAK,GAA2B;QACpC,eAAe,EAAE,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC;KACrD,CAAC;IAEF,IAAI,eAAe,EAAE,EAAE;QACrB,KAAK,CAAC,cAAc,GAAG,uBAAuB,SAAS,GAAG,GAAG,KAAK,CAAC;KACpE;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\n\nimport { BlurViewProps } from './BlurView.types';\nimport getBackgroundColor from './getBackgroundColor';\n\nexport default class BlurView extends React.Component<BlurViewProps> {\n render() {\n const { tint = 'default', intensity = 50, style, ...props } = this.props;\n const blurStyle = getBlurStyle({ tint, intensity: Math.min(intensity, 100) });\n return <View {...props} style={[style, blurStyle]} />;\n }\n}\n\nfunction isBlurSupported(): boolean {\n // https://developer.mozilla.org/en-US/docs/Web/API/CSS/supports\n // https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility\n return (\n typeof CSS !== 'undefined' &&\n (CSS.supports('-webkit-backdrop-filter', 'blur(1px)') ||\n CSS.supports('backdrop-filter', 'blur(1px)'))\n );\n}\n\nfunction getBlurStyle({ intensity, tint }): Record<string, string> {\n const style: Record<string, string> = {\n backgroundColor: getBackgroundColor(intensity, tint),\n };\n\n if (isBlurSupported()) {\n style.backdropFilter = `saturate(180%) blur(${intensity * 0.2}px)`;\n }\n\n return style;\n}\n"]}
1
+ {"version":3,"file":"BlurView.web.js","sourceRoot":"","sources":["../src/BlurView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGpC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,KAAK,CAAC,SAAwB;IAClE,MAAM;QACJ,MAAM,EAAE,IAAI,GAAG,SAAS,EAAE,SAAS,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACzE,MAAM,SAAS,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;QAC9E,OAAO,oBAAC,IAAI,OAAK,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,GAAI,CAAC;IACxD,CAAC;CACF;AAED,SAAS,eAAe;IACtB,gEAAgE;IAChE,yFAAyF;IACzF,OAAO,CACL,OAAO,GAAG,KAAK,WAAW;QAC1B,CAAC,GAAG,CAAC,QAAQ,CAAC,yBAAyB,EAAE,WAAW,CAAC;YACnD,GAAG,CAAC,QAAQ,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC,CAChD,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE;IACvC,MAAM,KAAK,GAA2B;QACpC,eAAe,EAAE,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC;KACrD,CAAC;IAEF,IAAI,eAAe,EAAE,EAAE;QACrB,MAAM,IAAI,GAAG,uBAAuB,SAAS,GAAG,GAAG,KAAK,CAAC;QACzD,KAAK,CAAC,cAAc,GAAG,IAAI,CAAC;QAC5B,iBAAiB;QACjB,KAAK,CAAC,yBAAyB,CAAC,GAAG,IAAI,CAAC;KACzC;IAED,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import * as React from 'react';\nimport { View } from 'react-native';\n\nimport { BlurViewProps } from './BlurView.types';\nimport getBackgroundColor from './getBackgroundColor';\n\nexport default class BlurView extends React.Component<BlurViewProps> {\n render() {\n const { tint = 'default', intensity = 50, style, ...props } = this.props;\n const blurStyle = getBlurStyle({ tint, intensity: Math.min(intensity, 100) });\n return <View {...props} style={[style, blurStyle]} />;\n }\n}\n\nfunction isBlurSupported(): boolean {\n // https://developer.mozilla.org/en-US/docs/Web/API/CSS/supports\n // https://developer.mozilla.org/en-US/docs/Web/CSS/backdrop-filter#Browser_compatibility\n return (\n typeof CSS !== 'undefined' &&\n (CSS.supports('-webkit-backdrop-filter', 'blur(1px)') ||\n CSS.supports('backdrop-filter', 'blur(1px)'))\n );\n}\n\nfunction getBlurStyle({ intensity, tint }): Record<string, string> {\n const style: Record<string, string> = {\n backgroundColor: getBackgroundColor(intensity, tint),\n };\n\n if (isBlurSupported()) {\n const blur = `saturate(180%) blur(${intensity * 0.2}px)`;\n style.backdropFilter = blur;\n // Safari support\n style['-webkit-backdrop-filter'] = blur;\n }\n\n return style;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "expo-blur",
3
+ "platforms": ["ios"],
4
+ "ios": {
5
+ "modules": ["BlurViewModule"]
6
+ }
7
+ }
@@ -1,15 +1,12 @@
1
1
  // Copyright 2015-present 650 Industries. All rights reserved.
2
2
 
3
- import UIKit
4
- import React
3
+ import ExpoModulesCore
5
4
 
6
- @objc(EXBlurView)
7
- public class BlurView: RCTView {
8
- private var blurEffectView: BlurEffectView
5
+ public final class BlurView: ExpoView {
6
+ private let blurEffectView = BlurEffectView()
9
7
 
10
- override init(frame: CGRect) {
11
- blurEffectView = BlurEffectView()
12
- super.init(frame: frame)
8
+ public required init(appContext: AppContext? = nil) {
9
+ super.init(appContext: appContext)
13
10
 
14
11
  blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
15
12
  clipsToBounds = true
@@ -17,14 +14,10 @@ public class BlurView: RCTView {
17
14
  addSubview(blurEffectView)
18
15
  }
19
16
 
20
- required init?(coder: NSCoder) { nil }
21
-
22
- @objc
23
17
  public func setTint(_ tint: String) {
24
18
  blurEffectView.tint = tint
25
19
  }
26
20
 
27
- @objc
28
21
  public func setIntensity(_ intensity: Double) {
29
22
  blurEffectView.intensity = intensity
30
23
  }
@@ -0,0 +1,32 @@
1
+ // Copyright 2022-present 650 Industries. All rights reserved.
2
+
3
+ import ExpoModulesCore
4
+
5
+ public final class BlurViewModule: Module {
6
+ public func definition() -> ModuleDefinition {
7
+ Name("ExpoBlurView")
8
+
9
+ View(BlurView.self) {
10
+ Prop("tint") { (view, tint: String) in
11
+ view.setTint(tint)
12
+ }
13
+
14
+ Prop("intensity") { (view, intensity: Double) in
15
+ view.setIntensity(intensity / 100)
16
+ }
17
+ }
18
+
19
+ AsyncFunction("setNativeProps") { (props: [String: Any], viewTag: Int) in
20
+ guard let view = appContext?.findView(withTag: viewTag, ofType: BlurView.self) else {
21
+ throw Exceptions.ViewNotFound((tag: viewTag, type: BlurView.self))
22
+ }
23
+ if let tint = props["tint"] as? String {
24
+ view.setTint(tint)
25
+ }
26
+ if let intensity = props["intensity"] as? Double {
27
+ view.setIntensity(intensity / 100)
28
+ }
29
+ }
30
+ .runOnQueue(.main)
31
+ }
32
+ }
@@ -3,7 +3,7 @@ require 'json'
3
3
  package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
4
 
5
5
  Pod::Spec.new do |s|
6
- s.name = 'EXBlur'
6
+ s.name = 'ExpoBlur'
7
7
  s.version = package['version']
8
8
  s.summary = package['description']
9
9
  s.description = package['description']
@@ -17,9 +17,9 @@ Pod::Spec.new do |s|
17
17
  s.dependency 'ExpoModulesCore'
18
18
 
19
19
  if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
20
- s.source_files = "#{s.name}/**/*.h"
20
+ s.source_files = "**/*.h"
21
21
  s.vendored_frameworks = "#{s.name}.xcframework"
22
22
  else
23
- s.source_files = "#{s.name}/**/*.{h,m,swift}"
23
+ s.source_files = "**/*.{h,m,swift}"
24
24
  end
25
25
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-blur",
3
- "version": "12.0.1",
3
+ "version": "12.2.0",
4
4
  "description": "A component that renders a native blur view on iOS and falls back to a semi-transparent view on Android. A common usage of this is for navigation bars, tab bars, and modals.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -43,5 +43,5 @@
43
43
  "peerDependencies": {
44
44
  "expo": "*"
45
45
  },
46
- "gitHead": "1a87dcc55895a9e16e3d4fd0fa78f2244c1d961f"
46
+ "gitHead": "1815e2eaad8c753588c7b1eb74420174a28e01f4"
47
47
  }
package/src/BlurView.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { NativeModulesProxy, requireNativeViewManager } from 'expo-modules-core';
1
+ import { requireNativeModule, requireNativeViewManager } from 'expo-modules-core';
2
2
  import React from 'react';
3
3
  import { View, StyleSheet, findNodeHandle } from 'react-native';
4
4
 
@@ -32,14 +32,13 @@ class BlurView extends React.Component<BlurViewProps & BlurViewForwardedRefProp>
32
32
 
33
33
  // Override `setNativeProps` (https://reactnative.dev/docs/animations#setnativeprops)
34
34
  view.setNativeProps = ({ tint, intensity, ...nativeProps }: BlurViewProps) => {
35
+ const ExpoBlurView = requireNativeModule('ExpoBlurView');
36
+
35
37
  // Call the original method with all View-based props
36
38
  view && originalSetNativeProps(nativeProps);
37
- // Invoke `setNativeProps` native expo method defined by `ExpoBlurViewManager`
39
+ // Invoke `setNativeProps` native expo method defined by `ExpoBlurView` module
38
40
  this.blurViewRef.current &&
39
- NativeModulesProxy.ExpoBlurViewManager.setNativeProps(
40
- { tint, intensity },
41
- findNodeHandle(this.blurViewRef.current)
42
- );
41
+ ExpoBlurView.setNativeProps({ tint, intensity }, findNodeHandle(this.blurViewRef.current));
43
42
  };
44
43
 
45
44
  // mimic `forwardedRef` logic
@@ -81,8 +80,13 @@ const NativeBlurView = requireNativeViewManager('ExpoBlurView');
81
80
 
82
81
  // This `forwardedRef` mechanism is necessary to make this component work properly
83
82
  // with React's `ref` prop and to react to props updates as expected.
84
- const BlurViewWithForwardedRef = React.forwardRef<View, BlurViewProps>((props, forwardRef) => (
85
- <BlurView {...props} forwardedRef={forwardRef} />
86
- ));
83
+ /**
84
+ * A React component that blurs everything underneath the view.
85
+ */
86
+ const BlurViewWithForwardedRef = React.forwardRef<View, BlurViewProps>(
87
+ (props: BlurViewProps, forwardRef: React.ForwardedRef<View>) => (
88
+ <BlurView {...props} forwardedRef={forwardRef} />
89
+ )
90
+ );
87
91
 
88
92
  export default BlurViewWithForwardedRef;
@@ -28,7 +28,10 @@ function getBlurStyle({ intensity, tint }): Record<string, string> {
28
28
  };
29
29
 
30
30
  if (isBlurSupported()) {
31
- style.backdropFilter = `saturate(180%) blur(${intensity * 0.2}px)`;
31
+ const blur = `saturate(180%) blur(${intensity * 0.2}px)`;
32
+ style.backdropFilter = blur;
33
+ // Safari support
34
+ style['-webkit-backdrop-filter'] = blur;
32
35
  }
33
36
 
34
37
  return style;
@@ -1,8 +0,0 @@
1
- // Copyright 2016-present 650 Industries. All rights reserved.
2
-
3
- #import <ExpoModulesCore/EXViewManager.h>
4
- #import <ExpoModulesCore/EXModuleRegistryConsumer.h>
5
-
6
- @interface EXBlurViewManager : EXViewManager <EXModuleRegistryConsumer>
7
-
8
- @end
@@ -1,63 +0,0 @@
1
- // Copyright 2016-present 650 Industries. All rights reserved.
2
-
3
- #import <EXBlur/EXBlurViewManager.h>
4
- #import <ExpoModulesCore/EXUIManager.h>
5
-
6
- #if __has_include(<EXBlur/EXBlur-Swift.h>)
7
- #import <EXBlur/EXBlur-Swift.h>
8
- #else
9
- #import "EXBlur-Swift.h"
10
- #endif
11
-
12
- @interface EXBlurViewManager ()
13
-
14
- @property (weak, nonatomic) EXModuleRegistry *moduleRegistry;
15
-
16
- @end
17
-
18
- @implementation EXBlurViewManager
19
-
20
- EX_EXPORT_MODULE(ExpoBlurViewManager);
21
-
22
- - (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry {
23
- _moduleRegistry = moduleRegistry;
24
- }
25
-
26
- - (UIView *)view
27
- {
28
- return [EXBlurView new];
29
- }
30
-
31
- - (NSString *)viewName
32
- {
33
- return @"ExpoBlurView";
34
- }
35
-
36
- EX_VIEW_PROPERTY(tint, NSString *, EXBlurView)
37
- {
38
- [view setTint:value];
39
- }
40
-
41
- EX_VIEW_PROPERTY(intensity, NSNumber *, EXBlurView)
42
- {
43
- [view setIntensity:[value doubleValue] / 100];
44
- }
45
-
46
- EX_EXPORT_METHOD_AS(setNativeProps,
47
- setNativeProps:(NSDictionary *)nativeProps
48
- forViewWithTag:(id)viewTag
49
- resolver:(EXPromiseResolveBlock)resolve
50
- rejecter:(EXPromiseRejectBlock)reject)
51
- {
52
- [[_moduleRegistry getModuleImplementingProtocol:@protocol(EXUIManager)] executeUIBlock:^(id view) {
53
- if ([view isKindOfClass:[EXBlurView class]]) {
54
- EXBlurView *blurView = view;
55
- if (nativeProps[@"intensity"]) { [blurView setIntensity:[nativeProps[@"intensity"] floatValue] / 100]; }
56
- if (nativeProps[@"tint"]) { [blurView setTint:nativeProps[@"tint"]]; }
57
- } else {
58
- reject(@"E_INVALID_VIEW", [NSString stringWithFormat:@"Invalid view returned from registry, expected EXBlurView, got: %@", view], nil);
59
- }
60
- } forView:viewTag ofClass:[EXBlurView class]];
61
- }
62
-
63
- @end
package/unimodule.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "name": "expo-blur",
3
- "platforms": ["ios"]
4
- }