From 9af48b1065fc8ed4e0e181a04d01b7fed2fcd214 Mon Sep 17 00:00:00 2001 From: hel-axelor <101327380+hel-axelor@users.noreply.github.com> Date: Fri, 23 Feb 2024 11:57:02 +0100 Subject: [PATCH] feat: add loader wait management popup (#367) * RM#73990 --- .../stock/src/screens/loader/LoaderScreen.js | 43 +++-- .../templates/Loader/LoaderPopup.tsx | 150 +++++++++++++++ .../templates/Loader/ProcessProvider.ts | 173 ++++++++++++++++++ .../src/components/templates/Loader/index.ts | 3 + .../templates/Loader/loader-helper.ts | 21 +++ .../src/components/templates/Loader/types.ts | 51 ++++++ .../templates/Loader/use-loader-listener.ts | 87 ++++----- packages/core/src/i18n/translations/en.json | 3 + packages/core/src/i18n/translations/fr.json | 3 + 9 files changed, 466 insertions(+), 68 deletions(-) create mode 100644 packages/core/src/components/templates/Loader/LoaderPopup.tsx create mode 100644 packages/core/src/components/templates/Loader/ProcessProvider.ts create mode 100644 packages/core/src/components/templates/Loader/loader-helper.ts create mode 100644 packages/core/src/components/templates/Loader/types.ts diff --git a/packages/apps/stock/src/screens/loader/LoaderScreen.js b/packages/apps/stock/src/screens/loader/LoaderScreen.js index f187147e8b..567148e7cf 100644 --- a/packages/apps/stock/src/screens/loader/LoaderScreen.js +++ b/packages/apps/stock/src/screens/loader/LoaderScreen.js @@ -34,34 +34,49 @@ * along with this program. If not, see . */ -import React from 'react'; -import {Button, View} from 'react-native'; -import {Screen} from '@axelor/aos-mobile-ui'; -import {useLoaderListner} from '@axelor/aos-mobile-core'; +import React, {useState} from 'react'; +import {View} from 'react-native'; +import {Button, Screen} from '@axelor/aos-mobile-ui'; +import {LoaderPopup} from '@axelor/aos-mobile-core'; // Screen for test Loader functionnalities const LoaderScreen = () => { + const [start, setStart] = useState(false); + const process = () => - new Promise(resolve => { + new Promise((resolve, reject) => { setTimeout(() => { - resolve('Process finished'); + resolve('Process completed'); + // reject('Process failed'); }, 10000); }); - const handleCustomAction = () => { - console.log('Custom action executed!'); + const handleSuccessAction = () => { + setStart(false); + console.log('Success action executed!'); }; - const {loading, listener} = useLoaderListner({ - process, - onSuccess: handleCustomAction, - onError: () => console.warn('An error has occurred!'), - }); + const handleErrorAction = () => { + setStart(false); + console.log('Error action executed!'); + }; return ( -