disable sidemenu opening when scrolling

This commit is contained in:
ammarahm-ed
2021-01-14 15:58:56 +05:00
parent 4bda6bb6c5
commit 4afd89c4f1

View File

@@ -1,44 +1,42 @@
import { import {
activateKeepAwake, activateKeepAwake,
deactivateKeepAwake, deactivateKeepAwake
} from '@sayem314/react-native-keep-awake'; } from '@sayem314/react-native-keep-awake';
import React, {useEffect, useState} from 'react'; import React, { useCallback, useEffect, useState } from 'react';
import {Dimensions, View} from 'react-native'; import { Dimensions, View } from 'react-native';
import ScrollableTabView from 'react-native-scrollable-tab-view'; import ScrollableTabView from 'react-native-scrollable-tab-view';
import SplashScreen from 'react-native-splash-screen'; import { notesnook } from './e2e/test.ids';
import {notesnook} from './e2e/test.ids';
import ContextMenu from './src/components/ContextMenu'; import ContextMenu from './src/components/ContextMenu';
import {DialogManager} from './src/components/DialogManager'; import { DialogManager } from './src/components/DialogManager';
import {DummyText} from './src/components/DummyText'; import { DummyText } from './src/components/DummyText';
import {Menu} from './src/components/Menu'; import { Menu } from './src/components/Menu';
import {Toast} from './src/components/Toast'; import { Toast } from './src/components/Toast';
import {NavigationStack} from './src/navigation/Drawer'; import { NavigationStack } from './src/navigation/Drawer';
import {NavigatorStack} from './src/navigation/NavigatorStack'; import { NavigatorStack } from './src/navigation/NavigatorStack';
import {useTracked} from './src/provider'; import { useTracked } from './src/provider';
import {Actions} from './src/provider/Actions'; import { Actions } from './src/provider/Actions';
import {DDS} from './src/services/DeviceDetection'; import { DDS } from './src/services/DeviceDetection';
import { import {
eSendEvent, eSendEvent,
eSubscribeEvent, eSubscribeEvent,
eUnSubscribeEvent, eUnSubscribeEvent
} from './src/services/EventManager'; } from './src/services/EventManager';
import {editing, setWidthHeight} from './src/utils'; import { editing, setWidthHeight } from './src/utils';
import { import {
eClearEditor, eClearEditor,
eCloseFullscreenEditor, eCloseFullscreenEditor,
eCloseSideMenu, eCloseSideMenu,
eOnLoadNote, eOnLoadNote,
eOpenFullscreenEditor, eOpenFullscreenEditor,
eOpenSideMenu, eOpenSideMenu
} from './src/utils/Events'; } from './src/utils/Events';
import {editorRef, tabBarRef} from './src/utils/Refs'; import { editorRef, tabBarRef } from './src/utils/Refs';
import {EditorWrapper} from './src/views/Editor/EditorWrapper'; import { EditorWrapper } from './src/views/Editor/EditorWrapper';
import {getIntent, getNote, post} from './src/views/Editor/Functions'; import { getNote, post } from './src/views/Editor/Functions';
let {width, height} = Dimensions.get('window'); let {width, height} = Dimensions.get('window');
let layoutTimer = null; let layoutTimer = null;
let currentTab = 0; let currentTab = 0;
const onChangeTab = async (obj) => { const onChangeTab = async (obj) => {
if (obj.i === 1) { if (obj.i === 1) {
eSendEvent(eCloseSideMenu); eSendEvent(eCloseSideMenu);
@@ -184,7 +182,7 @@ const AppStack = React.memo(
updatedDimensions = size; updatedDimensions = size;
if (!size || (size.width === dimensions.width && mode !== null)) { if (!size || (size.width === dimensions.width && mode !== null)) {
DDS.setSize(size); DDS.setSize(size);
console.log(mode,"MODE__") console.log(mode, 'MODE__');
dispatch({type: Actions.DEVICE_MODE, state: mode}); dispatch({type: Actions.DEVICE_MODE, state: mode});
return; return;
@@ -231,6 +229,17 @@ const AppStack = React.memo(
} }
} }
const onScroll = (scroll) => {
currentScroll = scroll;
if (scroll === 0) {
eSendEvent(eOpenSideMenu);
} else {
eSendEvent(eCloseSideMenu);
}
};
const renderTabBar = useCallback(() => <></>,[])
return ( return (
<View <View
onLayout={_onLayout} onLayout={_onLayout}
@@ -249,11 +258,11 @@ const AppStack = React.memo(
style={{ style={{
zIndex: 1, zIndex: 1,
}} }}
onScroll={(event) => (currentScroll = event)} onScroll={onScroll}
initialPage={0} initialPage={0}
prerenderingSiblingsNumber={Infinity} prerenderingSiblingsNumber={Infinity}
onChangeTab={onChangeTab} onChangeTab={onChangeTab}
renderTabBar={() => <></>}> renderTabBar={renderTabBar}>
{mode !== 'tablet' && ( {mode !== 'tablet' && (
<View <View
style={{ style={{