diff --git a/apps/mobile/index.mobile.js b/apps/mobile/index.mobile.js index 943242ed5..7c8156c30 100644 --- a/apps/mobile/index.mobile.js +++ b/apps/mobile/index.mobile.js @@ -10,11 +10,14 @@ import {EditorOpacity, EditorPosition} from './src/utils/animations'; import {sideMenuRef} from './src/utils/refs'; import {DDS} from './src/utils/utils'; import Editor from './src/views/Editor'; +import { eSubscribeEvent, eUnSubscribeEvent } from './src/services/eventManager'; +import { eOpenSideMenu, eCloseSideMenu } from './src/services/events'; const editorRef = createRef(); export const Initialize = () => { const [state, dispatch] = useTracked(); const {colors} = state; + const [locked,setLocked] = useState(false); useEffect(() => { if (Platform.OS === 'android') { @@ -24,6 +27,23 @@ export const Initialize = () => { } }, []); + const setGestureDisabled = () =>{ + setLocked(true); + } + + const setGestureEnabled = () => { + setLocked(false); + } + + useEffect(() => { + eSubscribeEvent(eOpenSideMenu,setGestureEnabled); + eSubscribeEvent(eCloseSideMenu,setGestureDisabled); + return () => { + eUnSubscribeEvent(eOpenSideMenu,setGestureEnabled); + eUnSubscribeEvent(eCloseSideMenu,setGestureDisabled); + } + },[]) + return ( { }} keyboardDismissMode="ondrag" drawerWidth={300} + drawerLockMode={locked? "locked-closed" : 'unlocked'} useNativeAnimations={true} renderNavigationView={() => ( { switch (action.type) { @@ -127,6 +129,12 @@ export const reducer = (state, action) => { }; } case ACTIONS.SELECTION_MODE: { + if (action.enabled) { + eSendEvent(eCloseSideMenu); + } else { + eSendEvent(eOpenSideMenu); + } + return { ...state, selectionMode: action.enabled, @@ -146,6 +154,9 @@ export const reducer = (state, action) => { selectedItems.push(action.item); } history.selectedItemsList = selectedItems; + if (selectedItems.length === 0) { + eSendEvent(eOpenSideMenu); + } return { ...state, selectedItemsList: selectedItems, @@ -154,6 +165,7 @@ export const reducer = (state, action) => { } case ACTIONS.CLEAR_SELECTION: { history.selectedItemsList = []; + eSendEvent(eOpenSideMenu); return { ...state, selectedItemsList: [], diff --git a/apps/mobile/src/views/Login/index.js b/apps/mobile/src/views/Login/index.js index a1325a207..7822b5a17 100644 --- a/apps/mobile/src/views/Login/index.js +++ b/apps/mobile/src/views/Login/index.js @@ -14,7 +14,11 @@ import {Header} from '../../components/header'; import {useTracked} from '../../provider'; import {ACTIONS} from '../../provider/actions'; import {eSendEvent} from '../../services/eventManager'; -import {eCloseSideMenu, refreshNotesPage} from '../../services/events'; +import { + eCloseSideMenu, + refreshNotesPage, + eOpenSideMenu, +} from '../../services/events'; import {validatePass, validateUsername} from '../../services/validation'; import {db, DDS, ToastEvent, getElevation} from '../../utils/utils'; import {useIsFocused} from '@react-navigation/native';