mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-29 00:20:04 +01:00
refactor
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { View } from 'react-native';
|
||||
import { useTracked } from '../../provider';
|
||||
import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/EventManager';
|
||||
import { getElevation } from '../../utils';
|
||||
import Paragraph from '../Typography/Paragraph';
|
||||
|
||||
let contextTimeout = null;
|
||||
|
||||
const ContextMenu = () => {
|
||||
const [state, dispatch] = useTracked();
|
||||
const {colors} = state;
|
||||
const [contextMenu, setContextMenu] = useState({
|
||||
location: {
|
||||
x: -100,
|
||||
y: -100,
|
||||
},
|
||||
title: 'World',
|
||||
});
|
||||
|
||||
const showContextMenu = async (event) => {
|
||||
if (contextTimeout) {
|
||||
clearTimeout(contextTimeout);
|
||||
contextTimeout = null;
|
||||
}
|
||||
setContextMenu(event);
|
||||
contextTimeout = setTimeout(() => {
|
||||
setContextMenu({
|
||||
location: {
|
||||
x: -100,
|
||||
y: -100,
|
||||
},
|
||||
title: 'World',
|
||||
});
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
eSubscribeEvent('showContextMenu', showContextMenu);
|
||||
|
||||
return () => {
|
||||
eUnSubscribeEvent('showContextMenu', showContextMenu);
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
...getElevation(5),
|
||||
position: 'absolute',
|
||||
left: contextMenu.location.x,
|
||||
top: contextMenu.location.y,
|
||||
backgroundColor: colors.night ? colors.nav : 'black',
|
||||
paddingVertical: 8,
|
||||
paddingHorizontal: 12,
|
||||
borderRadius: 5,
|
||||
}}>
|
||||
<Paragraph color="white">{contextMenu.title}</Paragraph>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
export default ContextMenu;
|
||||
@@ -2,38 +2,37 @@ import {
|
||||
activateKeepAwake,
|
||||
deactivateKeepAwake
|
||||
} from '@sayem314/react-native-keep-awake';
|
||||
import React, {useEffect, useRef} from 'react';
|
||||
import {View} from 'react-native';
|
||||
import Animated, {useValue} from 'react-native-reanimated';
|
||||
import {notesnook} from '../../e2e/test.ids';
|
||||
import ContextMenu from '../components/ContextMenu';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { View } from 'react-native';
|
||||
import Animated, { useValue } from 'react-native-reanimated';
|
||||
import { notesnook } from '../../e2e/test.ids';
|
||||
import CustomTabs from '../components/CustomTabs';
|
||||
import {DialogManager} from '../components/DialogManager';
|
||||
import {DummyText} from '../components/DummyText';
|
||||
import {Menu} from '../components/Menu';
|
||||
import {Toast} from '../components/Toast';
|
||||
import {NavigatorStack} from './NavigatorStack';
|
||||
import {useTracked} from '../provider';
|
||||
import {useEditorStore, useSettingStore} from '../provider/stores';
|
||||
import {DDS} from '../services/DeviceDetection';
|
||||
import { DialogManager } from '../components/DialogManager';
|
||||
import { DummyText } from '../components/DummyText';
|
||||
import { Menu } from '../components/Menu';
|
||||
import { Toast } from '../components/Toast';
|
||||
import { useTracked } from '../provider';
|
||||
import { useEditorStore, useSettingStore } from '../provider/stores';
|
||||
import { DDS } from '../services/DeviceDetection';
|
||||
import {
|
||||
eSendEvent,
|
||||
eSubscribeEvent,
|
||||
eUnSubscribeEvent
|
||||
} from '../services/EventManager';
|
||||
import {editing, setWidthHeight} from '../utils';
|
||||
import {updateStatusBarColor} from '../utils/Colors';
|
||||
import { editing, setWidthHeight } from '../utils';
|
||||
import { updateStatusBarColor } from '../utils/Colors';
|
||||
import {
|
||||
eClearEditor,
|
||||
eCloseFullscreenEditor,
|
||||
eOnLoadNote,
|
||||
eOpenFullscreenEditor
|
||||
} from '../utils/Events';
|
||||
import {editorRef, tabBarRef} from '../utils/Refs';
|
||||
import {sleep} from '../utils/TimeUtils';
|
||||
import {EditorWrapper} from '../views/Editor/EditorWrapper';
|
||||
import {EditorWebView, getNote} from '../views/Editor/Functions';
|
||||
import { editorRef, tabBarRef } from '../utils/Refs';
|
||||
import { sleep } from '../utils/TimeUtils';
|
||||
import { EditorWrapper } from '../views/Editor/EditorWrapper';
|
||||
import { EditorWebView, getNote } from '../views/Editor/Functions';
|
||||
import tiny from '../views/Editor/tiny/tiny';
|
||||
import { NavigatorStack } from './NavigatorStack';
|
||||
let layoutTimer = null;
|
||||
|
||||
const onChangeTab = async obj => {
|
||||
@@ -81,7 +80,6 @@ export const RootView = React.memo(
|
||||
<>
|
||||
<NativeStack />
|
||||
<Toast />
|
||||
<ContextMenu />
|
||||
<DummyText />
|
||||
<DialogManager />
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user