import React from 'react'; import {SafeAreaView as SafeAreaViews} from 'react-native-safe-area-context'; import {StyleSheet, StyleProp, ViewStyle, Platform, View} from 'react-native'; import Surface from '../Core/Surface'; import Text from '../Core/Typography'; import {useTheme} from '../../Theming'; import Button from '../Buttons/Button'; import Color from 'color'; import {useAnimation} from '../../Helpers/Hooks'; const SafeAreaView = Platform.OS === 'web' ? View : SafeAreaViews; type ActionType = { color?: string; label?: string; accessibilityLabel?: string; onPress?: () => void; }; type SnackbarType = { label: string; color?: string; // avatar?:AvatarType; style?: StyleProp; backgroundColor?: string; elevation?: number; action?: ActionType | undefined; isOpen?: boolean; onDismiss?: () => void; }; const Snackbar: React.FC = ({ style, label, color, backgroundColor, elevation, isOpen, action, onDismiss, }) => { const {roundness, dark, color: colors} = useTheme(); const opacity = useAnimation({ type: 'timing', toValue: isOpen ? 1 : 0, initialValue: 0, duration: 200, delay: 0, }); React.useEffect(() => { if (isOpen === true) { setTimeout(onDismiss, 3000); } }, [isOpen]); return ( }> {label} {action ? ( ) : null} ); }; const styles = StyleSheet.create({ wrapper: { position: 'absolute', bottom: 0, width: '100%', }, content: { marginLeft: 16, marginTop: 16, marginBottom: 16, flexWrap: 'wrap', // flex: 1, }, button: { margin: 6, }, }); export default Snackbar;