From e807f9599c757f16863616eddfe8f55c745aa120 Mon Sep 17 00:00:00 2001 From: Hamza El Gatia Date: Thu, 22 Feb 2024 11:55:05 +0100 Subject: [PATCH] feat: add process provider --- .../stock/src/screens/loader/LoaderScreen.js | 21 +- .../core/src/app/ContextedApplication.tsx | 2 - packages/core/src/app/ContextsProvider.tsx | 5 +- .../templates/Loader/LoaderContext.tsx | 298 ------------------ .../templates/Loader/LoaderPopup.tsx | 51 +-- .../templates/Loader/LoaderToastNotifier.tsx | 80 ----- .../templates/Loader/ProcessProvider.ts | 173 ++++++++++ .../src/components/templates/Loader/index.ts | 4 +- .../templates/Loader/loader-helper.ts | 21 ++ .../src/components/templates/Loader/types.ts | 51 +++ .../templates/Loader/use-loader-listener.ts | 117 ++----- 11 files changed, 311 insertions(+), 512 deletions(-) delete mode 100644 packages/core/src/components/templates/Loader/LoaderContext.tsx delete mode 100644 packages/core/src/components/templates/Loader/LoaderToastNotifier.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 6c1ef2fbb2..567148e7cf 100644 --- a/packages/apps/stock/src/screens/loader/LoaderScreen.js +++ b/packages/apps/stock/src/screens/loader/LoaderScreen.js @@ -37,42 +37,41 @@ import React, {useState} from 'react'; import {View} from 'react-native'; import {Button, Screen} from '@axelor/aos-mobile-ui'; -import {LoaderPopup, useLoader} from '@axelor/aos-mobile-core'; +import {LoaderPopup} from '@axelor/aos-mobile-core'; // Screen for test Loader functionnalities const LoaderScreen = () => { - const [runProccess, setRunProccess] = useState(false); + 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 handleSuccessAction = () => { - setRunProccess(false); + setStart(false); console.log('Success action executed!'); }; const handleErrorAction = () => { - setRunProccess(false); + setStart(false); console.log('Error action executed!'); }; - const {loading} = useLoader(); - return (