npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-modalview

v0.1.7

Published

An advanced and composable Modal component for react-native

Downloads

11

Readme

react-native-modalview

npm version styled with prettier

An advanced and composable Modal component for react-native

Features

  • Very modular through composable components
  • all features are easy to toggle on/off via props
  • Smooth open/close animations
  • Extendable with own animations/easings/...
  • Customizable backdrop opacity, color, duration and easing
  • Event listeners for the modal states onOpen, onOpened, onClose, onClosed

Demo

coming soon

Setup

This library is available on npm, install it with: npm install --save react-native-modalview or yarn add react-native-modalview.

Usage

Use all of the features or toggle features on and off via props;

import React, { Component } from 'react'
import { Text, TouchableOpacity, View } from 'react-native'
import Modal from 'react-native-modalview'

export default class ModalDemo extends Component {
  state = {
    showModal: false
  }

  _showModal = () => this.setState({ showModal: true })

  _hideModal = () => this.setState({ showModal: false })

  render () {
    const { showModal } = this.state;
    return (
      <View style={{ flex: 1 }}>
        <TouchableOpacity onPress={this._showModal}>
          <Text>Show Modal</Text>
        </TouchableOpacity>
        <Modal 
          open={showModal}
          backdrop={true}
          swipeToDismiss={true}
          onClosed={this._hideModal}
        >
          <View style={{ backgroundColor: '#fff' }}>
            <Text>Hello!</Text>
          </View>
        </Modal>
      </View>
    )
  }

}

If you don't need all the functionality like backdrop or swipeToDismiss you can also import the base components and compose the Modal without this functionality or extend it with your own.

import { ModalBase, withBackdrop} from 'react-native-modalview'
import { compose } from 'ramda';

const Modal = compose(
  withBackdrop, 
)(ModalBase);

Props

ModalBase

| Name | Type| Default | Description | | --- | --- | --- | --- | | open | bool | false | open/close the modal | | disabled | bool | false | disable open/closing of the modal | | children | node | REQUIRED | The modal content | | style | any | null | Style applied to the modal | | positionVertical | string | 'center' | vertical position of the modal. possible values: 'start', 'center', 'end' | | positionHorizontal | string | 'center' | horizontal position of the modal. possible values: 'start', 'center', 'end' | | animation | string | 'slideBottom' | convenience prop to set the animation type for open/close. | | animationDuration | number | 300 | convenience prop to set the animation duration for open/close/backdrop | | animationEasing | string | 'easeOut' | convenience prop to set the animation easing for open/close/backdrop | | animationIn | string | animation | animation type for opening the modal | | animationInDuration | string | animationDuration | animation duration for opening the modal | | animationInEasing | string, func | animationEasing | animation easing for opening the modal | | animationOut | string | animation | animation type for closing the modal | | animationOutDuration | string | animationDuration | animation duration for closing the modal | | animationOutEasing | string, func | animationEasing | animation easing for closing the modal | | animationUseNativeDriver | bool | false | use useNativeDriver for animations | | overlay | bool | false | wrap view in react-native Modal to present content above everything else | | testID | string | null | Used to locate this view in end-to-end tests. |

withBackdrop

| Name | Type| Default | Description | | --- | --- | --- | --- | | backdrop | bool | false | show/hide backdrop | | backdropClickToClose | bool | false | close modal by clicking on backdrop | | backdropColor | string | #00000099 | change backdrop color | | backdropAnimationDuration | string | animationDuration | animation duration for opening and closing the backdrop | | backdropAnimationEasing | string, func | animationEasing | animation easing for opening and closing the backdrop |

withSwipeToDismiss

| Name | Type| Default | Description | | --- | --- | --- | --- | | swipeToDismiss | bool | false | enable/disable swipe-to-dismiss functionality | | swipeThreshold | number | 50 | threshold to reach in pixels to close the modal | | swipeArea | number | null | width/height in pixels of the swipeable area. By default the whole modal is swipeable. |

Events

| Name | Type| Default | Description | | --- | --- | --- | --- | | onLayout | func | null | invoked on mount and layout changes | | onContentLayout | func | null | invoked when content layout changes | | onClose | func | null | invoked when the modal starts closing | | onClosed | func | null | invoked when the modal is closed completely | | onOpen | func | null | invoked when the modal starts opening | | onOpened | func | null | invoked when the modal is opened completely |

Animations

  • fade
  • slideBottom
  • slideTop
  • slideRight
  • slideLeft
  • scaleBackground
  • scaleForeground
  • custom animation func

Easings

  • linear
  • easeIn
  • easeOut
  • easeInOut
  • easeInQuad
  • easeOutQuad
  • easeInOutQuad
  • easeInCubic
  • easeOutCubic
  • easeInOutCubic
  • easeInSine
  • easeOutSine
  • easeInOutSine
  • easeInCirc
  • easeOutCirc
  • easeInOutCirc
  • easeInExpo
  • easeOutExpo
  • easeInOutExpo
  • easeInBounce
  • easeOutBounce
  • easeInOutBounce
  • easeInQuart
  • easeOutQuart
  • easeInOutQuart
  • easeInQuint
  • easeOutQuint
  • easeInOutQuint
  • easeInElastic
  • easeOutElastic
  • easeInOutElastic
  • easeInBack
  • easeOutBack
  • easeInOutBack
  • custom easing func

TODO

  • [ ] usage examples
  • [ ] unit-tests
  • [ ] demo gifs