Giter VIP home page Giter VIP logo

toastify-react-native's Introduction

toastify-react-native

npm version

๐ŸŽ‰ toastify-react-native allows you to add notifications to your react-native app (ios, android) with ease. No more nonsense!

Demo

Screen_Recording_20220916-193212_Expo.Go.mp4

Features

  • Smooth enter/exit animations
  • Plain simple and flexible APIs
  • Resize itself correctly on device rotation
  • Swipeable
  • Easy to set up for real, you can make it work in less than 10sec!
  • Super easy to customize
  • RTL support
  • Swipe to close ๐Ÿ‘Œ
  • Can choose swipe direction
  • Super easy to use an animation of your choice. Works well with animate.css for example
  • Define behavior per toast
  • Pause toast by click on the toast ๐Ÿ‘
  • Fancy progress bar to display the remaining time
  • Possibility to update a toast
  • You can control the progress bar a la nprogress ๐Ÿ˜ฒ
  • You can display multiple toast at the same time
  • Dark and light mode ๐ŸŒ’
  • And much more !

Installation

$ npm install toastify-react-native

A complete example

App.js

import React from 'react'
import { StyleSheet, View, TouchableOpacity, Text } from 'react-native'
import ToastManager, { Toast } from 'toastify-react-native'

import Another from './Another'

const App = () => {
  const showToasts = () => {
    Toast.success('Promised is resolved')
  }

  return (
    <View style={styles.container}>
      <ToastManager />
      <Another />
      <TouchableOpacity
        onPress={showToasts}
        style={{
          backgroundColor: 'white',
          borderColor: 'green',
          borderWidth: 1,
          padding: 10,
        }}
      >
        <Text>SHOW SOME AWESOMENESS!</Text>
      </TouchableOpacity>
    </View>
  )
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
})

export default App

Another.js

import React from 'react'
import { StyleSheet, View, TouchableOpacity, Text } from 'react-native'
import { Toast } from 'toastify-react-native'
const Another = () => (
  <View style={styles.container}>
    <TouchableOpacity
      onPress={() => Toast.info('Lorem ipsum info', 'bottom')}
      style={styles.buttonStyle}
    >
      <Text>SHOW SOME AWESOMENESS!</Text>
    </TouchableOpacity>
  </View>
)

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  buttonStyle: {
    marginTop: 10,
    backgroundColor: 'white',
    borderColor: 'green',
    borderWidth: 2,
    padding: 10,
  },
})

export default Another

For a more complex example take a look at the /example directory.

Available props

Name Type Default Description
width number 256 Width of toast
height number 68 Height of the toast
style any null Style applied to the toast
textStyle any null Style applied to the toast content
position top, center or bottom top Position of toast
positionValue number 50 position value of toast
duration number 3000 The display time of toast.
animationStyle upInUpOut, rightInOut or zoomInOut upInUpOut The animation style of toast
animationIn string or object 'slideInRight' Toast show animation
animationOut string or object 'slideOutLeft' Toast hide animation
animationInTiming number 300 Timing for the Toast show animation (in ms)
animationOutTiming number 300 Timing for the toast hide animation (in ms)
backdropTransitionInTiming number 300 The backdrop show timing (in ms)
backdropTransitionOutTiming number 300 The backdrop hide timing (in ms)
hasBackdrop bool false Render the backdrop
backdropColor string 'black' The backdrop background color
backdropOpacity number 0.2 The backdrop opacity when the toast is visible

Available animations

Take a look at react-native-animatable to see the dozens of animations available out-of-the-box.

Acknowledgements

Pull requests, feedbacks and suggestions are welcome!

License

toastify-react-native is MIT licensed .

toastify-react-native's People

Contributors

jduhking avatar jonijuntto avatar meibrarhussain avatar noehernandez94 avatar zahidalidev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

toastify-react-native's Issues

Multiple toasts

I noticed in your description that you mentioned, "You can display multiple toasts at the same time." I'm curious about how this can be achieved. Could you please provide an example to illustrate the process? Thank you very much.

Close Icon

ios-close-outline
no longer exist on lib react-native-vector-icons

On ToastManager.js

<TouchableOpacity onPress={this.hideToast} activeOpacity={0.9} style={styles.hideButton}>
            <Icon name='ios-close-outline' size={22} color={Colors[theme].text} />
</TouchableOpacity>

replace with

close-outline

Reduce font size

Is there any way to reduce fontsize for toast?

I tried with <ToastManager style={{fontSize:12}} /> but it doesn't work.
Also can we make width as 100% rather giving a numeric value.

Unable to use toastify-react-native npm

Facing below issue after installing the subject package:

