import React from 'react';
import { View, Text } from 'react-native';
import { Portal } from 'react-native-cross-elements';
export function ToastDemo() {
const [message, setMessage] = React.useState<string | null>(null);
React.useEffect(() => {
const show = setInterval(() => setMessage('Saved ✅'), 5000);
const hide = setInterval(() => setMessage(null), 6500);
return () => { clearInterval(show); clearInterval(hide); };
}, []);
return (
<Portal>
{message && (
<View
style={{
position: 'absolute',
bottom: 24,
left: 0,
right: 0,
alignItems: 'center',
// Important: enable touches for portal content
pointerEvents: 'auto',
}}
>
<View
style={{
paddingVertical: 10,
paddingHorizontal: 20,
borderRadius: 10,
backgroundColor: '#18181b',
borderWidth: 1,
borderColor: '#27272a',
}}
>
<Text style={{ color: '#e4e4e7' }}>{message}</Text>
</View>
</View>
)}
</Portal>
);
}