UNPKG

react-native-simple-toast

Version:
44 lines 1.59 kB
import { Platform, processColor } from 'react-native'; const unsupportedPlatform = 'RNSimpleToast: unsupported platform'; const RCTToast = Platform.select({ ios: () => require('./NativeSimpleToast').default, android: () => require('react-native').ToastAndroid, default: () => { throw new Error(unsupportedPlatform); } })(); const constantsSource = Platform.select({ ios: () => require('./NativeSimpleToast').default.getConstants(), android: () => require('react-native').ToastAndroid, default: () => { throw new Error(unsupportedPlatform); } })(); export default { SHORT: constantsSource.SHORT, LONG: constantsSource.LONG, TOP: constantsSource.TOP, BOTTOM: constantsSource.BOTTOM, CENTER: constantsSource.CENTER, show(message, duration, options) { RCTToast.show(message, duration ?? constantsSource.SHORT, processColors(options)); }, showWithGravity(message, duration, gravity, options) { RCTToast.showWithGravity(message, duration ?? constantsSource.SHORT, gravity, processColors(options)); }, showWithGravityAndOffset(message, duration, gravity, xOffset, yOffset, options) { RCTToast.showWithGravityAndOffset(message, duration ?? constantsSource.SHORT, gravity, xOffset, yOffset, processColors(options)); } }; function processColors(options) { if (Platform.OS === 'android' || !options) { return undefined; } return { // the types are not 100% correct ...options, messageColor: processColor(options.textColor), backgroundColor: processColor(options.backgroundColor) }; } //# sourceMappingURL=index.js.map