From bf77f8f5a75dbe861490c5fa34b77b7f5759bd2b Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Mon, 26 Oct 2020 11:35:42 +0500 Subject: [PATCH] add Message Board --- apps/mobile/App.js | 3 +++ apps/mobile/src/components/SimpleList/index.js | 2 +- apps/mobile/src/provider/Actions.js | 3 ++- apps/mobile/src/provider/Reducer.js | 6 ++++++ apps/mobile/src/services/Message.js | 16 ++++++++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 apps/mobile/src/services/Message.js diff --git a/apps/mobile/App.js b/apps/mobile/App.js index 91d63695d..d173516dd 100644 --- a/apps/mobile/App.js +++ b/apps/mobile/App.js @@ -28,6 +28,7 @@ import {db} from './src/utils/DB'; import {DDS} from './src/services/DeviceDetection'; import {MMKV} from './src/utils/mmkv'; import Backup from './src/services/Backup'; +import { setLoginMessage } from './src/services/Message'; let firstLoad = true; let note = null; @@ -160,6 +161,8 @@ const App = () => { if (user) { dispatch({type: Actions.USER, user: user}); await startSyncer(); + } else { + setLoginMessage(dispatch); } dispatch({type: Actions.ALL}); setInit(true); diff --git a/apps/mobile/src/components/SimpleList/index.js b/apps/mobile/src/components/SimpleList/index.js index efa8b2d9b..709a337ba 100644 --- a/apps/mobile/src/components/SimpleList/index.js +++ b/apps/mobile/src/components/SimpleList/index.js @@ -325,7 +325,7 @@ const MessageCard = ({data}) => { : colors.accent, fontSize: SIZE.xxs, }}> - {messageBoardState.data.actionText} + {messageBoardState.actionText} diff --git a/apps/mobile/src/provider/Actions.js b/apps/mobile/src/provider/Actions.js index 3b0796185..312e96003 100644 --- a/apps/mobile/src/provider/Actions.js +++ b/apps/mobile/src/provider/Actions.js @@ -26,5 +26,6 @@ export const Actions = { CONTAINER_STATE: 'containerState', CONTAINER_BOTTOM_BUTTON:'containerBottomButton', HEADER_VERTICAL_MENU:'verticalMenu', - HEADER_TEXT_STATE:'headerTextState' + HEADER_TEXT_STATE:'headerTextState', + MESSAGE_BOARD_STATE:'messageBoardState' }; diff --git a/apps/mobile/src/provider/Reducer.js b/apps/mobile/src/provider/Reducer.js index c19f3bea9..2477340ec 100644 --- a/apps/mobile/src/provider/Reducer.js +++ b/apps/mobile/src/provider/Reducer.js @@ -241,6 +241,12 @@ export const reducer = (state, action) => { containerBottomButton: containerBottomButton, }; } + case Actions.MESSAGE_BOARD_STATE: { + return { + ...state, + messageBoardState:action.state + } + } default: throw new Error('unknown action type'); } diff --git a/apps/mobile/src/services/Message.js b/apps/mobile/src/services/Message.js new file mode 100644 index 000000000..74d3ba84f --- /dev/null +++ b/apps/mobile/src/services/Message.js @@ -0,0 +1,16 @@ +import { Actions } from "../provider/Actions"; +import { eOpenLoginDialog } from "../utils/Events"; +import { eSendEvent } from "./EventManager"; + +export function setLoginMessage(dispatch) { + dispatch({type:Actions.MESSAGE_BOARD_STATE,state:{ + visible:true, + message:'You are not logged in', + actionText:"Login to sync your notes", + onPress: () => { + eSendEvent(eOpenLoginDialog); + }, + data:{}, + icon:'account-outline' + }}); +} \ No newline at end of file