Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-simple-toast

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-simple-toast - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

23

index.d.ts
declare var SimpleToast: {
// Toast duration constants
SHORT: number,
LONG: number,
SHORT: number;
LONG: number;
// Toast gravity constants
TOP: string,
BOTTOM: string,
CENTER: string,
TOP: string;
BOTTOM: string;
CENTER: string;
show: (message: string, duration?: number) => void,
show: (message: string, duration?: number, viewControllerBlacklist?: Array<string>) => void;
showWithGravity: (message: string, duration: number, gravity: string) => void
}
showWithGravity: (
message: string,
duration: number,
gravity: string,
viewControllerBlacklist?: Array<string>
) => void;
};
export default SimpleToast
export default SimpleToast;

@@ -15,9 +15,18 @@ import { NativeModules, ToastAndroid, Platform } from 'react-native';

show: function(message, duration) {
RCTToast.show(message, duration === undefined ? RCTToast.SHORT : duration);
show(message, duration, viewControllerBlacklist) {
RCTToast.show(
message,
duration === undefined ? RCTToast.SHORT : duration,
viewControllerBlacklist
);
},
showWithGravity: function(message, duration, gravity) {
RCTToast.showWithGravity(message, duration === undefined ? RCTToast.SHORT : duration, gravity);
showWithGravity(message, duration, gravity, viewControllerBlacklist) {
RCTToast.showWithGravity(
message,
duration === undefined ? RCTToast.SHORT : duration,
gravity,
viewControllerBlacklist
);
},
};
{
"name": "react-native-simple-toast",
"version": "1.0.0",
"version": "1.1.0",
"description": "Simple Toast for react-native. In Android it's just native toast, in iOS it's https://github.com/scalessec/Toast",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/vonovak/react-native-simple-toast.git",

@@ -1,2 +0,3 @@

# react-native-simple-toast [![npm version](https://badge.fury.io/js/react-native-simple-toast.svg)](https://badge.fury.io/js/react-native-simple-toast)
# react-native-simple-toast [![npm version](https://badge.fury.io/js/react-native-simple-toast.svg)](https://badge.fury.io/js/react-native-simple-toast)
React Native Toast component for both Android and iOS. It just lets iOS users have the same toast experience as on Android. Using [scalessec/Toast](https://github.com/scalessec/Toast) on iOS and the standard [ToastAndroid](http://facebook.github.io/react-native/docs/toastandroid.html) on Android;

@@ -11,3 +12,5 @@

react-native link react-native-simple-toast // only RN < 0.60
cd ios && pod install
```
then rebuild your project

@@ -17,3 +20,32 @@

```javascript
the module exposes the following functions:
```js
show: (message: string, duration?: number, viewControllerBlacklist?: Array<string>) => void,
```
```js
showWithGravity: (
message: string,
duration: number,
gravity: string,
viewControllerBlacklist?: Array<string>
) => void,
```
Note on `viewControllerBlacklist`: when presenting the Toast, we need to find the presented ViewController (VC). The Toast will be presented in that VC. For Example, let's say you're showing a `ReactNative.Modal` in your app - in that case, the presented VC is a `RCTModalHostViewController`.
If you present a Toast while that `Modal` is shown, and then hide the `Modal`, the Toast will disappear together with the `Modal`.
`viewControllerBlacklist` allows to say what VCs should not be considered when Toast is shown. This is to allow to work around issues like [#11](https://github.com/vonovak/react-native-simple-toast/issues/11) or [#13](https://github.com/vonovak/react-native-simple-toast/issues/13).
The values `viewControllerBlacklist` has been tested with are:
```js
['RCTModalHostViewController', 'UIAlertController'];
```
## Examples
```js
import Toast from 'react-native-simple-toast';

@@ -24,3 +56,7 @@

Toast.showWithGravity('This is a long toast at the top.', Toast.LONG, Toast.TOP)
Toast.showWithGravity('This is a long toast at the top.', Toast.LONG, Toast.TOP);
Toast.show('This is nicely visible even if you call this when an Alert is shown', Toast.SHORT, [
'UIAlertController',
]);
```

@@ -27,0 +63,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc