From 94532b397cb93b378ae3f576f95a2b20e42344c4 Mon Sep 17 00:00:00 2001 From: marcelxsilva Date: Thu, 4 Jul 2024 15:55:01 -0300 Subject: [PATCH 1/2] fix: reload toast --- src/Toast.tsx | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Toast.tsx b/src/Toast.tsx index 0730466..1e478dc 100644 --- a/src/Toast.tsx +++ b/src/Toast.tsx @@ -156,10 +156,7 @@ type Props = { config: ToastConfig; }; -export const Toast: FC = ({ - data: { message, type, duration = 2500, title }, - config, -}) => { +export const Toast: FC = ({ data, config }) => { const [toastHeight, setToastHeight] = useState(0); const [toast, setToast] = useState({ @@ -168,8 +165,8 @@ export const Toast: FC = ({ type: 'success', }); - const showCloseButton = config.showCloseButton[type]; - const disabledAutoHide = config.autoHide[type]; + const showCloseButton = config.showCloseButton[data.type]; + const disabledAutoHide = config.autoHide[data.type]; const disabledGesture = !disabledAutoHide; const handleBackgroundColor = () => { @@ -178,10 +175,13 @@ export const Toast: FC = ({ const error = '#ff726b'; const custom = '#4794ff'; - if (type === 'success') return config?.backgroundColor?.success || success; - if (type === 'warning') return config?.backgroundColor?.warning || warning; - if (type === 'error') return config?.backgroundColor?.error || error; - if (type === 'custom') return config?.backgroundColor?.custom || custom; + if (data.type === 'success') + return config?.backgroundColor?.success || success; + if (data.type === 'warning') + return config?.backgroundColor?.warning || warning; + if (data.type === 'error') return config?.backgroundColor?.error || error; + if (data.type === 'custom') + return config?.backgroundColor?.custom || custom; return config?.backgroundColor?.success || success; }; @@ -263,7 +263,7 @@ export const Toast: FC = ({ const handleDismiss = () => { if (disabledAutoHide) { - timeout = setTimeout(() => dismissToast(), duration); + timeout = setTimeout(() => dismissToast(), data.duration); return () => resetTimeout(); } @@ -280,14 +280,14 @@ export const Toast: FC = ({ }, [toast.message, toastHeight]); useEffect(() => { - if (!!message) { + if (!!data.message.length) { setToast({ - title: title, - message: message, - type: type, + title: data.title, + message: data.message, + type: data.type, }); } - }, [message]); + }, [data]); const panGestureEvent = useAnimatedGestureHandler< PanGestureHandlerGestureEvent, @@ -335,31 +335,31 @@ export const Toast: FC = ({ config?.customIcon[toast.type]} - {!!title && ( + {!!data.title && ( - {title?.trim()} + {data.title?.trim()} )} - {message && ( + {data.message && ( - {message?.trim()} + {data.message?.trim()} )} @@ -371,7 +371,7 @@ export const Toast: FC = ({ textColor={ typeof config?.textColor === 'string' ? config?.textColor - : config?.textColor?.[type] + : config?.textColor?.[data.type] } > {config.closeButtonText?.trim()} From 83eb7a4a042c8b1bf1851feb8ccfe3128c0bc3c6 Mon Sep 17 00:00:00 2001 From: marcelxsilva Date: Thu, 4 Jul 2024 16:48:16 -0300 Subject: [PATCH 2/2] feat: set version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e12e06b..f0d1291 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@platformbuilders/react-native-toast", - "version": "1.4.0", + "version": "1.4.1", "description": "", "author": "Platform Builders ", "repository": {