import React from 'react'; import { View, Text, StyleSheet, ScrollView, TouchableOpacity } from 'react-native'; import { useUx4gTheme } from '../theme/Ux4gThemeContext'; import { useUx4gToast, Ux4gToast } from '../components/toast/Toast'; import { Ux4gButton } from '../components/button/Button'; /** * **ToastShowcase** * * Demonstrates the `Ux4gToast` component and the `useUx4gToast` hook. * Showcases all `category` variants, layouts (`full`, `stacked`), and actions. */ export const ToastShowcase: React.FC = () => { const { colors, typography, isDark } = useUx4gTheme(); const { showToast, dismiss } = useUx4gToast(); const cardStyle = [ styles.card, { backgroundColor: colors.surface ?? (isDark ? '#18181B' : '#FFFFFF'), borderColor: isDark ? '#27272A' : '#E4E4E7', }, ]; const titleStyle = [styles.cardTitle, { color: colors.onSurface }]; const subtitleStyle = [ styles.cardSubtitle, { color: isDark ? '#A1A1AA' : '#71717A' }, ]; return ( 🍞 Toast (`Ux4gToast`) Ephemeral animated overlay component. Use `useUx4gToast()` to trigger notifications from anywhere inside a `Ux4gToastProvider`. {/* ── SECTION 0: Static Variants ─────────────────────────────────────── */} 0. All Static Variants (Inline) Statically rendered examples of all layouts, actions, and categories. {/* Full Layouts */} Full Layout (Default) {/* Stacked Layouts */} Stacked Layout {/* Action & Configuration States */} With Actions & Configurations {}} layout="full" /> {}} showCloseButton={false} layout="stacked" /> {/* ── SECTION 1: Standard Categories (Top Position) ─────────────────── */} 1. Standard Semantic Categories (Top Position) Trigger default toasts sliding in from the TOP of the screen (`isBottom: false`). showToast({ category: 'info', title: 'Information', subtitle: 'This is an info toast message.', isBottom: false, }) } /> showToast({ category: 'success', title: 'Successfully Saved', subtitle: 'Your profile has been updated.', isBottom: false, }) } /> {/* ── SECTION 2: Standard Categories (Bottom Position) ──────────────── */} 2. Semantic Categories (Bottom Position) Trigger default toasts sliding in from the BOTTOM of the screen (`isBottom: true`). showToast({ category: 'warning', title: 'Storage Almost Full', subtitle: 'Please free up some space soon.', isBottom: true, }) } /> showToast({ category: 'error', title: 'Connection Lost', subtitle: 'Failed to connect to the server.', isBottom: true, }) } /> showToast({ category: 'slot', title: 'Custom Action Required', isBottom: true, }) } /> {/* ── SECTION 3: Layouts & Actions ───────────────────────────────────── */} 3. Layouts, Actions & Timing Toasts can have action buttons and auto-close behaviors. showToast({ category: 'info', title: 'New Update Available', actionText: 'UPDATE', onActionClick: () => { dismiss(); console.log('Update clicked!'); }, durationMs: 5000, }) } /> showToast({ category: 'warning', title: 'Network Offline', subtitle: 'Please reconnect to the internet.', autoClose: false, actionText: 'RETRY', onActionClick: () => dismiss(), }) } /> ); }; const styles = StyleSheet.create({ container: { flex: 1, }, contentContainer: { padding: 16, paddingBottom: 64, }, header: { marginBottom: 20, }, title: { fontSize: 22, fontWeight: '800', marginBottom: 6, }, card: { borderWidth: 1, borderRadius: 12, padding: 16, marginBottom: 20, }, cardTitle: { fontSize: 16, fontWeight: '700', marginBottom: 4, }, cardSubtitle: { fontSize: 13, marginBottom: 16, lineHeight: 18, }, buttonGrid: { flexDirection: 'row', flexWrap: 'wrap', gap: 12, }, staticList: { flexDirection: 'column', gap: 12, }, });