mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-24 07:29:30 +01:00
lock gestures in selectionMode
This commit is contained in:
@@ -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 (
|
||||
<Animatable.View
|
||||
transition="backgroundColor"
|
||||
@@ -42,6 +62,7 @@ export const Initialize = () => {
|
||||
}}
|
||||
keyboardDismissMode="ondrag"
|
||||
drawerWidth={300}
|
||||
drawerLockMode={locked? "locked-closed" : 'unlocked'}
|
||||
useNativeAnimations={true}
|
||||
renderNavigationView={() => (
|
||||
<Menu
|
||||
|
||||
@@ -2,6 +2,8 @@ import {history, db} from '../utils/utils';
|
||||
import {ACTIONS} from './actions';
|
||||
import {sideMenuRef} from '../utils/refs';
|
||||
import storage from '../utils/storage';
|
||||
import {eSendEvent} from '../services/eventManager';
|
||||
import {eCloseSideMenu, eOpenSideMenu} from '../services/events';
|
||||
|
||||
export const reducer = (state, action) => {
|
||||
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: [],
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user