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

rn-toast-zavatta

v0.0.2

Published

A react native module to show toast like android, it works on iOS and Android.

Downloads

5

Readme

react-native-easy-toast

A react native module to show toast like android, it works on iOS and Android.

Getting started

Add rn-toast-zavatta to your js file.

import Toast from 'rn-toast-zavatta'

Inside your component's render method, use Toast:

 render() {
         return (
             <View style={styles.container}>
                 ...
                 <Toast ref="toast"/>
             </View>
         );
 }

Note: Add it in the bottom of the root view.

Then you can use it like this:

 this.refs.toast.show('hello world!');

That's it, you're ready to go!

show a toast, and execute callback function when toast close it:

    this.refs.toast.show('hello world!', 500, () => {
        // something you want to do at close
    });

Show a toast forever until you manually close it:

 this.refs.toast.show('hello world!', DURATION.FOREVER);

Or pass an element:

    this.refs.toast.show(<View><Text>hello world!</Text></View>);

// later on: this.refs.toast.close('hello world!');


Optional you can pass a delay in seconds to the close()-method:
```javascript
 this.refs.toast.close('hello world!', 500);

Currently, the default delay for close() in FOREVER-mode is set to 250 ms (or this.props.defaultCloseDelay, which you can pass with)

 <Toast ... defaultCloseDelay={100} />

Basic usage

render() {
        return (
            <View style={styles.container}>
                <TouchableHighlight
                    style={{padding: 10}}
                    onPress={()=>{
                        this.refs.toast.show('hello world!');
                    }}>
                    <Text>Press me</Text>
                </TouchableHighlight>
                <Toast ref="toast"/>
            </View>
        );
    }

Custom Toast

render() {
        return (
            <View style={styles.container}>
                <TouchableHighlight
                    style={{padding: 10}}
                    onPress={()=>{
                        this.refs.toast.show('hello world!',DURATION.LENGTH_LONG);
                    }}>
                    <Text>Press me</Text>
                </TouchableHighlight>
                <Toast
                    ref="toast"
                    style={{backgroundColor:'red'}}
                    position='top'
                    positionValue={200}
                    fadeInDuration={750}
                    fadeOutDuration={1000}
                    opacity={0.8}
                    textStyle={{color:'red'}}
                />
            </View>
        );
    }

More Usage:

GitHubPopular

API

Props | Type | Optional | Default | Description ----------------- | -------- | -------- | ----------- | ----------- style | View.propTypes.style | true | {backgroundColor: 'black',opacity: OPACITY,borderRadius: 5,padding: 10,} | Custom style toast position | PropTypes.oneOf(['top','center','bottom',]) |true | 'bottom' | Custom toast position positionValue | React.PropTypes.number | true | 120 | Custom toast position value fadeInDuration | React.PropTypes.number | true | 500 | Custom toast show duration fadeOutDuration | React.PropTypes.number | true | 500 | Custom toast close duration opacity | React.PropTypes.number | true | 1 | Custom toast opacity textStyle | View.propTypes.style | true | {color:'white'} | Custom style text

Method | Type | Optional | Description ----------------- | -------- | -------- | ----------- show(text, duration, callback) | function | false | show a toast,unit is millisecond,and do callback close() | function | - | start the close timer

Contribution

Issues are welcome. Please add a screenshot of bug and code snippet. Quickest way to solve issue is to reproduce it on one of the examples.

Pull requests are welcome. If you want to change API or making something big better to create issue and discuss it first.


MIT Licensed