1 | import PropTypes from 'prop-types';
|
2 | import * as React from 'react';
|
3 | import { View, ViewPropTypes } from 'react-native';
|
4 |
|
5 | import { BlurTint, BlurProps } from './BlurView.types';
|
6 | import getBackgroundColor from './getBackgroundColor';
|
7 |
|
8 | export default class BlurView extends React.Component<BlurProps> {
|
9 | static propTypes = {
|
10 | ...ViewPropTypes,
|
11 | tint: PropTypes.oneOf(['light', 'default', 'dark'] as BlurTint[]).isRequired,
|
12 | intensity: PropTypes.number.isRequired,
|
13 | };
|
14 |
|
15 | static defaultProps = {
|
16 | tint: 'default' as BlurTint,
|
17 | intensity: 100,
|
18 | };
|
19 |
|
20 | render() {
|
21 | let { tint, intensity, ...props } = this.props;
|
22 |
|
23 | let backgroundColor = getBackgroundColor(intensity, tint);
|
24 |
|
25 | return <View {...props} style={[this.props.style, { backgroundColor }]} />;
|
26 | }
|
27 | }
|