UNPKG

@janiscommerce/ui-native

Version:
32 lines (31 loc) 975 B
import React from 'react'; import { StyleSheet, View } from 'react-native'; import { black, palette } from '../../../theme/palette'; import { parseType } from './utils'; export var Types; (function (Types) { Types["Success"] = "success"; Types["Notice"] = "notice"; Types["Warning"] = "warning"; Types["Error"] = "error"; Types["Action"] = "action"; })(Types || (Types = {})); const defaultType = Types.Notice; const BaseToast = ({ children, style, type = defaultType, ...props }) => { if (!children) { return null; } const selectedType = parseType[type]; const backgroundColor = palette[selectedType]?.main || palette[defaultType]?.main; const styles = StyleSheet.create({ container: { backgroundColor, elevation: 5, shadowColor: black.shadow, }, }); return (<View style={[styles.container, style]} {...props}> {children} </View>); }; export default BaseToast;