generated from flexlark/app-template
Initial commit
This commit is contained in:
29
packages/ui/src/NativeToast.tsx
Normal file
29
packages/ui/src/NativeToast.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Toast, useToastState } from '@tamagui/toast'
|
||||
import { YStack } from 'tamagui'
|
||||
|
||||
export const NativeToast = () => {
|
||||
const currentToast = useToastState()
|
||||
|
||||
if (!currentToast || currentToast.isHandledNatively) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<Toast
|
||||
key={currentToast.id}
|
||||
duration={currentToast.duration}
|
||||
viewportName={currentToast.viewportName}
|
||||
enterStyle={{ opacity: 0, scale: 0.5, y: -25 }}
|
||||
exitStyle={{ opacity: 0, scale: 1, y: -20 }}
|
||||
y={0}
|
||||
opacity={1}
|
||||
scale={1}
|
||||
animation="quick"
|
||||
>
|
||||
<YStack py="$1.5" px="$2">
|
||||
<Toast.Title lineHeight="$1">{currentToast.title}</Toast.Title>
|
||||
{!!currentToast.message && <Toast.Description>{currentToast.message}</Toast.Description>}
|
||||
</YStack>
|
||||
</Toast>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user