mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-18 18:21:22 +02:00
Projects included: - maerchenzauber (NestJS backend + Expo mobile + SvelteKit web + Astro landing) - manacore (Expo mobile + SvelteKit web + Astro landing) - manadeck (NestJS backend + Expo mobile + SvelteKit web) - memoro (Expo mobile + SvelteKit web + Astro landing) This commit preserves the current state before monorepo restructuring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
101 lines
No EOL
2.6 KiB
TypeScript
101 lines
No EOL
2.6 KiB
TypeScript
import React from 'react';
|
|
import { View, StyleSheet } from 'react-native';
|
|
import Toast from './Toast.simple';
|
|
import { useToastStore } from '../store/toastStore';
|
|
|
|
const ToastContainer: React.FC = () => {
|
|
const { toasts, removeToast } = useToastStore();
|
|
|
|
if (toasts.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
// Group toasts by position
|
|
const topToasts = toasts.filter(toast => !toast.position || toast.position === 'top');
|
|
const bottomToasts = toasts.filter(toast => toast.position === 'bottom');
|
|
|
|
return (
|
|
<>
|
|
{/* Top Toasts */}
|
|
{topToasts.length > 0 && (
|
|
<View
|
|
style={[
|
|
styles.container,
|
|
styles.topContainer,
|
|
{
|
|
top: 120, // Fixed 120px from top to appear below header (adjusted for larger screens)
|
|
},
|
|
]}
|
|
pointerEvents="box-none"
|
|
>
|
|
{topToasts.filter(Boolean).map((toast) => (
|
|
toast && toast.id ? (
|
|
<Toast
|
|
key={toast.id}
|
|
toast={toast}
|
|
onDismiss={removeToast}
|
|
onAction={() => {
|
|
// Optional: dismiss after action
|
|
if (toast.onDismiss) {
|
|
toast.onDismiss();
|
|
}
|
|
}}
|
|
/>
|
|
) : null
|
|
))}
|
|
</View>
|
|
)}
|
|
|
|
{/* Bottom Toasts */}
|
|
{bottomToasts.length > 0 && (
|
|
<View
|
|
style={[
|
|
styles.container,
|
|
styles.bottomContainer,
|
|
{
|
|
bottom: 100, // Fixed 100px from bottom
|
|
},
|
|
]}
|
|
pointerEvents="box-none"
|
|
>
|
|
{bottomToasts.filter(Boolean).map((toast) => (
|
|
toast && toast.id ? (
|
|
<Toast
|
|
key={toast.id}
|
|
toast={toast}
|
|
onDismiss={removeToast}
|
|
onAction={() => {
|
|
// Optional: dismiss after action
|
|
if (toast.onDismiss) {
|
|
toast.onDismiss();
|
|
}
|
|
}}
|
|
/>
|
|
) : null
|
|
))}
|
|
</View>
|
|
)}
|
|
</>
|
|
);
|
|
};
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
position: 'absolute',
|
|
left: 0,
|
|
right: 0,
|
|
zIndex: 99999,
|
|
elevation: 99999,
|
|
alignItems: 'center', // Center toasts horizontally
|
|
paddingHorizontal: 16, // Add horizontal padding to all containers
|
|
},
|
|
topContainer: {
|
|
// Toasts appear from top to bottom
|
|
},
|
|
bottomContainer: {
|
|
// Toasts appear from bottom to top (reverse order)
|
|
flexDirection: 'column-reverse',
|
|
},
|
|
});
|
|
|
|
export default ToastContainer; |