1.1.1 • Published 2 years ago

react-native-modal-reanimated v1.1.1

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

This is a custom modal with reanimated. My build versions: 1- react-native-reanimated: 2.14.4

Installation

  npm install react-native-modal-reanimated

Doc

react-native-reanimated

Usage

    import React, { useState } from "react";
    import { SafeAreaView, Button } from "react-native";
    import Modal from "react-native-modal-reanimated";

    const [isOpen, setIsOpen] = useState(false);

    const handleClose = () => {
        setIsOpen(false);
    };

    const handleOpen = () => {
        setIsOpen(true);
    };

    const okButtonOnPress = () => {
        console.log("ok button pressed!");
        setIsOpen(false);
    };

    const noButtonOnPress = () => {
        console.log("no button pressed!");
        setIsOpen(false);
    };

    const yesButtonOnPress = () => {
        console.log("yes button pressed!");
        setIsOpen(false);
    };

    <SafeAreaView style={{ flex: 1 }}>
        <Button title="Open Modal" onPress={handleOpen} />

        <Modal
            isOpen={isOpen}
            onPress={handleClose}
            from="top"
            damping={true}
            duration={300}
            type="success" // success - info - warning - error
            title="Modal Title!"
            text="Modal Text."
            okButtonText={"Ok"}
            noButtonText={"No"}
            yesButtonText={"Yes"}
            openModalBgColor="gray"
            backgroundOpacity={0.5}
            twoButton={true}
            width="80%"
            height="35%"
            //containerBgColor="#DEF1D7" Automatically gives its own color for each type
            //containerBorderColor="#1F8722" Automatically gives its own color for each type
            containerBorderWidth={1}
            containerBorderRadius={15}
            containerPadding={10}
            containerIconSize={80}
            okButtonBgColor={"gray"}
            noButtonBgColor={"gray"}
            yesButtonBgColor={"gray"}
            buttonMinWidth={"30%"}
            buttonHeight={35}
            buttonBorderRadius={10}
            titleColor={"black"}
            titleSize={15}
            textColor={"black"}
            textSize={13}
            buttonTextColor={"white"}
            buttonTextSize={14}
            buttonTextBold={true}
            okButtonOnPress={okButtonOnPress}
            noButtonOnPress={noButtonOnPress}
            yesButtonOnPress={yesButtonOnPress}
        />
    </SafeAreaView>;

API

proptypedescriptiondefault
isOpenBooleanModal show.false
onPressFuncModal close onPress.null
fromStringModal from."top"
dampingBooleanModal damping.true
durationNumberModal duration.300
typeStringModal type."success"
titleStringModal title."Non"
textStringModal text."Non"
okButtonTextStringModal okButtonText."Non"
noButtonTextStringModal noButtonText."Non"
yesButtonTextStringModal yesButtonText."Non"
openModalBgColorStringModal bg color"gray"
backgroundOpacityNumberModal background opacity.0.5
twoButtonBooleanModal one or two button.true
widthStringModal width."80%"
heightStringModal height."35%"
containerBgColorStringModal bg color."#DEF1D7"
containerBorderColorStringModal border color."#1F8722"
containerBorderWidthNumberModal border width.1
containerBorderRadiusNumberModal border radius.15
containerPaddingNumberModal padding.10
containerIconSizeNumberModal icon size.80
okButtonBgColorStringModal btn bg color."gray"
noButtonBgColorStringModal btn bg color."gray"
yesButtonBgColorStringModal btn bg color."gray"
buttonMinWidthStringModal btn min width."30%"
buttonHeightNumberModal btn height.35
buttonBorderRadiusNumberModal btn border radius.10
titleColorStringModal title color."black"
titleSizeNumberModal title size.15
textColorStringModal text color."black"
textSizeNumberModal text size.13
buttonTextColorStringModal text color."white"
buttonTextSizeNumberModal text size.14
buttonTextBoldBooleanModal text bold.true
okButtonOnPressFuncModal ok btn onPress.null
noButtonOnPressFuncModal no btn onPress.null
yesButtonOnPressFuncModal yes btn onPress.null