Error: Unable to resolve module react-native-responsive-fontsize from /Users/macintosh/Desktop/project-name/node_modules/toastify-react-native/components/ToastManager.js: react-native-responsive-fontsize could not be found within the project or in these directories: node_modules/toastify-react-native/node_modules node_modules ../../node_modules 2 | import Modal from 'react-native-modal' 3 | import React, { Component } from 'react' > 4 | import { RFPercentage } from 'react-native-responsive-fontsize' | ^ 5 | import { View, Text, Animated, Dimensions, TouchableOpacity } from 'react-native' 6 | 7 | import defaultProps from '../utils/defaultProps' RCTFatal __28-[RCTCxxBridge handleError:]_block_invoke _dispatch_call_block_and_release _dispatch_client_callout _dispatch_main_queue_drain _dispatch

Screenshot 2023-04-26 at 11 21 25 AM

Custom icons

Could you make it possible to use custom icons and icon styles (color, size, etc)?

Toastify Message showed behind React-Native Full Width Modal

I made ToastifyProvider like this

import React, { createContext, useContext, useState } from 'react';
import ToastManager, { Toast } from 'toastify-react-native';

// Create a context to manage toast state
const ToastContext = createContext<{
    showToast: (type:string, message: string) => void;
  }>({
    showToast: () => {},
  });

// Create a ToastProvider component
export const ToastProvider = ({ children }:any) => {

    const showToast = (type: string, message: string) => {
        switch(type) {
            case 'success':
                return Toast.success(message);
            case 'warn':
                return Toast.warn(message);
            case 'error':
                return Toast.error(message);
            default:
                break;
        }
    };

    return (
        <ToastContext.Provider value={{ showToast }}>
            {children}
            <ToastManager 
                width={307}
                height={58}
                animationStyle="rightInOut"
                duration={2000}
            />
        </ToastContext.Provider>
    );
};

// Create a custom hook to use the ToastProvider context
export const useToast = () => {
    return useContext(ToastContext);
};

And This is my App.tsx code

function App(): JSX.Element {
  return (
    <NativeBaseProvider>
      <ToastProvider>
        <NavigationContainer>
          <Stack.Navigator initialRouteName="Login">
            <Stack.Screen
              name='Login'
              component={TestLogin}
              options={{ headerShown: false }}
            />
            <Stack.Screen
              name="Valve"
              component={Valve}
              options={{
                title: "Valves",
                headerShown: false
              }}
            />
          </Stack.Navigator>
        </NavigationContainer>
      </ToastProvider>
    </NativeBaseProvider>
  );
}

And I am using FullScreen Modal in Valve Screen Component, but Toastify message showed behind Modal
Can anyone help me to show alert on React-Native Modal?

THIS LIBRARY DOESN'T WORK PROPERLY AND NOBODY RESPONDS TO ISSUES

This library simply doesn't work properly, TOAST doesn't appear in some components, there's no way to make a global configuration, I've already tried to create a context for it but it doesn't do anything, it still doesn't appear in some specific components, no error appears indicating the reason for it not appearing, as already mentioned in someone else's error below, the INFO type gives the following error WARN "ios-information-circle" is not a valid icon name for family "ionicons", simply poorly done, the devs who developed it She doesn't respond to issues, difficult. I do not recommend.

My CONTEXT

image

Issue running npm I when contributing

I am trying to contribute and I come across this error after cloning the repo and checking out to a new branch and attempting to perform npm install.

error

Does not work as a global component

I have to import it in all components for it to appear, I even have to import it within MODALS for it to appear, does it really work like this or is there another way?

Progress bar cannot run smoothly

Hi,

Thanks for the creating of this library, it is really helpful.
I got an issue about progress bar that cannot run smoothly, i set the duration to 3000 and after toast is finished, the keyboard will show up. Probably you can help me.

Thank you.

Screen.Recording.2021-12-08.at.11.56.45.mov

After installation facing issuue

error: Error: Unable to resolve module react-native-modal from E:\live_cafeapp\node_modules\toastify-react-native\components\ToastManager.js: react-native-modal could not be found within the project or in these directories:

Help Needed with Library Dependencies

Description:
Encountered issues with missing information while working on a project. Errors indicate the absence of essential dependencies, particularly related to modals and responsive font sizing.

Errors:

  1. react-native-modal could not be found within the project or in these directories:
    node_modules/toastify-react-native/node_modules
    node_modules
  2. react-native-responsive-fontsize could not be found within the project or in these directories:
    node_modules/toastify-react-native/node_modules
    node_modules

Fix:
I manually added the missing dependencies to make it work. Can we update the docs with clear install steps for these if these dependencies are needed in our project?

Info:

  • Library Version: 3.1.2
  • React Native Version: 0.69.2

RBSheet issue

how to make the toast appears over the backdrop of the RBSheet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.