UNPKG

800 BTypeScriptView Raw
1import PropTypes from 'prop-types';
2import * as React from 'react';
3import { View, ViewPropTypes } from 'react-native';
4
5type Props = {
6 tint: BlurTint;
7} & React.ComponentProps<typeof View>;
8type BlurTint = 'light' | 'dark' | 'default';
9
10export default class BlurView extends React.Component<Props> {
11 static propTypes = {
12 tint: PropTypes.oneOf(['light', 'default', 'dark']),
13 ...ViewPropTypes,
14 };
15
16 render() {
17 let { tint, ...props } = 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 <View {...props} style={[this.props.style, { backgroundColor }]} />;
29 }
30}