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