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-factory

v1.8.9

Published

🍞 This module is about displaying Toasts in React Native.

Downloads

5

Readme

react-native-toast-factory

npm version npm downloads Build Status Platforms Issues Expo

Versión: v1.8.8

Descripción

🏭react-native-toast-factory is a Toast notification library for React Native applications. It provides an easy and customizable way to display brief, non-intrusive messages in your app. The library supports various types of messages, such as errors and successes, with simple customization options to fit your app's design.

Features

  • 🎉Toast Notifications: Display messages on the screen in a non-intrusive way.
  • Toast Types: Supports notification types, such as errors and success.
  • Flexible Configuration: Customize the colors, size, and styles of the toasts.
  • Easy Integration: Install and use in your project with ease.
  • Contexto Global con Zustand🌐: Use Zustand to manage the global state of the toasts!.
  • Animations with react-native-reanimated: Integrate smooth animations for a better user experience.
  • Multiple Toast Themes🌙: Supports differents toast themes, including dark mode and custom styles.

Installation

To install the library, run the following command:

npm install react-native-toast-factory

Ejemplo de Uso

  1. Configurar el Toast Provider (Toaster):

    make sure to add the Toaster at the entry point of your application so that toast can be rendered there:

    import React from 'react';
    import { View, Text } from 'react-native';
       
    import { Toaster } from 'react-native-toast-factory'; // Ensure you import the Toaster component
       
    const App = () => (
       
        <View style={{ flex: 1 }}>
          <Toaster /> {/* Add the Toaster at the top of your app */}
          <Text>My App</Text>
          {/* Other components */}
        </View>
       
    );
       
    export default App;
  2. Display a Toast:

Use the methods toast.success, toast.error, toast.info, toast.warning, and toast.loading to display toasts from anywhere in your application.

These methods allow you to show messages with different types of notifications and customizable settings. Below is an example:

 import React from 'react';
 import { Button, View } from 'react-native';
 import { toast } from 'react-native-toast-factory';
 
 const ExampleComponent = () => {
   const showSuccessToast = () => {
     toast.success('Operation completed successfully.', {
       title: 'Success', // Toast title (optional)
       position: 'top-right', // Toast position (optional)
       duration: 4000, // Toast duration in milliseconds (optional)
       progress: true, // Show progress indicator (optional)
       border: true, // Show a border around the toast (optional)
       styles: {
         backgroundColor: '#28a745', // Custom background color
         borderColor: '#155724', // Custom border color
         titleColor: '#fff', // Custom title color
         textColor: '#ddd', // Custom text color
         progressColor: '#ffc107', // Custom progress indicator color
       },
     });
   };
   toast.success("Thanks for visiting us!", { toastStyle: 'dark', icon: '🚀'})
 
   const showErrorToast = () => {
     toast.error('There was a problem with the operation.', {
       title: 'Error',
       position: 'center',
       duration: 2500,
       icon: '🚫', // Custom icon (emoji)
       styles: {
         backgroundColor: '#dc3545', // Custom background color
         borderColor: '#721c24', // Custom border color
         titleColor: '#fff', // Custom title color
         textColor: '#f8d7da', // Custom text color
       },
     });
   };
 
   // Real-world example
   const sendData = () => {
     toast.loading("Loading...", {
       id: "loadData",
       duration: 2000,
       position: top, // Persistent state if loading changes to success
       toastStyle: "dark", // This prop is also persistent
       icon: '⏳', // Custom icon (emoji)
     });
     try {
       const { success, message } = axios.post('https://....');
       if (success) { 
         toast.info(message, { id: 'loadData', title: 'Success!' }); // Inherits position and toastStyle
       } else {
         // toast ...
       }
     } catch(error) {
         // toast ...
     }
   };
   
   return (
     <View>
       <Button title="Show Success" onPress={showSuccessToast} />
       <Button title="Show Error" onPress={showErrorToast} />
     </View>
   );
 };
 
 export default ExampleComponent;

Prop Properties

| Property | Type | Description | |----------------------|---------------------------------------------------------------|----------------------------------------------------------------------------------------------------------| | id | number (optional) | Unique identifier for the toast. | | title | string (optional) | Title of the toast. | | duration | number (optional) | Duration of the toast in milliseconds. | | position | 'top' - 'bottom' - 'center' - 'top-left' - 'top-right' - 'bottom-left' - 'bottom-right' (optional) | Screen position where the toast will appear. | | toastStyle | 'primary' - 'secondary' - 'primaryDark' - 'dark' (optional) | Style of the toast. | | animationType | 'fade' - 'slide' - 'bounce' (optional) | Type of toast animation. | | animationInDuration | number (optional) | Duration of the animation in milliseconds. | | animationOutDuration | number (optional) | Duration of the animation in milliseconds. | | progress | boolean (optional) | Indicates if the progress bar is displayed. | | icon | string (optional) | Emoji or character to display as an icon in the toast. | | border | boolean (optional) | Indicates if a border is displayed around the toast. | | inheritStyles | boolean (optional) | Indicates if styles from the toast with the same id are inherited. |

Custom Style Properties

| Property | Type | Description | |---------------------|------------------------------------------------------------------|---------------------------------------------------------------------------------------------| | titleColor | string (optional) | Color of the toast title. | | textColor | string (optional) | Color of the toast text. | | titleSize | number (optional) | Font size of the toast title. | | textSize | number (optional) | Font size of the toast text. | | backgroundColor | string (optional) | Background color of the toast. | | borderRadius | number (optional) | Border radius of the toast corners. | | borderColor | string (optional) | Border color of the toast. | | iconSize | number (optional) | Size of the icon within the toast. | | iconStyle | 'solid' - 'outline' - 'default' (optional) | Style of the icon in the toast. | | loadingColor | string (optional) | Color of the loading indicator if a loading toast is shown. | | progressColor | string (optional) | Color of the toast progress bar. | | width | number (optional) | Custom width of the toast. | | opacity | number (optional) | Indicates the opacity of the background. | | height | number (optional) | Custom height of the toast. | | top | number (optional) | Custom top position of the toast on the screen. | | bottom | number (optional) | Custom bottom position of the toast on the screen. | | left | number (optional) | Custom left position of the toast on the screen. | | right | number (optional) | Custom right position of the toast on the screen. |