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

@iqorlobanov/react-native-toast

v0.5.1

Published

Animated toast component for React Native.

Downloads

15

Readme

@iqorlobanov/react-native-toast

Animated toast component for React Native.

toast gif

Documentation

Installation

This component created by using react-native-reanimated and react-native-vector-icons. Make sure you have installed react-native-reanimated and react-native-vector-icons before start.

yarn add @iqorlobanov/react-native-toast
# or
npm install --save @iqorlobanov/react-native-toast

Usage


Render the ToastComponent in your app's entry file, as the LAST CHILD in the View hierarchy (along with any other components that might be rendered there):

// App.tsx
import { ToastComponent } from '@iqorlobanov/react-native-toast';

export default function App() {
  return (
    <>
      {/* ... */}
      <ToastComponent />
    </>
  );
}

Then use it anywhere in your app (even outside React components), by calling any Toast method directly:

// Foo.tsx
import { Toast, ToastType } from '@iqorlobanov/react-native-toast';
import { Button } from 'react-native';

export function Foo() {
  return (
    <Button
      title="Show toast"
      onPress={() => {
        Toast.show({
          title: 'Lorem Ipsum',
          description:
            'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
          type: ToastType.SUCCESS,
          visibilityTime: 5000,
        });
      }}
    />
  );
}

API


The Toast API consists of:

  1. methods that can be called directly on the Toast object
  2. props that can be passed to the ToastComponent component instance; they act as defaults for all Toasts that are shown

methods

show(options = {})

To show a Toast, call the show() method andd pass the options that suit your needs. Everything is optional, unless specified otherwise:

import { Toast } from '@iqorlobanov/react-native-toast';

Toast.show({
  title: 'Lorem Ipsum',
  description:
    'Lorem Ipsum is simply dummy text of the printing and typesetting industry.',
  type: ToastType.SUCCESS,
  visibilityTime: 5000,
});

The complete set of options is described below:

| option | description | required | type | default value | | ---------------- | ----------------------------------------------------------------------- | -------- | ----------- | ------------------- | | type | Toast type. Available values of: SUCCESS, INFO, WARNING, ERROR. | true | ToastType | ToastType.SUCCESS | | title | First line of text | true | string | | | description | Second line of text | false | string | | | visibilityTime | Number of milliseconds after which Toast automatically hides. | false | number | 5000 | | topOffset | Offset from the top of the screen (in px). Has effect only when | false | number | 10 | | withShadow | Enable shadow effect | false | boolean | true | | touchable | Hide toast on toch | false | boolean | true | | showLeftIcon | Show left icon component | false | boolean | true | | showRightIcon | Show close icon component | false | boolean | true |

hide()

To hide the current visible Toast, call the hide() method:

Toast.hide();

props

The following set of props can be passed to the ToastComponent component instance to specify certain defaults for all Toasts that are shown:

| prop | description | type | default value | | -------------------- | --------------------------- | ----------------- | ------------- | | titleStyle | Title text style | TextStyle | | | descriptionStyle | Description text style | TextStyle | | | style | Toast view style | ViewStyle | | | leftIconComponent | Custom left icon component | React.ReactNode | | | rightIconComponent | Custom right icon component | React.ReactNode | |

// App.tsx
import { ToastComponent } from '@iqorlobanov/react-native-toast';
import CustomRightIcon from './CustomRightIcon'

export default function App() {
  return (
    <>
      {/* ... */}
      <ToastComponent
        titleStyle={{
          fontSize: 16,
          color: 'black',
        }}
        descriptionStyle={{
          fontSize: 14,
          color: 'gray',
        }}
        rightIconComponent={<CustomRightIcon />}
      />
    </>
  );
}

License

MIT