Toast Manager with Reanimated and Gesture Handler 🍞
Wednesday, November 22, 2023
demos
toast
An ongoing collection of React Native animations crafted with Reanimated, Gesture Handler, and Skia.
TypeScript
3.2k
296
A customizable toast notification system with gesture support.
What's This About?
This component creates an interactive toast notification system with gesture-based dismissal. It features customizable toast messages with icons, auto-dismiss functionality, and smooth animations. The implementation includes a provider-based toast management system, gesture handling for swipe-to-dismiss, and support for multiple concurrent toasts, making it perfect for applications requiring user feedback and notifications.
Technical Implementation
The component uses:
Toast management
Gesture handling
Auto-dismiss
Custom icons
Provider pattern
Usage
// Basic usage with provider
<ToastProvider>
<App />
</ToastProvider>;
// Show a toast
const { showToast } = useToast();
// Simple toast
showToast({
title: 'Simple toast message',
leading: () => <AntDesign name="checkcircle" size={20} color="black" />,
});
// Advanced toast with subtitle and auto-dismiss
showToast({
title: 'Advanced toast',
subtitle: 'With more details',
autodismiss: true,
leading: () => <AntDesign name="user" size={20} color="black" />,
});
// Toast with custom key
showToast({
title: 'Custom toast',
key: `toast-${Math.random()}`,
leading: () => <AntDesign name="twitter" size={20} color="black" />,
});
// Toast configuration type
type ToastType = {
id: string;
title: string;
subtitle?: string;
autodismiss?: boolean;
leading: () => React.ReactNode;
key?: string;
};
Unlock the beauty of React Native animations
Learn Reanimated, Gesture Handler & Skia with Reanimate.dev
Feedback on Toast
Ideas, bugs, or anything that felt off: I read every message. For anything else, write to hello@reactiive.io.
Send feedback