···11-import {type Theme, select} from '#/alf'
11+import {select, type Theme} from '#/alf'
22+import {Check_Stroke2_Corner0_Rounded as SuccessIcon} from '#/components/icons/Check'
33+import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
24import {CircleInfo_Stroke2_Corner0_Rounded as ErrorIcon} from '#/components/icons/CircleInfo'
35import {Warning_Stroke2_Corner0_Rounded as WarningIcon} from '#/components/icons/Warning'
44-import {Check_Stroke2_Corner0_Rounded as SuccessIcon} from '#/components/icons/Check'
55-import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
6677-export type ToastType = 'default' | 'success' | 'error' | 'warning' | 'info'
77+export type ToastType =
88+ | 'default'
99+ | 'success'
1010+ | 'error'
1111+ | 'warning'
1212+ | 'info'
1313+ | 'xmark'
1414+ | 'exclamation-circle'
1515+ | 'check'
1616+ | 'clipboard-check'
1717+ | 'circle-exclamation'
818919export const TOAST_ANIMATION_CONFIG = {
1020 duration: 300,
+9-7
src/view/com/util/Toast.tsx
···1717} from 'react-native-reanimated'
1818import RootSiblings from 'react-native-root-siblings'
1919import {useSafeAreaInsets} from 'react-native-safe-area-context'
2020+2021import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
2121-import {atoms as a, useTheme} from '#/alf'
2222-import {Text} from '#/components/Typography'
2322import {
2424- type ToastType,
2525- TOAST_TYPE_TO_ICON,
2623 getToastTypeStyles,
2724 TOAST_ANIMATION_CONFIG,
2828-} from './Toast.style'
2525+ TOAST_TYPE_TO_ICON,
2626+ type ToastType,
2727+} from '#/view/com/util/Toast.style'
2828+import {atoms as a, useTheme} from '#/alf'
2929+import {Text} from '#/components/Typography'
29303031const TIMEOUT = 2e3
3132···5657 const [cardHeight, setCardHeight] = useState(0)
57585859 const toastStyles = getToastTypeStyles(t)
5959- const colors = toastStyles[type]
6060- const IconComponent = TOAST_TYPE_TO_ICON[type]
6060+ const colors = toastStyles[type as keyof typeof toastStyles]
6161+ const IconComponent =
6262+ TOAST_TYPE_TO_ICON[type as keyof typeof TOAST_TYPE_TO_ICON]
61636264 // for the exit animation to work on iOS the animated component
6365 // must not be the root component
+8-7
src/view/com/util/Toast.web.tsx
···4455import {useEffect, useState} from 'react'
66import {Pressable, StyleSheet, Text, View} from 'react-native'
77-import {atoms as a, useTheme} from '#/alf'
77+88import {
99- type ToastType,
1010- TOAST_TYPE_TO_ICON,
119 getToastTypeStyles,
1210 getToastWebAnimationStyles,
1111+ TOAST_TYPE_TO_ICON,
1312 TOAST_WEB_KEYFRAMES,
1414-} from './Toast.style'
1313+ type ToastType,
1414+} from '#/view/com/util/Toast.style'
1515+import {atoms as a, useTheme} from '#/alf'
15161617const DURATION = 3500
1718···62636364 const toastTypeStyles = getToastTypeStyles(t)
6465 const toastStyles = activeToast
6565- ? toastTypeStyles[activeToast.type]
6666+ ? toastTypeStyles[activeToast.type as keyof typeof toastTypeStyles]
6667 : toastTypeStyles.default
67686869 const IconComponent = activeToast
6969- ? TOAST_TYPE_TO_ICON[activeToast.type]
7070+ ? TOAST_TYPE_TO_ICON[activeToast.type as keyof typeof TOAST_TYPE_TO_ICON]
7071 : TOAST_TYPE_TO_ICON.default
71727273 const animationStyles = getToastWebAnimationStyles()
···146147 maxWidth: 380,
147148 padding: 20,
148149 flexDirection: 'row',
149149- alignItems: 'flex-start',
150150+ alignItems: 'center',
150151 borderRadius: 10,
151152 borderWidth: 1,
152153 },
+10-8
src/view/screens/Storybook/Toasts.tsx
···11-import {View, Pressable} from 'react-native'
11+import {Pressable, View} from 'react-native'
2233-import {atoms as a, useTheme} from '#/alf'
44-import {Text, H1} from '#/components/Typography'
33+import * as Toast from '#/view/com/util/Toast'
54import {
66- type ToastType,
77- TOAST_TYPE_TO_ICON,
85 getToastTypeStyles,
66+ TOAST_TYPE_TO_ICON,
77+ type ToastType,
98} from '#/view/com/util/Toast.style'
1010-import * as Toast from '#/view/com/util/Toast'
99+import {atoms as a, useTheme} from '#/alf'
1010+import {H1, Text} from '#/components/Typography'
11111212function ToastPreview({message, type}: {message: string; type: ToastType}) {
1313 const t = useTheme()
1414 const toastStyles = getToastTypeStyles(t)
1515- const colors = toastStyles[type]
1616- const IconComponent = TOAST_TYPE_TO_ICON[type]
1515+ const colors = toastStyles[type as keyof typeof toastStyles]
1616+ const IconComponent =
1717+ TOAST_TYPE_TO_ICON[type as keyof typeof TOAST_TYPE_TO_ICON]
17181819 return (
1920 <Pressable
2121+ accessibilityRole="button"
2022 onPress={() => Toast.show(message, type)}
2123 style={[
2224 {backgroundColor: colors.backgroundColor},