Socket
Socket
Sign inDemoInstall

@birdwingo/react-native-swipe-modal

Package Overview
Dependencies
521
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @birdwingo/react-native-swipe-modal

A versatile and smooth swipeable modal component for React Native applications.


Version published
Weekly downloads
650
increased by28.97%
Maintainers
1
Install size
4.27 MB
Created
Weekly downloads
 

Readme

Source

@birdwingo/react-native-swipe-modal

npm downloads npm version github release npm release

Features 🌟

🕶️ Swipe-to-Close Functionality: Easily close modals with a single swipe gesture, providing an intuitive user experience.

🎨 Customizable Appearance: Adjust the color, size, animation, and more to make it blend seamlessly with your application's design.

💃 Smooth Animations: Enjoy smooth and pleasing animations that offer a polished look and feel.

📱 Responsive Design: Adapts to various screen sizes and orientations, ensuring a consistent appearance across devices.

⚙️ Easy Integration: With minimal code, you can have Swipe Modal up and running in your application.

♿ Accessibility Support: Designed with accessibility in mind, allowing all users to interact with the modal effortlessly.

🌍 Cross-Platform Support: Works seamlessly on both iOS and Android, providing a unified experience.

About

react-native-swipe-modal is a customizable and animated modal component that can be used in React Native applications. It provides a smooth swipe-to-close functionality along with various configuration options to suit different use cases. It is used in the Birdwingo mobile app to show different kinds of popups and explanations.

Installation

npm install react-native-reanimated
npm install react-native-gesture-handler
npm install @birdwingo/react-native-swipe-modal

Usage

To use the SwipeModal component, you need to import it in your React Native application and include it in your JSX code. Here's an example of how to use it:

import React, { useRef } from 'react';
import { View, Text } from 'react-native';
import SwipeModal, { SwipeModalPublicMethods } from '@birdwingo/react-native-swipe-modal';


const YourComponent = () => {

  const modalRef = useRef<SwipeModalPublicMethods>(null);

  const showModal = () => modalRef.current?.show(); // Call this function to show modal
  const hideModal = () => modalRef.current?.hide(); // Call this function to hide modal

  return (
    <SwipeModal ref={modalRef}>
      <View>
        <Text>Swipe Modal</Text>
      </View>
    </SwipeModal>
  );

};

export default YourComponent;

Props

NameTypeDefault valueDescription
childrenReactNode|ReactNode[]requiredThe content to be rendered inside the modal.
bgstring'black'The background color of the modal.
showBarbooleantrueSet to true to display a bar at the top of the modal.
barColorstring'grey'The color of the bar at the top of the modal.
barContainerStyleViewStyle|ViewStyle[]Additional styles applied to bar container view.
maxHeight'max'|'auto'|number'max'The maximum height of the modal. If 'auto' maxHeight of modal will the height modal children need.
defaultHeightnumbermaxHeightThe default height of the modal.
fixedHeightbooleanfalseSet to true if you want to maintain a fixed height for the modal. It means that the height of the modal will get back to the initial position after swipe, if modal was not closed .
styleViewStyle|ViewStyle[]Additional styles to be applied to the modal.
closeTrigger'swipeDown'|'minHeight''swipeDown'The trigger to close the modal. 'swipeDown' means that modal will close when modal was swiped down by closeTriggerValue. 'minHeight' means that modal will close when height of modal is less than closeTriggerValue.
closeTriggerValuenumber10The value that triggers the modal to close when using the closeTrigger.
scrollEnabledbooleanfalseSet to true if you want the modal content to be scrollable.
scrollContainerStyleViewStyle|ViewStyle[]Additional styles to be applied to the scrollable container.
scrollContainerPropsScrollView['props']Additional props to be passed to the internal ScrollView component.
headerComponentReactNodeA custom component to be displayed at the top of the modal. It's placed above scroll content
footerComponentReactNodeA custom component to be displayed at the bottom of the modal. It's placed under scroll content
disableSwipebooleanfalseSet to true if you don't want allow gesture.
visiblebooleanfalseDefault value for modal visibility. It can be changed dynamically using public methods.
onShow() => voidA callback function that will be triggered when the modal is shown.
onHide() => voidA callback function that will be triggered when the modal is hidden.
closeOnEmptySpacebooleantrueSet to true to close the modal when the user taps outside the modal's content.
closeOnPressBackbooleantrueSet to true to close the modal when the user presses the back button (Android only).
animationDurationnumber300The duration of the modal's opening and closing animations, in milliseconds.
closeSpaceVisibilitynumber (0 - 1)0.6A number representing the opacity of empty space, that will close the modal if closeOnEmptySpace is enabled.
topOffsetnumber0Determines the amount of space that the swipeable content will be offset from the top edge of window.
containerPropsViewPropsAdditional props to be applied to the container.
hideKeyboardOnShowbooleantrueSet to true if you want to hide keyboard on show modal if was opened.
wrapInGestureHandlerRootViewbooleanfalseSet to true if you want to wrap content in to GestureHandlerRootView (required if you want to use modal inside react-native Modal component).
useKeyboardAvoidingViewbooleantrueSet to false if you want to show keyboard over the modal content.

Public Methods

NameDescription
showCall this method to show the modal.
hideCall this method to hide the modal.

Sponsor

react-native-swipe-modal is sponsored by Birdwingo.
Download Birdwingo mobile app to see react-native-swipe-modal in action!

Keywords

FAQs

Last updated on 01 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc