Skip to content

Commit

Permalink
feat: add process provider
Browse files Browse the repository at this point in the history
  • Loading branch information
hel-axelor committed Feb 22, 2024
1 parent a8cbc51 commit e807f95
Show file tree
Hide file tree
Showing 11 changed files with 311 additions and 512 deletions.
21 changes: 10 additions & 11 deletions packages/apps/stock/src/screens/loader/LoaderScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Screen>
<View>
<Button
title="Run process"
onPress={() => setRunProccess(true)}
disabled={loading}
onPress={() => setStart(true)}
disabled={start}
/>
<LoaderPopup
start={start}
process={process}
runProccess={runProccess}
timeout={5000}
onSuccess={handleSuccessAction}
onError={handleErrorAction}
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/app/ContextedApplication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
Camera,
CameraScanner,
HeaderBandList,
LoaderToastNotifier,
Scanner,
Toast,
} from '../components';
Expand Down Expand Up @@ -88,7 +87,6 @@ const ContextedApplication = ({
<NavigationContainer>
<HeaderBandList />
<LoadingIndicator />
<LoaderToastNotifier />
<BlockInteractionMessage />
<RootNavigator
modules={modules}
Expand Down
5 changes: 1 addition & 4 deletions packages/core/src/app/ContextsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import {requestBuilder} from '../apiProviders/Standard/requests.helper';
import {core_modelAPI, core_searchFields, core_sortFields} from '../models';
import {HeaderBandProvider} from '../header';
import {addModuleForms, formConfigsProvider} from '../forms';
import {LoaderProvider} from '../components';

const ApplicationContext = createContext(null);

Expand Down Expand Up @@ -167,9 +166,7 @@ const ContextsProvider = ({
defaultTheme={defaultWritingTheme}
writingStylesConfig={writingStylesConfig}>
<ConfigProvider showModulesSubtitle={showModulesSubtitle}>
<HeaderBandProvider>
<LoaderProvider>{children}</LoaderProvider>
</HeaderBandProvider>
<HeaderBandProvider>{children}</HeaderBandProvider>
</ConfigProvider>
</WritingThemeProvider>
</ThemeProvider>
Expand Down
298 changes: 0 additions & 298 deletions packages/core/src/components/templates/Loader/LoaderContext.tsx

This file was deleted.

Loading

0 comments on commit e807f95

Please sign in to comment.