@diyardev/react-native-dynamic-toast
Version:
A beautiful, dynamic and customizable toast notification system for React Native with TypeScript support
52 lines (51 loc) • 1.95 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.Toast = exports.setToastFunction = void 0;
// Global toast functions
var showToastFunction = null;
var setToastFunction = function (fn) {
showToastFunction = fn;
};
exports.setToastFunction = setToastFunction;
exports.Toast = {
success: function (message, options) {
if (showToastFunction) {
showToastFunction({
type: 'success',
message: message,
duration: options === null || options === void 0 ? void 0 : options.duration,
position: options === null || options === void 0 ? void 0 : options.position,
});
}
else {
console.warn('Toast function not initialized. Make sure ToastProvider is set up correctly.');
}
},
error: function (message, options) {
if (showToastFunction) {
showToastFunction({
type: 'error',
message: message,
duration: options === null || options === void 0 ? void 0 : options.duration,
position: options === null || options === void 0 ? void 0 : options.position,
});
}
else {
console.warn('Toast function not initialized. Make sure ToastProvider is set up correctly.');
}
},
errorWithValidation: function (message, errors, options) {
if (showToastFunction) {
showToastFunction({
type: 'error',
message: message,
errors: errors,
duration: options === null || options === void 0 ? void 0 : options.duration,
position: options === null || options === void 0 ? void 0 : options.position,
});
}
else {
console.warn('Toast function not initialized. Make sure ToastProvider is set up correctly.');
}
},
};
;