Swipe Toast

Interactive toast that can be swiped horizontally to dismiss.

Component Features and Props

How to Use Swipe Toast Component

Installation Guide for Swipe Toast

Component Props

Specifications
PropTypeDefaultDescription
visibleReqboolean-Control visibility
messageReqstring-Message text
actionLabelstring-Optional action button text
onAction() => void-Action callback
onDismissReq() => void-Dismiss callback

Install

TERMINAL
$ npx expo install react-native

Component Code

Component.tsx
1import React, { useEffect, useRef, useState } from 'react';
2import {
3    Text,
4    StyleSheet,
5    Animated,
6    View,
7    Dimensions,
8    PanResponder,
9    TouchableOpacity
10} from 'react-native';
11
12const SCREEN_WIDTH = Dimensions.get('window').width;
13const SWIPE_THRESHOLD = SCREEN_WIDTH * 0.4;
14
15interface SwipeToastProps {
16    visible: boolean;
17    message: string;
18    actionLabel?: string;
19    onAction?: () => void;
20    onDismiss: () => void;

Usage

Usage.tsx
import React, { useState } from 'react';
import { StyleSheet, View, Text, TouchableOpacity, SafeAreaView } from 'react-native';
import SwipeToast from './components/SwipeToast';

export default function App() {
    const [toastVisible, setToastVisible] = useState(false);
    const [undoMode, setUndoMode] = useState(false);

    const handleDelete = () => {
        setUndoMode(true);
        setToastVisible(true);
    };

    const handleUndo = () => {
        setUndoMode(false);
        setToastVisible(false);
        console.log("Action Undone!");
    };

    return (
100%
Swipe Toast - React Native Toast & Snackbar Notification | Uilora | Uilora