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-navigation-native-modal

v0.1.11

Published

React Navigation integration for React Native's Modal component

Downloads

223

Readme

react-navigation-native-modal

Build Status Version MIT License

React Navigation integration for React Native's Modal component. This navigator works like a Stack Navigator, but each screen is shown as a modal using the Modal component from React Native.

Currently the presentationStyle of pageSheet and formSheet are not usable on iOS because it's impossible to detect when they are closed via gesture. See https://github.com/facebook/react-native/issues/29319

Demo

Installation

npm install @react-navigation/native react-navigation-native-modal

Usage

To use this navigator, import it from react-navigation-native-modal:

import { createModalNavigator } from 'react-navigation-native-modal';

const Modal = createModalNavigator();

function MyModal() {
  return (
    <Modal.Navigator>
      <Modal.Screen name="Home" component={Home} />
      <Modal.Screen name="Notifications" component={Notifications} />
      <Modal.Screen name="Profile" component={Profile} />
      <Modal.Screen name="Settings" component={Settings} />
    </Modal.Navigator>
  );
}

Then you can navigate to any screen to show it as a modal:

navigation.navigate('Profile');

The first screen in the stack is always rendered as a normal screen and not as a modal. But any subsequent screens will be rendered as modals.

Options

All of the props available on Modal component can be specified in options to configure the screens in the navigator, except visible, onDismiss, onOrientationChange, onRequestClose and onShow.

Example:

<Modal.Screen
  name="Profile"
  component={ProfileScreen}
  options={{
    animationType: 'fade',
  }}
/>

Some of the defaults are different from the Modal component:

  • animationType is set to slide instead of none

Events

The navigator can emit events on certain actions. Supported events are:

orientationChange

This event is fired when the orientation changes while the modal is being displayed and on initial render. Same as the onOrientationChange prop.

It receives an object in the data property of the event, which contains the key orientation with the value portrait or landscape:

console.log(e.data) // { orientation: 'portrait' }

Example:

React.useEffect(() => {
  const unsubscribe = navigation.addListener('orientationChange', (e) => {
    // Do something
  });

  return unsubscribe;
}, [navigation]);

Only supported on iOS.

Helpers

The modal navigator adds the following methods to the navigation prop:

push

Pushes a new screen to top of the modal stack and navigate to it. The method accepts following arguments:

  • name - Name of the route to push onto the modal stack.
  • params - Screen params to merge into the destination route (found in the pushed screen through route.params).
navigation.push('Profile', { owner: 'Michaś' });

pop

Pops the current screen from the modal stack and navigates back to the previous screen. It takes one optional argument (count), which allows you to specify how many screens to pop back by.

navigation.pop();

popToTop

Pops all of the screens in the modal stack except the first one and navigates to it.

navigation.popToTop();

Gotchas

The modal navigator is always shown above other navigators since it renders a native modal. This means that if you have a regular stack navigator as the parent of the modal navigator and push a screen in the parent stack, it won't appear above the modal navigator.

So it's a good practice to always have the modal navigator at the root to avoid such issues instead of nesting it.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.