UNPKG

877 BJavaScriptView Raw
1import React, { Component } from 'react';
2import PropTypes from 'prop-types';
3import { View, ViewPropTypes } from 'react-native';
4import deprecatedPropType from 'react-native/Libraries/Utilities/deprecatedPropType';
5
6export default class BlurView extends Component {
7 static propTypes = {
8 tintEffect: deprecatedPropType(
9 PropTypes.string,
10 'Use the `tint` prop instead.'
11 ),
12 tint: PropTypes.oneOf(['light', 'default', 'dark']),
13 ...ViewPropTypes,
14 };
15
16 render() {
17 let { tint } = this.props;
18
19 let backgroundColor;
20 if (tint === 'dark') {
21 backgroundColor = 'rgba(0,0,0,0.5)';
22 } else if (tint === 'light') {
23 backgroundColor = 'rgba(255,255,255,0.7)';
24 } else {
25 backgroundColor = 'rgba(255,255,255,0.4)';
26 }
27
28 return (
29 <View {...this.props} style={[this.props.style, { backgroundColor }]} />
30 );
31 }
32}