refactor: prevent require cycles warning

This commit is contained in:
ammarahm-ed
2020-04-09 15:13:09 +05:00
parent ac51c4c861
commit 4b7bd58657
8 changed files with 369 additions and 370 deletions

View File

@@ -3,15 +3,14 @@ import Animated from 'react-native-reanimated';
import { Menu } from './src/components/Menu';
import * as Animatable from 'react-native-animatable';
import SideMenu from './src/components/SideMenu';
import NavigationService, {
AppContainer,
} from './src/services/NavigationService';
import { EditorPosition } from './src/utils/animations';
import { sideMenuRef } from './src/utils/refs';
import { DDS, w } from './src/utils/utils';
import Editor from './src/views/Editor';
import { useTracked } from './src/provider';
import { StatusBar, Platform } from 'react-native';
import { AppContainer } from './src/services/AppContainer';
import NavigationService from './src/services/NavigationService';
const editorRef = createRef();
export const Initialize = () => {

View File

@@ -4,9 +4,7 @@ import * as Animatable from 'react-native-animatable';
import { Menu } from './src/components/Menu';
import { ModalMenu } from './src/components/ModalMenu';
import { useTracked } from './src/provider';
import NavigationService, {
AppContainer,
} from './src/services/NavigationService';
import Editor from './src/views/Editor';
import { eSubscribeEvent, eSendEvent } from './src/services/eventManager';
import {
@@ -14,6 +12,8 @@ import {
eCloseFullscreenEditor,
eOnLoadNote,
} from './src/services/events';
import { AppContainer } from './src/services/AppContainer';
import NavigationService from './src/services/NavigationService';
const editorRef = createRef();
let outColors;

View File

@@ -0,0 +1,6 @@
import { TopLevelNavigator } from "./Navigator";
import {
createAppContainer,
} from 'react-navigation';
export const AppContainer = createAppContainer(TopLevelNavigator);

View File

@@ -1,129 +1,9 @@
import {
createAppContainer,
NavigationActions,
StackActions,
} from 'react-navigation';
import {createStackNavigator} from 'react-navigation-stack';
import AccountSettings from '../views/AccountSettings';
import Editor from '../views/Editor';
import Favorites from '../views/Favorites';
import Folders from '../views/Folders';
import ForgotPassword from '../views/ForgotPassword';
import Home from '../views/Home/index';
import Lists from '../views/Lists';
import ListsEditor from '../views/ListsEditor';
import Login from '../views/Login';
import Notebook from '../views/Notebook';
import Notes from '../views/Notes';
import ReminderEditor from '../views/ReminderEditor';
import Reminders from '../views/Reminders';
import Settings from '../views/Settings';
import Signup from '../views/Signup';
import Tags from '../views/Tags';
import Trash from '../views/Trash';
import AppearanceSettings from '../views/AppearanceSettings';
import EditorSettings from '../views/EditorSettings';
const fade = props => {
const {position, scene} = props;
const index = scene.index;
const translateX = 0;
const translateY = 0;
const opacity = position.interpolate({
inputRange: [index - 0.7, index, index + 0.7],
outputRange: [0.7, 1, 0.7],
});
return {
opacity,
transform: [{translateX}, {translateY}],
};
};
const TopLevelNavigator = createStackNavigator(
{
Home: {
screen: Home,
},
Editor: {
screen: Editor,
navigationOptions: {
gesturesEnabled: false,
},
},
Reminders: {
screen: Reminders,
},
Lists: {
screen: Lists,
},
Folders: {
screen: Folders,
},
Favorites: {
screen: Favorites,
},
ListsEditor: {
screen: ListsEditor,
},
ReminderEditor: {
screen: ReminderEditor,
},
Login: {
screen: Login,
},
Signup: {
screen: Signup,
},
ForgotPassword: {
screen: ForgotPassword,
},
Settings: {
screen: Settings,
},
Trash: {
screen: Trash,
},
Notes: {
screen: Notes,
},
Tags: {
screen: Tags,
},
Notebook: {
screen: Notebook,
},
AccountSettings: {
screen: AccountSettings,
},
AppearanceSettings: {
screen: AppearanceSettings,
},
EditorSettings: {
screen: EditorSettings,
},
},
{
initialRouteName: 'Home',
defaultNavigationOptions: {
gesturesEnabled: false,
headerStyle: {
backgroundColor: 'transparent',
borderBottomWidth: 0,
height: 0,
},
},
cardOverlayEnabled: true,
cardShadowEnabled: true,
animationEnabled: false,
},
);
export const AppContainer = createAppContainer(TopLevelNavigator);
let _navigator;

View File

@@ -0,0 +1,120 @@
import AccountSettings from '../views/AccountSettings';
import Editor from '../views/Editor';
import Favorites from '../views/Favorites';
import Folders from '../views/Folders';
import ForgotPassword from '../views/ForgotPassword';
import Home from '../views/Home/index';
import Lists from '../views/Lists';
import ListsEditor from '../views/ListsEditor';
import Login from '../views/Login';
import Notebook from '../views/Notebook';
import Notes from '../views/Notes';
import ReminderEditor from '../views/ReminderEditor';
import Reminders from '../views/Reminders';
import Settings from '../views/Settings';
import Signup from '../views/Signup';
import Tags from '../views/Tags';
import Trash from '../views/Trash';
import AppearanceSettings from '../views/AppearanceSettings';
import EditorSettings from '../views/EditorSettings';
import { createStackNavigator } from 'react-navigation-stack';
const fade = props => {
const { position, scene } = props;
const index = scene.index;
const translateX = 0;
const translateY = 0;
const opacity = position.interpolate({
inputRange: [index - 0.7, index, index + 0.7],
outputRange: [0.7, 1, 0.7],
});
return {
opacity,
transform: [{ translateX }, { translateY }],
};
};
export const TopLevelNavigator = createStackNavigator(
{
Home: {
screen: Home,
},
Editor: {
screen: Editor,
navigationOptions: {
gesturesEnabled: false,
},
},
Reminders: {
screen: Reminders,
},
Lists: {
screen: Lists,
},
Folders: {
screen: Folders,
},
Favorites: {
screen: Favorites,
},
ListsEditor: {
screen: ListsEditor,
},
ReminderEditor: {
screen: ReminderEditor,
},
Login: {
screen: Login,
},
Signup: {
screen: Signup,
},
ForgotPassword: {
screen: ForgotPassword,
},
Settings: {
screen: Settings,
},
Trash: {
screen: Trash,
},
Notes: {
screen: Notes,
},
Tags: {
screen: Tags,
},
Notebook: {
screen: Notebook,
},
AccountSettings: {
screen: AccountSettings,
},
AppearanceSettings: {
screen: AppearanceSettings,
},
EditorSettings: {
screen: EditorSettings,
},
},
{
initialRouteName: 'Home',
defaultNavigationOptions: {
gesturesEnabled: false,
headerStyle: {
backgroundColor: 'transparent',
borderBottomWidth: 0,
height: 0,
},
},
cardOverlayEnabled: true,
cardShadowEnabled: true,
animationEnabled: false,
},
);

View File

@@ -8,10 +8,6 @@ import SimpleList from '../../components/SimpleList';
import { useTracked } from '../../provider';
import { ACTIONS } from '../../provider/actions';
import NavigationService from '../../services/NavigationService';
import {db} from '../../utils/utils';
const w = Dimensions.get('window').width;
const h = Dimensions.get('window').height;
export const Tags = ({ navigation }) => {
const [state, dispatch] = useTracked();

View File

@@ -1,10 +1,6 @@
import React, { useEffect, useState } from 'react';
import { useIsFocused } from 'react-navigation-hooks';
import Container from '../../components/Container';
import {
simpleDialogEvent,
TEMPLATE_EMPTY_TRASH,
} from '../../components/DialogManager';
import { TrashPlaceHolder } from '../../components/ListPlaceholders';
import { NotebookItem } from '../../components/NotebookItem';
import NoteItem from '../../components/NoteItem';
@@ -13,6 +9,8 @@ import SimpleList from '../../components/SimpleList';
import { useTracked } from '../../provider';
import { ACTIONS } from '../../provider/actions';
import { db, ToastEvent, w } from '../../utils/utils';
import { simpleDialogEvent } from '../../components/DialogManager/recievers';
import { TEMPLATE_EMPTY_TRASH } from '../../components/DialogManager/templates';
export const Trash = ({ navigation }) => {
const [state, dispatch] = useTracked();