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-toast-animated

v0.2.0

Published

An animated toast component for React Native

Downloads

9

Readme

react-native-toast-animated

An animated toast component for React Native

example

Installation

// Using npm
npm install react-native-toast-animated

// Using yarn
yarn add react-native-toast-animated

Usage

Wrap your App with ToastProvider component and pass your config object.

import {
  ToastProvider,
  ToastPosition,
  type ConfigType,
} from 'react-native-toast-animated';

...

const config: ConfigType = {
  position: ToastPosition.TOP,
};

...

return (
    <ToastProvider config={config}>
      ...
    </ToastProvider>
  );

Then create your toast using the useToast hook and now you can show it with show function.

import { useToast } from 'react-native-toast-animated';

...

const toast = useToast();

...

toast.show({
            type: 'success',
            text: 'This is a success toast',
            title: 'Success',
          })

Documentation

Config

A config object should be passed to <ToastProvider>. It contains all the necessary configuration for the Toast.

| Property | Required | Description | Type | Default value | --- | --- | --- | --- | --- | | position | true | Toast position: ToastPosition.TOP or ToastPosition.BOTTOM | ToastPosition | ToastPosition.TOP | | width | false | Toast width | FlexStyle['width'] | '90%' | | height | false | Toast height | FlexStyle['height'] || | duration | false | Duration before the toast automatically hides. Set to null if you don't want the toast to hide automatically | number | null | 5000 | | showCloseIcon | false | Show/hide the X button | boolean | true | | hideableByGesture | false | Set to false if you don't want the toast to be hidden with gesture.If set to true, you can hide the toast by dragging it to top if position is set to ToastPosition.TOP or to bottom if position is set to ToastPosition.BOTTOM | boolean | true | | colors | false | To respect your design system, you can specify the colors property.PS: colors specified here can be overriden by containerStyle, titleStyle, textStyle and closeIconStyle, | Colors (See next section) | (See next section) | | titleMaxLines | false | Maximum number of lines. It will truncate title if it exceeds this number. | number | 1 | | textMaxLines | false | Maximum number of lines. It will truncate text if it exceeds this number. | number | 2 | | containerStyle | false | Override container style | StyleProp || | titleStyle | false | Override title style | StyleProp || | textStyle | false | Override text style | StyleProp || | closeIconStyle | false | Override close icon style | StyleProp ||

Type

ConfigType type definition:

export type ConfigType = {
  position: ToastPosition;
  width?: FlexStyle['width'];
  height?: FlexStyle['height'];
  duration?: number | null;
  showCloseIcon?: boolean;
  hideableByGesture?: boolean;
  colors?: Colors;
  titleMaxLines?: number;
  textMaxLines?: number;
  containerStyle?: StyleProp<ViewStyle>;
  titleStyle?: StyleProp<TextStyle>;
  textStyle?: StyleProp<TextStyle>;
  closeIconStyle?: StyleProp<TextStyle>;
};

Colors

Colors type definition:

export type Colors = {
  background?: string;
  title?: string;
  text?: string;
  closeIcon?: string;
  borderColor?: {
    success: string;
    info: string;
    warning: string;
    error: string;
  };
};

Default values

export const colors = {
  background: '#1c1c1c',
  title: '#ffffff',
  text: '#ffffff',
  closeIcon: '#ffffff',
  borderColor: {
    success: '#24A148',
    info: '#0043ce',
    warning: '#ff832b',
    error: '#da1e28',
  },
};

useToast

The useToast hook returns the show function

const { show } = useToast();

show

show function takes an object of type ToastInfos as parameter

show({
      type: 'success', // required
      text: 'This is a success toast', // required
      title: 'Success', // optional
      onClick: () => console.log('Success'), // optional
    })

Type

export type ToastInfos = {
  text: string;
  type: ToastType;
  title?: string;
  onClick?: () => void;
};

Possible toast types:

type ToastType = 'success' | 'info' | 'warning' | 'error';

Contributing

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

License

MIT


Made with create-react-native-library