@danielsaraldi/react-native-blur-view
Version:
A simple blur view in react native
78 lines (76 loc) • 1.97 kB
JavaScript
;
import { Children, forwardRef } from 'react';
import { Platform, View } from 'react-native';
import Vibrancy from './VibrancyViewNativeComponent';
import { globalStyles } from "./styles/index.js";
/**
* @description The `VibrancyView` component is a React Native component that
* provides a native vibrancy effect to its children.
*
* @see https://github.com/DanielAraldi/react-native-blur-view?tab=readme-ov-file#vibrancyview
*
* @since 1.2.0
*
* @example
* ```tsx
* import React from 'react';
* import { View, Text } from 'react-native';
* import { VibrancyView } from '@danielsaraldi/react-native-blur-view';
* import { styles } from './styles';
*
* const MyComponent = () => {
* return (
* <View style={styles.container}>
* <VibrancyView style={styles.vibrancyView}>
* <Text style={styles.vibrancyText}>Vibrant Content</Text>
* </VibrancyView>
* </View>
* );
* };
* ```
*/
import { jsx as _jsx } from "react/jsx-runtime";
export const VibrancyView = /*#__PURE__*/forwardRef((props, ref) => {
const {
type = 'light',
effectStyle = 'label',
radius = 10,
reducedTransparencyFallbackColor = 'white',
style,
children,
overlayColor,
...rest
} = props;
if (Platform.OS !== 'ios') {
return /*#__PURE__*/_jsx(View, {
ref: ref,
style: style,
...rest,
children: children
});
}
const commonProps = {
ref,
radius,
effectStyle,
reducedTransparencyFallbackColor,
overlayColor: type,
style: [globalStyles.container, style, {
backgroundColor: overlayColor
}],
...rest
};
if (!Children.count(children)) {
return /*#__PURE__*/_jsx(Vibrancy, {
...commonProps,
children: /*#__PURE__*/_jsx(View, {
style: globalStyles.expand
})
});
}
return /*#__PURE__*/_jsx(Vibrancy, {
...commonProps,
children: children
});
});
//# sourceMappingURL=VibrancyView.js.map