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-global-modal-2

v1.3.0

Published

๐ŸŒ Global modal and callable from anywhere on the app for React Native

Downloads

329

Readme

React Native Global Modal

npm version npm Platform - Android and iOS License: MIT styled with prettier

Installation

Add the dependency:

npm i react-native-global-modal-2

Peer dependencies

"react-native-modal": "^13.0.1"

Usage

Import

import GlobalModal, { ModalController } from "react-native-global-modal-2"

Fundamental Usage

In App.tsx or wherever your root is, simply put the GlobalModal to root You can open it with custom ModalData with ModalController

Note: This is just an example of the usage

<NavigationContainer>
  <MainStack/>
  <GlobalModal/>
</NavigationContainer>

Call/control the animated modal with ModalController

import { ModalController, ModalData } from "react-native-global-modal-2"

// Example of ModalData
// You can customize the modal as you want with this format
// **Custom layout** option is also available!
const data: ModalData = {
  title: 'Update available',
  description: 'A new software version is available for download',
  primaryButtonText: 'Update',
  outlineButtonText: 'Not now',
  titleProps: {
    imageSource: require('./assets/cross.png'),
  },
  onPrimaryButtonPress: () => {},
  onOutlineButtonPress: () => {},
};
// Show
ModalController.show(data);
// Hide
ModalController.hide()

Custom Layout Usage

You can completely use your own layout with customLayout

import { ModalController, ModalData } from "react-native-global-modal-2"


const data: ModalData = {
  customLayout: (
    <View
      style={{
        borderRadius: 16,
        paddingTop: 24,
        paddingLeft: 24,
        paddingRight: 24,
        paddingBottom: 16,
        backgroundColor: '#fff',
      }}>
      <Text>Hello</Text>
    </View>
  ),
};
ModalController.show(data);

Customized Example

You can use any props from react-native-modal with prop drilling

<GlobalModal
  animationIn="fadeIn"
  animationOut="fadeOut"
  onBackdropPress={ModalController.hide}
/>

Example Project ๐Ÿ˜

You can check out the example project ๐Ÿฅฐ

Simply run

  • npm i
  • react-native run-ios/android

should work of the example project.

Configuration - Props

Fundamentals

| Property | Type | Default | Description | |----------------------|:--------:| :-------: |-------------------------------------------------| | title | string | undefined | change the title | | description | string | undefined | change the descrition | | primaryButtonText | string | undefined | change the primary button's text | | onPrimaryButtonPress | function | undefined | set function when the primary button is pressed | | onOutlineButtonPress | function | undefined | set function when the primary button is pressed |

Customization (Optionals)

| Property | Type | Default | Description | | -------------- |:-----------:|:---------:|-------------------------------------------------------------------| | style | ViewStyle | default | set or override the style object for the main container | | buttonsContainerStyle | ViewStyle | default | set or override the style object for the buttons' container style | | TouchableComponent | component | Pressable | set your own component instead of default Pressable component | | buttonProps | ButtonProps | default | change button's props (primary button) | | outlineButtonProps | OutlineButtonProps | default | change button's props (outline button) |

Customization [Button] Component

| Property | Type | Default | Description | |--------------------|:---------:|:---------:|--------------------------------------------------------| | title | string | undefined | change the title | | onPress | function | undefined | set your function | | style | ViewStyle | default | set or override the style object for the main container | | textStyle | TextStyle | default | set or override the style object for the text style |

Customization [OutlineButton] Component

| Property | Type | Default | Description | |--------------------|:---------:|:---------:|--------------------------------------------------------| | title | string | undefined | change the title | | onPress | function | undefined | set your function | | style | ViewStyle | default | set or override the style object for the main container | | textStyle | TextStyle | default | set or override the style object for the text style |

Future Plans

  • [x] ~~LICENSE~~
  • [ ] More built-in modal types
    • [ ] Notification Type
    • [ ] One Button
    • [ ] One Outline Button
  • [x] ~~Custom Layout Feature~~
  • [ ] More and better screenshots
  • [ ] Write an article about the lib on Medium

Credits

I inspired from Roycechua's global modal example Thank you so much Roycechua ๐Ÿ˜

I heavily inspired the design by Patrick Marx Thank you so much sir ๐Ÿฅณ

Author

FreakyCoder, [email protected]

License

React Native Global Modal is available under the MIT license. See the LICENSE file for more info.