From 150e61ea10cab36efce66dbde8bec91e3d821426 Mon Sep 17 00:00:00 2001 From: wil Date: Thu, 28 Mar 2024 13:59:43 -0400 Subject: [PATCH] loading bar logic and example --- app/pages/PageEnigma/PageEnigmaComponent.tsx | 1 - .../ControlsTopButtons/ControlsTopButtons.tsx | 27 +++++++++++++++++-- .../reducers/appUiReducer/reducer.tsx | 9 +++++++ .../reducers/appUiReducer/types.tsx | 13 ++++++++- 4 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/pages/PageEnigma/PageEnigmaComponent.tsx b/app/pages/PageEnigma/PageEnigmaComponent.tsx index bdfbc8feb3..8465f1d683 100644 --- a/app/pages/PageEnigma/PageEnigmaComponent.tsx +++ b/app/pages/PageEnigma/PageEnigmaComponent.tsx @@ -77,7 +77,6 @@ export const PageEnigmaComponent = () => { message={appUiState.showEditorLoadingBar.message} label={appUiState.showEditorLoadingBar.label} progress={appUiState.showEditorLoadingBar.progress} - useFakeTimer={30000} /> diff --git a/app/pages/PageEnigma/comps/ControlsTopButtons/ControlsTopButtons.tsx b/app/pages/PageEnigma/comps/ControlsTopButtons/ControlsTopButtons.tsx index 315c5981b6..76949ab418 100644 --- a/app/pages/PageEnigma/comps/ControlsTopButtons/ControlsTopButtons.tsx +++ b/app/pages/PageEnigma/comps/ControlsTopButtons/ControlsTopButtons.tsx @@ -27,15 +27,38 @@ export const ControlsTopButtons = () => { const handleButtonTest = () => { if(appUiState?.showEditorLoadingBar.isShowing){ + //TO GO TO A HUNDRED AND DISAPPER dispatchAppUiState({ - type: APPUI_ACTION_TYPES.HIDE_EDITOR_LOADINGBAR, + type: APPUI_ACTION_TYPES.UPDATE_EDITOR_LOADINGBAR, + payload:{ + showEditorLoadingBar: { + progress: 100, + } + } }); + setTimeout(() => { + dispatchAppUiState({ + type: APPUI_ACTION_TYPES.HIDE_EDITOR_LOADINGBAR, + }); + }, 1000); + //END :TO GO TO A HUNDRED AND DISAPPER + + //EAMPLE OF CHANING LOADING MESSAGE + // dispatchAppUiState({ + // type: APPUI_ACTION_TYPES.UPDATE_EDITOR_LOADINGBAR, + // payload:{ + // showEditorLoadingBar: { + // message: "new message", + // } + // } + // }); }else{ dispatchAppUiState({ type: APPUI_ACTION_TYPES.SHOW_EDITOR_LOADINGBAR, payload:{ showEditorLoadingBar: { - message: 'display of LoadingBar triggered by Test Button' + message: 'display of LoadingBar triggered by Test Button', + progress: 10, } } diff --git a/app/pages/PageEnigma/reducers/appUiReducer/reducer.tsx b/app/pages/PageEnigma/reducers/appUiReducer/reducer.tsx index 63881a7a4b..c632ebfef2 100644 --- a/app/pages/PageEnigma/reducers/appUiReducer/reducer.tsx +++ b/app/pages/PageEnigma/reducers/appUiReducer/reducer.tsx @@ -29,6 +29,15 @@ export function reducer(state: State, action: Action): State { }, } } + case ACTION_TYPES.UPDATE_EDITOR_LOADINGBAR:{ + return{ + ...state, + showEditorLoadingBar: { + ...state.showEditorLoadingBar, + ...action.payload?.showEditorLoadingBar, + }, + } + } case ACTION_TYPES.HIDE_EDITOR_LOADINGBAR:{ return{ ...state, diff --git a/app/pages/PageEnigma/reducers/appUiReducer/types.tsx b/app/pages/PageEnigma/reducers/appUiReducer/types.tsx index 8b658fcbb4..5e07b24b3f 100644 --- a/app/pages/PageEnigma/reducers/appUiReducer/types.tsx +++ b/app/pages/PageEnigma/reducers/appUiReducer/types.tsx @@ -28,6 +28,7 @@ export enum ACTION_TYPES { SHOW_EDITOR_LOADER = "show_editor_loader", HIDE_EDITOR_LOADER = "hide_editor_loader", SHOW_EDITOR_LOADINGBAR = "show_editor_loadingbar", + UPDATE_EDITOR_LOADINGBAR = "update_editor_loadingbar", HIDE_EDITOR_LOADINGBAR = "hide_editor_loadingbar", }; @@ -49,7 +50,17 @@ export type Action = label?: string; message?: string; progress?: number; - useFake?: boolean; + useFakeTimer?: number; + } + } + } + | { + type: ACTION_TYPES.UPDATE_EDITOR_LOADINGBAR, + payload:{ + showEditorLoadingBar: { + label?: string; + message?: string; + progress?: number; } } }