Skip to content
项目

vonovak/react-native-simple-toast

在 GitHub 查看

关于

适用于 React Native 的跨平台 Toast 体验

网站与应用开发

这些数字如何统计

实测星标增长

24小时
0
7天
0
15天
0
1个月
正在收集历史

各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。

README.md

原文

react-native-simple-toast npm version

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 on iOS and the React Native's ToastAndroid on Android.

Summary

✅ supports both old and new architecture (RN >= 0.71 is required for new arch)

✅ extremely simple fire-and-forget api, same as ToastAndroid

✅ renders on top of Modals and Alerts

✅ avoids keyboard

✅ customizable styling

Screenshots

Expand for more screenshots

Install

yarn add react-native-simple-toast
cd ios && pod install

then rebuild your project

Usage

the module exposes the following functions, same as ToastAndroid, with extra configuration parameter for iOS only:

import Toast from 'react-native-simple-toast';

Toast.show(message, duration, options);

Toast.showWithGravity(message, duration, gravity, options);

Toast.showWithGravityAndOffset(
  message,
  duration,
  gravity,
  xOffset,
  yOffset,
  options,
);

exported duration and positioning constants:

import Toast from 'react-native-simple-toast';

Toast.LONG;
Toast.SHORT;
Toast.TOP;
Toast.BOTTOM;
Toast.CENTER;

Please note that yOffset and xOffset are ignored on Android 11 and above.

For customizing on iOS, you can pass an object with the following properties:

type OptionsIOS = {
  textColor?: ColorValue;
  backgroundColor?: ColorValue;
  tapToDismissEnabled?: boolean;
};

Examples

import Toast from 'react-native-simple-toast';

Toast.show('This is a short toast');

Toast.show('This is a long toast.', Toast.LONG);

Toast.showWithGravity(
  'This is a long toast at the top.',
  Toast.LONG,
  Toast.TOP,
);

Toast.show('This is a styled toast on iOS.', Toast.LONG, {
  backgroundColor: 'blue',
});

Toast.show('This is a toast that can be dismissed (iOS only).', Toast.LONG, {
  tapToDismissEnabled: true,
});

License

MIT


Made with create-react-native-library

探索相关项目

加载中…