1.2.0 • Published 2 years ago

react-native-swipeable-toast-basic v1.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

This is a custom swipeable toast basic. My build versions: 1- react-native-gesture-handler: 2.9.0 2- react-native-reanimated: 2.14.4

Installation

  npm install react-native-swipeable-toast-basic

Doc

react-native-reanimated

react-native-gesture-handler

Usage

    //App.js
    import { GestureHandlerRootView } from "react-native-gesture-handler";

    <GestureHandlerRootView style={{ flex: 1 }}>
        //Your codes in here
    </GestureHandlerRootView>;

    //Usage in screen
    import React, { useRef } from "react";
    import { Button } from "react-native";
    import SwipeableToast from "react-native-swipeable-toast-basic";

    const toastRef = useRef(null);

    <SafeAreaView style={{flex: 1}}>
        <SwipeableToast ref={toastRef} />
    </SafeAreaView>

    <Button
        title="Show Swipeable Toast Basic"
        onPress={() => {
            toastRef.current.showToast({
                type: "success", // success - info - warning - error
                title: "Title",
                text: "Text",
                duration: 3000,
                toastWidth: "90%",
                toastPadding: 16,
                toastBorderRadius: 16,
                toastBorderWidth: 0.5,
                toastSuccessBgColor: "#DEF1D7",
                toastSuccessBorderColor: "#1F8722",
                toastInfoBgColor: "#ECF4FE",
                toastInfoBorderColor: "#1F5F87",
                toastWarningBgColor: "#FEF7EC",
                toastWarningBorderColor: "#F08135",
                toastErrorBgColor: "#FAE1DB",
                toastErrorBorderColor: "#D9100A",
                toastSuccessTitleColor: "#1F8722",
                toastInfoTitleColor: "#1F6587",
                toastWarningTitleColor: "#F08135",
                toastErrorTitleColor: "#D9100A",
                toastSuccessTextColor: "#1F8722",
                toastInfoTextColor: "#1F6587",
                toastWarningTextColor: "#F08135",
                toastErrorTextColor: "#D9100A",
            });
        }}
    />

API

proptypedescriptiondefault
typeStringToast type."success"
titleStringToast title."Non"
textStringToast text."Non"
durationNumberToast duration.3000
toastWidthStringToast width."90%"
toastPaddingNumberToast padding.16
toastBorderRadiusNumberToast border radius.16
toastBorderWidthNumberToast border width.0.5
toastSuccessBgColorStringToast bg color."#DEF1D7"
toastSuccessBorderColorStringToast border color."#1F8722"
toastInfoBgColorStringToast bg color."#ECF4FE"
toastInfoBorderColorStringToast border color."#1F5F87"
toastWarningBgColorStringToast bg color."#FEF7EC"
toastWarningBorderColorStringToast border color."#F08135"
toastErrorBgColorStringToast bg color."#FAE1DB"
toastErrorBorderColorStringToast border color."#D9100A"
toastSuccessTitleColorStringToast title color."#1F8722"
toastInfoTitleColorStringToast title color."#1F6587"
toastWarningTitleColorStringToast title color."#F08135"
toastErrorTitleColorStringToast title color."#D9100A"
toastSuccessTextColorStringToast text color."#1F8722"
toastInfoTextColorStringToast text color."#1F6587"
toastWarningTextColorStringToast text color."#F08135"
toastErrorTextColorStringToast text color."#D9100A"