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-common/toast

v0.1.3

Published

This component provides a simple and customizable toast notification system for React Native applications. It uses `react-native-reanimated` for animations and `react-native-screens` for overlay support.

Downloads

82

Readme

@rn-common/toast

This component provides a simple and customizable toast notification system for React Native applications. It uses react-native-reanimated for animations and react-native-screens for overlay support.

Features

  • Customizable Toast Styles: Define custom styles for different types of toasts.
  • Animation Support: Includes slide-in and slide-out animations using react-native-reanimated.
  • Auto Dismiss: Toasts automatically dismiss after a specified duration.
  • Cross-Platform Support: Works on both iOS and Android with platform-specific optimizations.

Installation

Install using:

npx expo install @rn-common/toast react-native-reanimated react-native-safe-area-context react-native-screens

Usage

Importing the Component

import Toast from '@rn-common/toast'

Setting Up the Toast Provider

Place the Toast.Provider component at the root of your app, preferably at a high level in the component tree. Make sure to wrap the Toast.Provider component inside a SafeAreaProvider from react-native-safe-area-context to ensure the toast is displayed correctly.

import React from 'react'
import { SafeAreaProvider } from 'react-native-safe-area-context'
import Toast from '@rn-common/toast'

export default function App() {
  const toastConfig = {
    duration: 4000,
    toastMap: {
      success: {
        indicatorStyle: { backgroundColor: 'green' },
        textStyle: { color: 'white' },
      },
      error: {
        indicatorStyle: { backgroundColor: 'red' },
        textStyle: { color: 'white' },
      },
    },
  }

  return (
    <SafeAreaProvider>
      {/* Your other app components */}
      <Toast.Provider config={toastConfig} />
    </SafeAreaProvider>
  )
}

Showing a Toast

To show a toast, call the Toast.show method with the desired type and message:

import Toast from '@rn-common/toast'

// Example usage:
Toast.show('success', 'This is a success message!')
Toast.show('error', 'This is an error message!')

Configuration

The Toast.Provider accepts a config prop to customize toast behavior:

  • duration (optional): Duration in milliseconds for how long the toast should be visible. Defaults to 3000 ms.
  • toastMap: An object mapping toast types to their styles. Each entry can have indicatorStyle and textStyle properties.

Styling

Customize the styles by modifying the toastMap configuration:

  • indicatorStyle: Style for the indicator on the left side of the toast.
  • textStyle: Style for the toast message text.