expo-blur 10.0.3 → 11.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 +16 -3
- package/README.md +4 -4
- package/build/BlurView.android.d.ts +3 -3
- package/build/BlurView.android.d.ts.map +1 -0
- package/build/BlurView.android.js +2 -3
- package/build/BlurView.android.js.map +1 -1
- package/build/BlurView.d.ts +8 -12
- package/build/BlurView.d.ts.map +1 -0
- package/build/BlurView.js +45 -17
- package/build/BlurView.js.map +1 -1
- package/build/BlurView.types.d.ts +11 -7
- package/build/BlurView.types.d.ts.map +1 -0
- package/build/BlurView.types.js.map +1 -1
- package/build/BlurView.web.d.ts +3 -3
- package/build/BlurView.web.d.ts.map +1 -0
- package/build/BlurView.web.js +1 -2
- package/build/BlurView.web.js.map +1 -1
- package/build/getBackgroundColor.d.ts +1 -0
- package/build/getBackgroundColor.d.ts.map +1 -0
- package/build/index.d.ts +2 -1
- package/build/index.d.ts.map +1 -0
- package/build/index.js.map +1 -1
- package/ios/EXBlur/BlurEffectView.swift +83 -0
- package/ios/EXBlur/BlurView.swift +31 -0
- package/ios/EXBlur/EXBlurViewManager.m +17 -23
- package/ios/EXBlur.podspec +1 -1
- package/package.json +6 -5
- package/src/BlurView.android.tsx +3 -5
- package/src/BlurView.tsx +65 -18
- package/src/BlurView.types.ts +10 -12
- package/src/BlurView.web.tsx +2 -4
- package/src/index.ts +1 -1
- package/tsconfig.json +1 -1
- package/yarn-error.log +20691 -0
- package/ios/EXBlur/EXBlurView.h +0 -14
- package/ios/EXBlur/EXBlurView.m +0 -57
package/CHANGELOG.md
CHANGED
|
@@ -10,13 +10,26 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## 11.2.0 — 2022-07-07
|
|
14
14
|
|
|
15
15
|
_This version does not introduce any user-facing changes._
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## 11.1.0 — 2022-04-18
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
### 🐛 Bug fixes
|
|
20
|
+
|
|
21
|
+
- Fixed the component not rendering correctly when the border radius style is set. ([#16671](https://github.com/expo/expo/pull/16671) by [@tsapeta](https://github.com/tsapeta))
|
|
22
|
+
|
|
23
|
+
## 11.0.0 — 2021-12-03
|
|
24
|
+
|
|
25
|
+
### 🛠 Breaking changes
|
|
26
|
+
|
|
27
|
+
- On iOS replaced non-working `alpha`-based blur mechanism with a new one basing on `UIViewPropertyAnimator`. ([#14946](https://github.com/expo/expo/pull/14946) by [@bbarthec](https://github.com/bbarthec))
|
|
28
|
+
- Renamed `BlurProps` to `BlurViewProps` to align with React Native's types naming convention. ([#14946](https://github.com/expo/expo/pull/14946) by [@bbarthec](https://github.com/bbarthec))
|
|
29
|
+
|
|
30
|
+
### 🐛 Bug fixes
|
|
31
|
+
|
|
32
|
+
- On iOS fixed `intensity` property not blurring text content properly. ([#14946](https://github.com/expo/expo/pull/14946) by [@bbarthec](https://github.com/bbarthec))
|
|
20
33
|
|
|
21
34
|
## 10.0.1 — 2021-10-01
|
|
22
35
|
|
package/README.md
CHANGED
|
@@ -4,16 +4,16 @@ 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
|
|
8
|
-
- [Documentation for the latest stable release](https://docs.expo.
|
|
7
|
+
- [Documentation for the main branch](https://github.com/expo/expo/blob/main/docs/pages/versions/unversioned/sdk/blur-view.md)
|
|
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
|
|
11
11
|
|
|
12
|
-
For
|
|
12
|
+
For [managed](https://docs.expo.dev/versions/latest/introduction/managed-vs-bare/) Expo projects, please follow the installation instructions in the [API documentation for the latest stable release](https://docs.expo.dev/versions/latest/sdk/blur-view/).
|
|
13
13
|
|
|
14
14
|
# Installation in bare React Native projects
|
|
15
15
|
|
|
16
|
-
For bare React Native projects, you must ensure that you have [installed and configured the `
|
|
16
|
+
For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing.
|
|
17
17
|
|
|
18
18
|
### Add the package to your npm dependencies
|
|
19
19
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { BlurViewProps } from './BlurView.types';
|
|
3
|
+
export default class BlurView extends React.Component<BlurViewProps> {
|
|
4
4
|
render(): JSX.Element;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
//# sourceMappingURL=BlurView.android.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlurView.android.d.ts","sourceRoot":"","sources":["../src/BlurView.android.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC;IAClE,MAAM;CAKP"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import getBackgroundColor from './getBackgroundColor';
|
|
4
|
-
class BlurView extends React.Component {
|
|
4
|
+
export default class BlurView extends React.Component {
|
|
5
5
|
render() {
|
|
6
|
-
const { tint = 'default', intensity =
|
|
6
|
+
const { tint = 'default', intensity = 50, style, ...props } = this.props;
|
|
7
7
|
const backgroundColor = getBackgroundColor(intensity, tint);
|
|
8
8
|
return React.createElement(View, { ...props, style: [style, { backgroundColor }] });
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
export default BlurView;
|
|
12
11
|
//# sourceMappingURL=BlurView.android.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlurView.android.js","sourceRoot":"","sources":["../src/BlurView.android.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,QAAS,SAAQ,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"BlurView.android.js","sourceRoot":"","sources":["../src/BlurView.android.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,eAAe,GAAG,kBAAkB,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QAC5D,OAAO,oBAAC,IAAI,OAAK,KAAK,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,eAAe,EAAE,CAAC,GAAI,CAAC;IAClE,CAAC;CACF","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 backgroundColor = getBackgroundColor(intensity, tint);\n return <View {...props} style={[style, { backgroundColor }]} />;\n }\n}\n"]}
|
package/build/BlurView.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
_setNativeRef: (ref: ComponentOrHandle) => void;
|
|
10
|
-
setNativeProps: (nativeProps: any) => void;
|
|
11
|
-
render(): JSX.Element;
|
|
12
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
declare const BlurViewWithForwardedRef: React.ForwardRefExoticComponent<{
|
|
4
|
+
tint?: import("./BlurView.types").BlurTint | undefined;
|
|
5
|
+
intensity?: number | undefined;
|
|
6
|
+
} & import("react-native").ViewProps & React.RefAttributes<View>>;
|
|
7
|
+
export default BlurViewWithForwardedRef;
|
|
8
|
+
//# sourceMappingURL=BlurView.d.ts.map
|
|
@@ -0,0 +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"}
|
package/build/BlurView.js
CHANGED
|
@@ -1,26 +1,54 @@
|
|
|
1
1
|
import { NativeModulesProxy, requireNativeViewManager } from 'expo-modules-core';
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { View, StyleSheet, findNodeHandle } from 'react-native';
|
|
4
|
+
class BlurView extends React.Component {
|
|
5
|
+
blurViewRef = React.createRef();
|
|
6
|
+
/**
|
|
7
|
+
* This component is a composition of the two components, but from the outside it's
|
|
8
|
+
* just a simple View with additional properties. To properly handle `setNativeProps`
|
|
9
|
+
* method (used when animating props), we need to properly separate `ViewProps` from `BlurViewProps`
|
|
10
|
+
* and pass them to the proper underlying views.
|
|
11
|
+
*
|
|
12
|
+
* This method handles the native view reference obtained from the parent View component
|
|
13
|
+
* and overrides it's original `setNativeProps` method that is available as it's property.
|
|
14
|
+
* When the `NativeBlurView` native ref is available `BlurView`-only props are forwarded
|
|
15
|
+
* to this view using `setNativeProps` method exposed by the native runtime.
|
|
16
|
+
*/
|
|
17
|
+
onRefChange = (view) => {
|
|
18
|
+
if (!view) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// Save the reference to the original method already bound to the proper calling context
|
|
22
|
+
const originalSetNativeProps = view.setNativeProps.bind(view);
|
|
23
|
+
// Override `setNativeProps` (https://reactnative.dev/docs/animations#setnativeprops)
|
|
24
|
+
view.setNativeProps = ({ tint, intensity, ...nativeProps }) => {
|
|
25
|
+
// Call the original method with all View-based props
|
|
26
|
+
view && originalSetNativeProps(nativeProps);
|
|
27
|
+
// Invoke `setNativeProps` native expo method defined by `ExpoBlurViewManager`
|
|
28
|
+
this.blurViewRef.current &&
|
|
29
|
+
NativeModulesProxy.ExpoBlurViewManager.setNativeProps({ tint, intensity }, findNodeHandle(this.blurViewRef.current));
|
|
30
|
+
};
|
|
31
|
+
// mimic `forwardedRef` logic
|
|
32
|
+
if (typeof this.props.forwardedRef === 'function') {
|
|
33
|
+
this.props.forwardedRef(view);
|
|
34
|
+
}
|
|
35
|
+
else if (this.props.forwardedRef) {
|
|
36
|
+
this.props.forwardedRef.current = view;
|
|
16
37
|
}
|
|
17
38
|
};
|
|
18
39
|
render() {
|
|
19
|
-
const { tint, intensity, style, children, ...props } = this.props;
|
|
20
|
-
return (React.createElement(View, { ...props,
|
|
21
|
-
React.createElement(NativeBlurView, { tint: tint, intensity: intensity,
|
|
40
|
+
const { tint = 'default', intensity = 50, style, children, forwardedRef, ...props } = this.props;
|
|
41
|
+
return (React.createElement(View, { ...props, ref: this.onRefChange, style: [styles.container, style] },
|
|
42
|
+
React.createElement(NativeBlurView, { ref: this.blurViewRef, tint: tint, intensity: intensity, style: StyleSheet.absoluteFill }),
|
|
22
43
|
children));
|
|
23
44
|
}
|
|
24
45
|
}
|
|
46
|
+
const styles = StyleSheet.create({
|
|
47
|
+
container: { backgroundColor: 'transparent' },
|
|
48
|
+
});
|
|
25
49
|
const NativeBlurView = requireNativeViewManager('ExpoBlurView');
|
|
50
|
+
// This `forwardedRef` mechanism is necessary to make this component work properly
|
|
51
|
+
// with React's `ref` prop and to react to props updates as expected.
|
|
52
|
+
const BlurViewWithForwardedRef = React.forwardRef((props, forwardRef) => (React.createElement(BlurView, { ...props, forwardedRef: forwardRef })));
|
|
53
|
+
export default BlurViewWithForwardedRef;
|
|
26
54
|
//# sourceMappingURL=BlurView.js.map
|
package/build/BlurView.js.map
CHANGED
|
@@ -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,
|
|
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,15 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare type BlurProps = {
|
|
1
|
+
import { ViewProps } from 'react-native';
|
|
2
|
+
export declare type BlurViewProps = {
|
|
4
3
|
/**
|
|
5
4
|
* A tint mode which will be applied to the view.
|
|
6
5
|
* @default 'default'
|
|
7
6
|
*/
|
|
8
|
-
tint
|
|
7
|
+
tint?: BlurTint;
|
|
9
8
|
/**
|
|
10
9
|
* A number from `1` to `100` to control the intensity of the blur effect.
|
|
10
|
+
*
|
|
11
|
+
* You can animate this property using `Animated API` from React Native or using `react-native-reanimated`.
|
|
12
|
+
* > Animating this property using `Animated API` from React Native with `setNativeDriver: true` does not work.
|
|
13
|
+
*
|
|
14
|
+
* @default 50
|
|
11
15
|
*/
|
|
12
|
-
intensity
|
|
13
|
-
} &
|
|
16
|
+
intensity?: number;
|
|
17
|
+
} & ViewProps;
|
|
14
18
|
export declare type BlurTint = 'light' | 'dark' | 'default';
|
|
15
|
-
|
|
19
|
+
//# sourceMappingURL=BlurView.types.d.ts.map
|
|
@@ -0,0 +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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlurView.types.js","sourceRoot":"","sources":["../src/BlurView.types.ts"],"names":[],"mappings":"","sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"BlurView.types.js","sourceRoot":"","sources":["../src/BlurView.types.ts"],"names":[],"mappings":"","sourcesContent":["import { ViewProps } from 'react-native';\n\nexport type BlurViewProps = {\n /**\n * A tint mode which will be applied to the view.\n * @default 'default'\n */\n tint?: BlurTint;\n /**\n * A number from `1` to `100` to control the intensity of the blur effect.\n *\n * You can animate this property using `Animated API` from React Native or using `react-native-reanimated`.\n * > Animating this property using `Animated API` from React Native with `setNativeDriver: true` does not work.\n *\n * @default 50\n */\n intensity?: number;\n} & ViewProps;\n\nexport type BlurTint = 'light' | 'dark' | 'default';\n"]}
|
package/build/BlurView.web.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { BlurViewProps } from './BlurView.types';
|
|
3
|
+
export default class BlurView extends React.Component<BlurViewProps> {
|
|
4
4
|
render(): JSX.Element;
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
//# sourceMappingURL=BlurView.web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlurView.web.d.ts","sourceRoot":"","sources":["../src/BlurView.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC;IAClE,MAAM;CAKP"}
|
package/build/BlurView.web.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import getBackgroundColor from './getBackgroundColor';
|
|
4
|
-
class BlurView extends React.Component {
|
|
4
|
+
export default class BlurView extends React.Component {
|
|
5
5
|
render() {
|
|
6
6
|
const { tint = 'default', intensity = 50, style, ...props } = this.props;
|
|
7
7
|
const blurStyle = getBlurStyle({ tint, intensity: Math.min(intensity, 100) });
|
|
@@ -24,5 +24,4 @@ function getBlurStyle({ intensity, tint }) {
|
|
|
24
24
|
}
|
|
25
25
|
return style;
|
|
26
26
|
}
|
|
27
|
-
export default BlurView;
|
|
28
27
|
//# sourceMappingURL=BlurView.web.js.map
|
|
@@ -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,QAAS,SAAQ,KAAK,CAAC,
|
|
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"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getBackgroundColor.d.ts","sourceRoot":"","sources":["../src/getBackgroundColor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,CAcpF"}
|
package/build/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { default as BlurView } from './BlurView';\nexport { BlurTint,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { default as BlurView } from './BlurView';\nexport { BlurTint, BlurViewProps } from './BlurView.types';\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
This class is based on https://gist.github.com/darrarski/29a2a4515508e385c90b3ffe6f975df7
|
|
7
|
+
*/
|
|
8
|
+
final class BlurEffectView: UIVisualEffectView {
|
|
9
|
+
@Clamping(lowerBound: 0.01, upperBound: 1)
|
|
10
|
+
var intensity: Double = 0.5 {
|
|
11
|
+
didSet {
|
|
12
|
+
setNeedsDisplay()
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@Containing(values: ["default", "light", "dark"])
|
|
17
|
+
var tint = "default" {
|
|
18
|
+
didSet {
|
|
19
|
+
visualEffect = UIBlurEffect(style: blurEffectStyleFrom(tint))
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private var visualEffect: UIVisualEffect = UIBlurEffect(style: blurEffectStyleFrom("default")) {
|
|
24
|
+
didSet {
|
|
25
|
+
setNeedsDisplay()
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
private var animator: UIViewPropertyAnimator?
|
|
29
|
+
|
|
30
|
+
init() {
|
|
31
|
+
super.init(effect: nil)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
required init?(coder aDecoder: NSCoder) { nil }
|
|
35
|
+
|
|
36
|
+
deinit {
|
|
37
|
+
animator?.stopAnimation(true)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
override func draw(_ rect: CGRect) {
|
|
41
|
+
super.draw(rect)
|
|
42
|
+
effect = nil
|
|
43
|
+
animator?.stopAnimation(true)
|
|
44
|
+
animator = UIViewPropertyAnimator(duration: 1, curve: .linear) { [unowned self] in
|
|
45
|
+
self.effect = visualEffect
|
|
46
|
+
}
|
|
47
|
+
animator?.fractionComplete = CGFloat(intensity)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private func blurEffectStyleFrom(_ tint: String) -> UIBlurEffect.Style {
|
|
52
|
+
switch tint {
|
|
53
|
+
case "light": return .extraLight
|
|
54
|
+
case "dark": return .dark
|
|
55
|
+
case "default": return .light
|
|
56
|
+
default: return .dark
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
Property wrapper clamping the value between an upper and lower bound
|
|
62
|
+
*/
|
|
63
|
+
@propertyWrapper
|
|
64
|
+
struct Clamping<Value: Comparable> {
|
|
65
|
+
var wrappedValue: Value
|
|
66
|
+
|
|
67
|
+
init(wrappedValue: Value, lowerBound: Value, upperBound: Value) {
|
|
68
|
+
self.wrappedValue = max(lowerBound, min(upperBound, wrappedValue))
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
Property wrapper ensuring that the value is contained in list of valid values
|
|
74
|
+
*/
|
|
75
|
+
@propertyWrapper
|
|
76
|
+
struct Containing<Value: Equatable> {
|
|
77
|
+
var wrappedValue: Value
|
|
78
|
+
|
|
79
|
+
init(wrappedValue: Value, values: [Value]) {
|
|
80
|
+
let isValueValid = values.contains(wrappedValue)
|
|
81
|
+
self.wrappedValue = isValueValid ? wrappedValue : values.first!
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import UIKit
|
|
4
|
+
import ExpoModulesCore
|
|
5
|
+
|
|
6
|
+
@objc(EXBlurView)
|
|
7
|
+
public class BlurView: ExpoView {
|
|
8
|
+
private var blurEffectView: BlurEffectView
|
|
9
|
+
|
|
10
|
+
override init(frame: CGRect) {
|
|
11
|
+
blurEffectView = BlurEffectView()
|
|
12
|
+
super.init(frame: frame)
|
|
13
|
+
|
|
14
|
+
blurEffectView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
|
|
15
|
+
clipsToBounds = true
|
|
16
|
+
|
|
17
|
+
addSubview(blurEffectView)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
required init?(coder: NSCoder) { nil }
|
|
21
|
+
|
|
22
|
+
@objc
|
|
23
|
+
public func setTint(_ tint: String) {
|
|
24
|
+
blurEffectView.tint = tint
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@objc
|
|
28
|
+
public func setIntensity(_ intensity: Double) {
|
|
29
|
+
blurEffectView.intensity = intensity
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
// Copyright 2016-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
|
-
#import <EXBlur/EXBlurView.h>
|
|
4
3
|
#import <EXBlur/EXBlurViewManager.h>
|
|
5
4
|
#import <ExpoModulesCore/EXUIManager.h>
|
|
6
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
|
+
|
|
7
12
|
@interface EXBlurViewManager ()
|
|
8
13
|
|
|
9
14
|
@property (weak, nonatomic) EXModuleRegistry *moduleRegistry;
|
|
@@ -20,7 +25,7 @@ EX_EXPORT_MODULE(ExpoBlurViewManager);
|
|
|
20
25
|
|
|
21
26
|
- (UIView *)view
|
|
22
27
|
{
|
|
23
|
-
return [
|
|
28
|
+
return [EXBlurView new];
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
- (NSString *)viewName
|
|
@@ -31,39 +36,28 @@ EX_EXPORT_MODULE(ExpoBlurViewManager);
|
|
|
31
36
|
EX_VIEW_PROPERTY(tint, NSString *, EXBlurView)
|
|
32
37
|
{
|
|
33
38
|
[view setTint:value];
|
|
34
|
-
[view didSetProps:@[@"tint"]];
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
EX_VIEW_PROPERTY(intensity, NSNumber *, EXBlurView)
|
|
38
42
|
{
|
|
39
|
-
[view setIntensity:value];
|
|
40
|
-
[view didSetProps:@[@"intensity"]];
|
|
43
|
+
[view setIntensity:[value doubleValue] / 100];
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
EX_EXPORT_METHOD_AS(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
EX_EXPORT_METHOD_AS(setNativeProps,
|
|
47
|
+
setNativeProps:(NSDictionary *)nativeProps
|
|
48
|
+
forViewWithTag:(id)viewTag
|
|
49
|
+
resolver:(EXPromiseResolveBlock)resolve
|
|
50
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
48
51
|
{
|
|
49
52
|
[[_moduleRegistry getModuleImplementingProtocol:@protocol(EXUIManager)] executeUIBlock:^(id view) {
|
|
50
53
|
if ([view isKindOfClass:[EXBlurView class]]) {
|
|
51
54
|
EXBlurView *blurView = view;
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
[blurView setIntensity:props[@"intensity"]];
|
|
55
|
-
[changedProps addObject:@"intensity"];
|
|
56
|
-
}
|
|
57
|
-
if (props[@"tint"] && ![props[@"tint"] isEqual:blurView.tint]) {
|
|
58
|
-
[blurView setTint:props[@"tint"]];
|
|
59
|
-
[changedProps addObject:@"tint"];
|
|
60
|
-
}
|
|
61
|
-
[blurView didSetProps:changedProps];
|
|
62
|
-
resolver([NSNull null]);
|
|
55
|
+
if (nativeProps[@"intensity"]) { [blurView setIntensity:[nativeProps[@"intensity"] floatValue] / 100]; }
|
|
56
|
+
if (nativeProps[@"tint"]) { [blurView setTint:nativeProps[@"tint"]]; }
|
|
63
57
|
} else {
|
|
64
|
-
|
|
58
|
+
reject(@"E_INVALID_VIEW", [NSString stringWithFormat:@"Invalid view returned from registry, expected EXBlurView, got: %@", view], nil);
|
|
65
59
|
}
|
|
66
|
-
} forView:
|
|
60
|
+
} forView:viewTag ofClass:[EXBlurView class]];
|
|
67
61
|
}
|
|
68
62
|
|
|
69
63
|
@end
|
package/ios/EXBlur.podspec
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-blur",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.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",
|
|
@@ -33,11 +33,12 @@
|
|
|
33
33
|
"author": "650 Industries, Inc.",
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/blur-view/",
|
|
36
|
-
"dependencies": {
|
|
37
|
-
"expo-modules-core": "~0.4.4"
|
|
38
|
-
},
|
|
36
|
+
"dependencies": {},
|
|
39
37
|
"devDependencies": {
|
|
40
38
|
"expo-module-scripts": "^2.0.0"
|
|
41
39
|
},
|
|
42
|
-
"
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"expo": "*"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "e893ff2b01e108cf246cec02318c0df9d6bc603c"
|
|
43
44
|
}
|
package/src/BlurView.android.tsx
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { BlurViewProps } from './BlurView.types';
|
|
5
5
|
import getBackgroundColor from './getBackgroundColor';
|
|
6
6
|
|
|
7
|
-
class BlurView extends React.Component<
|
|
7
|
+
export default class BlurView extends React.Component<BlurViewProps> {
|
|
8
8
|
render() {
|
|
9
|
-
const { tint = 'default', intensity =
|
|
9
|
+
const { tint = 'default', intensity = 50, style, ...props } = this.props;
|
|
10
10
|
const backgroundColor = getBackgroundColor(intensity, tint);
|
|
11
11
|
return <View {...props} style={[style, { backgroundColor }]} />;
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
export default BlurView;
|