UNPKG

expo-toastee

Version:

A simple and elegant toast notification library for React Native Expo with Material You and Neobrutalist themes

45 lines (44 loc) 1.19 kB
class ToastConfigManager { constructor() { this.config = { theme: 'material', size: 'md', defaultDuration: 3000, defaultPosition: 'top', defaultAnimationType: 'slide', }; } // Set global configuration setConfig(newConfig) { this.config = { ...this.config, ...newConfig }; } // Get current configuration getConfig() { return { ...this.config }; } // Get specific config values getTheme() { return this.config.theme || 'material'; } getDefaultDuration() { return this.config.defaultDuration || 3000; } getDefaultPosition() { return this.config.defaultPosition || 'top'; } getDefaultAnimationType() { return this.config.defaultAnimationType || 'slide'; } getCustomStyles() { return this.config.customStyles || {}; } getSize() { return this.config.size || 'md'; } } // Create singleton instance export const toastConfig = new ToastConfigManager(); // Convenience function for users export const configureToasts = (config) => { toastConfig.setConfig(config); };