UNPKG

react-native-simple-toast

Version:
51 lines (50 loc) 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _reactNative = require("react-native"); const unsupportedPlatform = 'RNSimpleToast: unsupported platform'; const RCTToast = _reactNative.Platform.select({ ios: () => require('./NativeSimpleToast').default, android: () => require('react-native').ToastAndroid, default: () => { throw new Error(unsupportedPlatform); } })(); const constantsSource = _reactNative.Platform.select({ ios: () => require('./NativeSimpleToast').default.getConstants(), android: () => require('react-native').ToastAndroid, default: () => { throw new Error(unsupportedPlatform); } })(); var _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)); } }; exports.default = _default; function processColors(options) { if (_reactNative.Platform.OS === 'android' || !options) { return undefined; } return { // the types are not 100% correct ...options, messageColor: (0, _reactNative.processColor)(options.textColor), backgroundColor: (0, _reactNative.processColor)(options.backgroundColor) }; } //# sourceMappingURL=index.js.map