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

@fugood/react-native-call-modal

v0.0.19

Published

This module let you use api call to open Modal and provide some basic panel most commonly.

Downloads

23

Readme

React Native Call Modal: Programmatically modal component control

Since react native is a property driven framework (It's really great!). Every component have to locate within render function, and control by props. Even THE special Modal component is not an exception.

// Render function
<Madal visible={this.state.visible}>
  <Text>{'Show me the MODAL!'}</Text>
</Modal>

// Some other place
handleSomeThingPress = () => {
  this.setState({
    visible: true,
  });
}

Now we got a empty modal, if you want more feature with this modal... Good lock!

But sometimes we just want simply call confirm() then show panel and blocking the code wait user's response.

React Native Call Modal is born for this, this lib not only give you a callable modal but also provide you a set of modal utilities like: alert(), confirm(), prompt(). And it will add more useful feature for you.

Get Started

Step 1

Install react-native-call-modal

npm i @fugood/react-native-call-modal --save

Step 2

Initialize the provider to put the modal component at top.

// At your root component
import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import { CallModal, CallModalUtil, connectCallModal } from '@fugood/react-native-call-modal';

@connectCallModal
export default class App extends Component {
  ...
}

AppRegistry.registerComponent('App', () => App);

Step 3

Call for use

// Any where you like just call
await CallModalUtil.alert('Show me the ALERT');
console.log('User press OK');

const result = await CallModalUtil.confirm('Sure to logout?');
console.log(`Answer: ${result}`);

const name = await CallModalUtil.prompt('Enter your name');
console.log(`Hello: ${name}`);

Now you can see an beautiful modal (maybe...) jump out screen, with an OK button and custom message. Until user press the OK button the second line console.log will be execute.

If a simple title modal can not meet you, keep going!

Advanced Usage

First argument can be a string or object, you can give an object to get more control.

Alert

| Name | Type | Description | Default | |---------|--------|----------------------------------|---------| | title | string | Title text with bold font weight | | | message | string | Body text | | | okText | string | Text show on confirm button | "OK" |

Confirm

| Name | Type | Description | Default | |-------------|--------|----------------------------------|----------| | title | string | Title text with bold font weight | | | message | string | Body text | | | okText | string | Text show on confirm button | "OK" | | cancelText | string | Text show on cancel button | "CANCEL" |

Prompt

| Name | Type | Description | Default | |--------------------------|--------|-----------------------------------------------------------------------------------|----------| | title | string | Title text with bold font weight | | | message | string | Body text | | | okText | string | Text show on confirm button | "OK" | | cancelText | string | Text show on cancel button | "CANCEL" | | autoSubmit | bool | When select use to disable OK button | false | | inputType | string | One of text, select, checkbox, action, question | "text" | | value (text) | string | Default value of prompt, this must be a string value | "" | | value (select, checkbox) | array | Default value of prompt, this must be an array of { key: , value: } | [] | | value (action) | array | Default value of prompt, this must be an array of { key: , value: , onSelect: } | [] | | value (question) | array | Default value of prompt, this must be an array of { key: , value: , title: } | [] |

Customize Modal Usage

If you want customize all your modal and just want we open/close the modal for you. You can use CallModal.show() to get things done.

// Notice: here is CallModal not CallModalUtil
CallModal.show({
  renderFunction: () => <View style={{width: 200, height: 300, backgroundColor: '#F00'}}><Text>{'Hello World!!!'}</Text></View>,
  backgroundColor: '#FF0',
  closeWhenPressBackground: true,
});

// Or a react class
CallModal.show({
  renderFunction: class extends Component {
    handleSubmit = () => {
      this.props.requestCloseModal();
    };
    render() {
      return (
        <View style={{width: 200, height: 300, backgroundColor: '#F00'}}>
          <TouchableWithoutFeedback onPress={this.props.handleSubmit}>
            ...
          </TouchableWithoutFeedback>
        </View>
      )
    }
  }
});

Live Demo

Exponent Live Demo

Exponent Live Demo

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Roadmap

  • [x] Basic modal
  • [ ] Test coverage
  • [ ] Custom modal
  • [ ] Custom container, title, item, button render function
  • [ ] QRCode modal

Known Issues

History

TODO: Write history

Thanks

Inspired by:

License

MIT