UNPKG

778 BTypeScriptView Raw
1import PropTypes from 'prop-types';
2import * as React from 'react';
3import { View, ViewPropTypes } from 'react-native';
4
5import { BlurTint, BlurProps } from './BlurView.types';
6import getBackgroundColor from './getBackgroundColor';
7
8export 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}