import React from 'react' import { StyleSheet, Text, View } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' import Toast from 'react-native-toast-message' import { useTheme } from '@utils/styles/ThemeManager' import { Feather } from '@expo/vector-icons' import { StyleConstants } from '@utils/styles/constants' export interface Params { type: 'success' | 'error' | 'warning' position?: 'top' | 'bottom' content: string description?: string autoHide?: boolean onShow?: () => void onHide?: () => void } type Config = { type: Params['type'] position: Params['position'] text1: Params['content'] text2: Params['description'] } const toast = ({ type, position = 'top', content, description, autoHide = true, onShow, onHide }: Params) => { Toast.show({ type, position, text1: content, text2: description, visibilityTime: 1500, autoHide, topOffset: 0, bottomOffset: 0, onShow: onShow, onHide: onHide }) } const ToastBase = ({ config }: { config: Config }) => { const { theme } = useTheme() const iconSet = { success: 'check-circle', error: 'x-circle', warning: 'alert-circle' } enum colorMapping { success = 'blue', error = 'red', warning = 'secondary' } return ( {config.text1} {config.text2 && ( {config.text2} )} ) } const toastConfig = { success: (config: Config) => , error: (config: Config) => , warning: (config: Config) => } const styles = StyleSheet.create({ base: { width: '100%', borderBottomWidth: 1 }, container: { flex: 1, flexDirection: 'row', justifyContent: 'center', alignItems: 'center', padding: StyleConstants.Spacing.L }, texts: { marginLeft: StyleConstants.Spacing.S }, text1: { ...StyleConstants.FontStyle.M }, text2: { ...StyleConstants.FontStyle.S, marginTop: StyleConstants.Spacing.S } }) export { toast, toastConfig }