Fixed bug of Toast not closing when there is no close callback #39
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
LINK DE TICKET:
https://janiscommerce.atlassian.net/browse/APPSRN-308
DESCRIPCIÓN DEL REQUERIMIENTO:
Contexto:
En las tres apps estamos usando notificaciones para mostrar distintos mensajes y tenemos bastante codigo duplicado como tambien distintas maneras de usarlo. Por ejemplo en picking tenemos varios tipos de toast que se podrían mejorar y simplificar.
Con todo el desarrollo de push notification, las notificaciones cada vez van a ser mas importantes y por tal motivo necesitamos tener dicha funcionalidad de una manera mas agnóstica, reutilizable y que permite escalar el codigo de una manera mas rápida para agilizar entregas
Necesidad:
Tener los distintos tipos de notificaciones desde la libreria con sus distintos tipos
Como funciona hoy en las apps?
Desde la libreria estamos usando en App.js el componente Toast, el cual se encarga de recibir la configuracion de todos los Toast posibles.
La configuracion implica declarar el tipo de toast (este tipo es importante porque luego se usa para mostrar los distintos Toast en base al tipo) y cada uno de ellos esta usando un componente BaseToast.
DESCRIPCIÓN DE LA SOLUCIÓN:
Se solucionó un bug que no estaba permitiendo cerrar el Toast desde el icono de cruz cuándo no se le pasaba un onCloseCb.
A su vez, se agregó un handleActionCb para que ambos callbacks del Toast queden claros e iguales.
CÓMO SE PUEDE PROBAR?
En el repo de ui-native correr en consola: yalc publish
En la app: yalc add @janis-commerce/ui-native && npm i
En App.js reemplazar el componente Toast que se usa como provider:
import {Toast as ToastProvider, configToast} from '@janiscommerce/ui-native';
//donde configAppToast es la configuracion de los toast locales
<ToastProvider
config={{...configAppToast, ...configToast}}
ref={(ref) => ToastProvider.setRef(ref)}
position="bottom"
/>
Para probar que el bug se haya solucionado se lo puede hacer con el siguiente código, importando el Toast de UI-Native:
useEffect(() => {
Toast.show({
type: 'notice',
text1: 'Notice!',
text2: 'Lorem ipsum dolor sit amet, consectetur adipiscingsed ipsum dolorrrrdfds.',
autoHide: false,
showIcon: true,
props: {
showCloseIcon: true,
},
});
}, []);
Tras salir el Toast se debe verificar que, al presionar la cruz para cerrarlo, el mismo se cierre correctamente aunque no se le pase la prop onCloseCb
SCREENSHOTS:
Demo: https://streamable.com/sgmeqj
CHANGELOG: