1 | import { NativeModulesProxy, requireNativeViewManager } from '@unimodules/core';
|
2 | import * as React from 'react';
|
3 | import { findNodeHandle } from 'react-native';
|
4 |
|
5 | import { BlurProps, BlurTint, ComponentOrHandle } from './BlurView.types';
|
6 |
|
7 | export default class BlurView extends React.Component<BlurProps> {
|
8 | static defaultProps = {
|
9 | tint: 'default' as BlurTint,
|
10 | intensity: 50,
|
11 | };
|
12 |
|
13 | _root: ComponentOrHandle = null;
|
14 |
|
15 | _setNativeRef = (ref: ComponentOrHandle) => {
|
16 | this._root = ref;
|
17 | };
|
18 |
|
19 | setNativeProps = nativeProps => {
|
20 | if (this._root) {
|
21 | NativeModulesProxy.ExpoBlurViewManager.updateProps(nativeProps, findNodeHandle(this._root));
|
22 | }
|
23 | };
|
24 |
|
25 | render() {
|
26 | const { style, ...props } = this.props;
|
27 | return (
|
28 | <NativeBlurView
|
29 | {...props}
|
30 | ref={this._setNativeRef}
|
31 | style={[style, { backgroundColor: 'transparent' }]}
|
32 | />
|
33 | );
|
34 | }
|
35 | }
|
36 |
|
37 | const NativeBlurView = requireNativeViewManager('ExpoBlurView');
|