diff --git a/apps/mobile/index.js b/apps/mobile/index.js index cb28667c9..7cd4ca176 100644 --- a/apps/mobile/index.js +++ b/apps/mobile/index.js @@ -1,9 +1,13 @@ +import "react-native-gesture-handler"; import 'react-native-get-random-values' +import { enableScreens } from 'react-native-screens'; import { AppRegistry } from 'react-native'; import App from './App'; import { name as appName } from './app.json'; import React from 'react'; import { Provider } from './src/provider'; +enableScreens(); + const AppProvider = () => { return ( diff --git a/apps/mobile/index.mobile.js b/apps/mobile/index.mobile.js index bbbb2741e..fab2f8588 100644 --- a/apps/mobile/index.mobile.js +++ b/apps/mobile/index.mobile.js @@ -1,22 +1,20 @@ -import React, { useEffect, createRef } from 'react'; -import Animated from 'react-native-reanimated'; -import { Menu } from './src/components/Menu'; +import React, {createRef, useEffect} from 'react'; +import {Platform, StatusBar, View} from 'react-native'; import * as Animatable from 'react-native-animatable'; +import Animated from 'react-native-reanimated'; +import {Menu} from './src/components/Menu'; import SideMenu from './src/components/SideMenu'; -import { EditorPosition, EditorOpacity } from './src/utils/animations'; -import { sideMenuRef } from './src/utils/refs'; -import { DDS, w } from './src/utils/utils'; +import {useTracked} from './src/provider'; +import {EditorOpacity, 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'; -import { useSafeArea } from 'react-native-safe-area-context'; +import {NavigationStack} from './src/services/Navigator'; const editorRef = createRef(); export const Initialize = () => { const [state, dispatch] = useTracked(); - const { colors } = state; + const {colors} = state; useEffect(() => { if (Platform.OS === 'android') { @@ -52,16 +50,14 @@ export const Initialize = () => { /> } openMenuOffset={w / 1.5}> - { - NavigationService.setTopLevelNavigator(navigatorRef); - }} - /> + }}> + + { position: 'absolute', backgroundColor: colors.bg, elevation: 10, - opacity:EditorOpacity, + opacity: EditorOpacity, transform: [ { translateX: EditorPosition, diff --git a/apps/mobile/index.tablet.js b/apps/mobile/index.tablet.js index 431c47915..6de0760b6 100644 --- a/apps/mobile/index.tablet.js +++ b/apps/mobile/index.tablet.js @@ -4,23 +4,18 @@ 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 { eSendEvent, eSubscribeEvent } from './src/services/eventManager'; +import { eCloseFullscreenEditor, eOnLoadNote, eOpenFullscreenEditor } from './src/services/events'; +import { NavigationStack } from './src/services/Navigator'; import Editor from './src/views/Editor'; -import { eSubscribeEvent, eSendEvent } from './src/services/eventManager'; -import { - eOpenFullscreenEditor, - eCloseFullscreenEditor, - eOnLoadNote, -} from './src/services/events'; -import { AppContainer } from './src/services/AppContainer'; -import NavigationService from './src/services/NavigationService'; + const editorRef = createRef(); let outColors; export const Initialize = () => { const [state, dispatch] = useTracked(); - const { colors } = state; + const {colors} = state; const [fullscreen, setFullscreen] = useState(false); @@ -56,7 +51,7 @@ export const Initialize = () => { }; useEffect(() => { - eSendEvent(eOnLoadNote, { type: 'new' }); + eSendEvent(eOnLoadNote, {type: 'new'}); eSubscribeEvent(eOpenFullscreenEditor, showFullScreenEditor); eSubscribeEvent(eCloseFullscreenEditor, closeFullScreenEditor); @@ -104,15 +99,7 @@ export const Initialize = () => { borderRightColor: colors.nav, borderRightWidth: 2, }}> - { - NavigationService.setTopLevelNavigator(navigatorRef); - }} - /> + - +{/* (this.moveNoteDialog = ref)} colors={colors} - /> + /> */} (this.addTopicsDialog = ref)} @@ -329,7 +309,7 @@ export class DialogManager extends Component { colors={colors} /> - (this.loginDialog = ref)} /> + {/* (this.loginDialog = ref)} /> */} diff --git a/apps/mobile/src/components/LoginDialog/index.js b/apps/mobile/src/components/LoginDialog/index.js index ea66d8fdf..5e939c315 100644 --- a/apps/mobile/src/components/LoginDialog/index.js +++ b/apps/mobile/src/components/LoginDialog/index.js @@ -1,4 +1,4 @@ -import React from 'react'; +/* import React from 'react'; import {Modal, TouchableOpacity, View} from 'react-native'; import * as Animatable from 'react-native-animatable'; import {createAppContainer} from 'react-navigation'; @@ -169,3 +169,4 @@ class LoginDialog extends React.Component { } export default LoginDialog; + */ \ No newline at end of file diff --git a/apps/mobile/src/components/MoveNoteDialog/index.js b/apps/mobile/src/components/MoveNoteDialog/index.js index 7b49c23e1..54d74cb6c 100644 --- a/apps/mobile/src/components/MoveNoteDialog/index.js +++ b/apps/mobile/src/components/MoveNoteDialog/index.js @@ -1,4 +1,4 @@ -import React from 'react'; +/* import React from 'react'; import {Modal, TouchableOpacity, View} from 'react-native'; import * as Animatable from 'react-native-animatable'; import {createAppContainer} from 'react-navigation'; @@ -175,3 +175,4 @@ class MoveNoteDialog extends React.Component { } export default MoveNoteDialog; + */ \ No newline at end of file diff --git a/apps/mobile/src/services/AppContainer.js b/apps/mobile/src/services/AppContainer.js deleted file mode 100644 index a5cd7d818..000000000 --- a/apps/mobile/src/services/AppContainer.js +++ /dev/null @@ -1,6 +0,0 @@ -import { TopLevelNavigator } from "./Navigator"; -import { - createAppContainer, -} from 'react-navigation'; - -export const AppContainer = createAppContainer(TopLevelNavigator); \ No newline at end of file diff --git a/apps/mobile/src/services/NavigationService.js b/apps/mobile/src/services/NavigationService.js index b9187d4a0..09f535b25 100755 --- a/apps/mobile/src/services/NavigationService.js +++ b/apps/mobile/src/services/NavigationService.js @@ -1,43 +1,19 @@ -import { - NavigationActions, - StackActions, -} from 'react-navigation'; +import { StackActions } from '@react-navigation/routers'; +import { rootNavigatorRef } from '../utils/refs'; - - -let _navigator; - -function setTopLevelNavigator(navigatorRef) { - _navigator = navigatorRef; +function navigate(name, params) { + rootNavigatorRef .current?.navigate(name, params); } - -function navigate(routeName, params) { - _navigator.dispatch( - NavigationActions.navigate({ - routeName, - params, - }), - ); -} - -function push(routeName, params) { - _navigator.dispatch( - StackActions.push({ - routeName, - params, - }), - ); -} - function goBack() { - _navigator.dispatch(NavigationActions.back()); + rootNavigatorRef.current?.goBack(); } -// add other navigation functions that you need and export them +function push(...args) { + rootNavigatorRef.current?.dispatch(StackActions.push(...args)); +} export default { navigate, - push, goBack, - setTopLevelNavigator, -}; + push, +}; \ No newline at end of file diff --git a/apps/mobile/src/services/Navigator.js b/apps/mobile/src/services/Navigator.js index f9d04a703..99781e310 100644 --- a/apps/mobile/src/services/Navigator.js +++ b/apps/mobile/src/services/Navigator.js @@ -1,105 +1,44 @@ -import Editor from '../views/Editor'; +import {NavigationContainer} from '@react-navigation/native'; +import {createStackNavigator} from '@react-navigation/stack'; +import * as React from 'react'; 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 {createStackNavigator} from 'react-navigation-stack'; -import {Animated} from 'react-native'; -const fade = props => { - const {position, scene} = props; - const index = scene.index; - const translateX = 0; - const translateY = 0; +import {rootNavigatorRef} from '../utils/refs'; - const opacity = position.interpolate({ - inputRange: [index - 0.7, index, index + 0.7], - outputRange: [0.7, 1, 0.7], - }); +const Stack = createStackNavigator(); - return { - opacity, - transform: [{translateX}, {translateY}], - }; +export const NavigationStack = () => { + return ( + + + + + + + + + + + + + + + ); }; -export const TopLevelNavigator = createStackNavigator( - { - Home: { - screen: Home, - }, - Editor: { - screen: Editor, - navigationOptions: { - gesturesEnabled: false, - }, - }, - Lists: { - screen: Lists, - }, - Folders: { - screen: Folders, - }, - Favorites: { - screen: Favorites, - }, - ListsEditor: { - screen: ListsEditor, - }, - Login: { - screen: Login, - }, - Signup: { - screen: Signup, - }, - ForgotPassword: { - screen: ForgotPassword, - }, - Settings: { - screen: Settings, - }, - Trash: { - screen: Trash, - }, - Notes: { - screen: Notes, - }, - Tags: { - screen: Tags, - }, - Notebook: { - screen: Notebook, - }, - }, - { - initialRouteName: 'Home', - defaultNavigationOptions: { - gestureEnabled: false, - headerStyle: { - backgroundColor: 'transparent', - borderBottomWidth: 0, - height: 0, - }, - }, - animationEnabled: false, - transitionConfig: () => ({ - transitionSpec: { - duration: 0, - timing: Animated.timing, - }, - }), - cardOverlayEnabled: true, - cardShadowEnabled: true, - animationEnabled: false, - }, -); diff --git a/apps/mobile/src/utils/refs.js b/apps/mobile/src/utils/refs.js index f0aeccc41..41513776f 100644 --- a/apps/mobile/src/utils/refs.js +++ b/apps/mobile/src/utils/refs.js @@ -3,3 +3,4 @@ import {createRef} from 'react'; export const sideMenuRef = createRef(); export const inputRef = createRef(); export const sideMenuOverlayRef = createRef(); +export const rootNavigatorRef = createRef(); diff --git a/apps/mobile/src/views/Favorites/index.js b/apps/mobile/src/views/Favorites/index.js index 6c15af349..d2f459977 100644 --- a/apps/mobile/src/views/Favorites/index.js +++ b/apps/mobile/src/views/Favorites/index.js @@ -1,5 +1,4 @@ import React, {useEffect, useState} from 'react'; -import {useIsFocused} from 'react-navigation-hooks'; import Container from '../../components/Container'; import {FavoritesPlaceHolder} from '../../components/ListPlaceholders'; import {NotebookItem} from '../../components/NotebookItem'; @@ -9,7 +8,7 @@ import {useTracked} from '../../provider'; import {ACTIONS} from '../../provider/actions'; import {ToastEvent, w, db} from '../../utils/utils'; import SimpleList from '../../components/SimpleList'; - +import { useIsFocused } from '@react-navigation/native'; export const Favorites = ({navigation}) => { const [state, dispatch] = useTracked(); const {colors, selectionMode, favorites} = state; @@ -118,8 +117,5 @@ export const Favorites = ({navigation}) => { ); }; -Favorites.navigationOptions = { - header: null, -}; export default Favorites; diff --git a/apps/mobile/src/views/Folders/index.js b/apps/mobile/src/views/Folders/index.js index f2028b713..1b69ffa72 100644 --- a/apps/mobile/src/views/Folders/index.js +++ b/apps/mobile/src/views/Folders/index.js @@ -1,7 +1,8 @@ -import React, {useEffect, useState} from 'react'; +import {useIsFocused} from '@react-navigation/native'; +import React, {useEffect} from 'react'; import {BackHandler} from 'react-native'; -import {useIsFocused} from 'react-navigation-hooks'; import Container from '../../components/Container'; +import {AddNotebookEvent} from '../../components/DialogManager/recievers'; import {NotebookPlaceHolder} from '../../components/ListPlaceholders'; import {NotebookItem} from '../../components/NotebookItem'; import SelectionWrapper from '../../components/SelectionWrapper'; @@ -10,12 +11,10 @@ import {useTracked} from '../../provider'; import {ACTIONS} from '../../provider/actions'; import {eSendEvent} from '../../services/eventManager'; import {eScrollEvent} from '../../services/events'; -import {slideLeft, slideRight} from '../../utils/animations'; -import {ToastEvent, w, db} from '../../utils/utils'; -import {AddNotebookEvent} from '../../components/DialogManager/recievers'; import NavigationService from '../../services/NavigationService'; - -export const Folders = ({navigation}) => { +import {slideRight} from '../../utils/animations'; +import {w} from '../../utils/utils'; +export const Folders = ({route, navigation}) => { const [state, dispatch] = useTracked(); const { colors, @@ -27,7 +26,7 @@ export const Folders = ({navigation}) => { let isFocused = useIsFocused(); const handleBackPress = () => { - if (navigation.state.params.isMove) { + if (route.params.isMove) { return true; } else { NavigationService.goBack(); @@ -62,7 +61,7 @@ export const Folders = ({navigation}) => { }; }, []); - const params = navigation.state.params; + const params = route.params; const _renderItem = ({item, index}) => ( @@ -129,8 +128,4 @@ export const Folders = ({navigation}) => { ); }; -Folders.navigationOptions = { - header: null, -}; - export default Folders; diff --git a/apps/mobile/src/views/ForgotPassword/index.js b/apps/mobile/src/views/ForgotPassword/index.js index bd59a6209..3cf6a31ca 100644 --- a/apps/mobile/src/views/ForgotPassword/index.js +++ b/apps/mobile/src/views/ForgotPassword/index.js @@ -1,13 +1,12 @@ import React, {createRef, useEffect} from 'react'; import {SafeAreaView, Text, TouchableOpacity, View} from 'react-native'; import {TextInput} from 'react-native-gesture-handler'; -import {useIsFocused} from 'react-navigation-hooks'; import {opacity, pv, SIZE, WEIGHT, DDS} from '../../common/common'; import {Header} from '../../components/header'; import {useTracked} from '../../provider'; import {eSubscribeEvent, eUnSubscribeEvent} from '../../services/eventManager'; import {eLoginDialogNavigateBack} from '../../services/events'; - +import { useIsFocused } from '@react-navigation/native'; export const ForgotPassword = ({navigation}) => { const [state, dispatch] = useTracked(); const {colors, isLoginNavigator} = state; diff --git a/apps/mobile/src/views/Home/index.js b/apps/mobile/src/views/Home/index.js index da15d6595..957242425 100755 --- a/apps/mobile/src/views/Home/index.js +++ b/apps/mobile/src/views/Home/index.js @@ -1,19 +1,18 @@ -import React, {useEffect, useState} from 'react'; -import {useIsFocused} from 'react-navigation-hooks'; +import { useIsFocused } from '@react-navigation/native'; +import React, { useEffect } from 'react'; import Container from '../../components/Container'; -import SelectionHeader from '../../components/SelectionHeader'; -import {useTracked} from '../../provider'; -import {ACTIONS} from '../../provider/actions'; -import {eSendEvent} from '../../services/eventManager'; -import {DDS, ToastEvent, db} from '../../utils/utils'; -import {eScrollEvent, eOnLoadNote} from '../../services/events'; -import {openEditorAnimation} from '../../utils/animations'; -import {sideMenuRef} from '../../utils/refs'; -import SimpleList from '../../components/SimpleList'; -import {NotesPlaceHolder} from '../../components/ListPlaceholders'; -import SelectionWrapper from '../../components/SelectionWrapper'; +import { NotesPlaceHolder } from '../../components/ListPlaceholders'; import NoteItem from '../../components/NoteItem'; -import {Platform} from 'react-native'; +import SelectionHeader from '../../components/SelectionHeader'; +import SelectionWrapper from '../../components/SelectionWrapper'; +import SimpleList from '../../components/SimpleList'; +import { useTracked } from '../../provider'; +import { ACTIONS } from '../../provider/actions'; +import { eSendEvent } from '../../services/eventManager'; +import { eOnLoadNote, eScrollEvent } from '../../services/events'; +import { openEditorAnimation } from '../../utils/animations'; +import { sideMenuRef } from '../../utils/refs'; +import { DDS } from '../../utils/utils'; let count = 0; export const Home = ({navigation}) => { @@ -110,13 +109,6 @@ export const Home = ({navigation}) => { ); }; -Home.navigationOptions = { - header: null, - headerStyle: { - backgroundColor: 'transparent', - borderBottomWidth: 0, - height: 0, - }, -}; + export default Home; diff --git a/apps/mobile/src/views/Login/index.js b/apps/mobile/src/views/Login/index.js index aa9f2179b..27d682330 100644 --- a/apps/mobile/src/views/Login/index.js +++ b/apps/mobile/src/views/Login/index.js @@ -9,7 +9,6 @@ import { import * as Animatable from 'react-native-animatable'; import {TextInput} from 'react-native-gesture-handler'; import Icon from 'react-native-vector-icons/MaterialCommunityIcons'; -import {useIsFocused} from 'react-navigation-hooks'; import {opacity, pv, SIZE, WEIGHT} from '../../common/common'; import {Header} from '../../components/header'; import {useTracked} from '../../provider'; @@ -18,7 +17,7 @@ import {eSendEvent} from '../../services/eventManager'; import {eCloseSideMenu, refreshNotesPage} from '../../services/events'; import {validatePass, validateUsername} from '../../services/validation'; import {db, DDS, ToastEvent, getElevation} from '../../utils/utils'; - +import { useIsFocused } from '@react-navigation/native'; @@ -542,13 +541,4 @@ export const Login = ({navigation}) => { ); }; -Login.navigationOptions = { - header: null, - headerStyle: { - backgroundColor: 'transparent', - borderBottomWidth: 0, - height: 0, - }, -}; - export default Login; diff --git a/apps/mobile/src/views/Notebook/index.js b/apps/mobile/src/views/Notebook/index.js index 58394d70a..d6a981d73 100644 --- a/apps/mobile/src/views/Notebook/index.js +++ b/apps/mobile/src/views/Notebook/index.js @@ -1,5 +1,4 @@ import React, {useEffect, useState} from 'react'; -import {useIsFocused} from 'react-navigation-hooks'; import Container from '../../components/Container'; import {AddTopicEvent} from '../../components/DialogManager/recievers'; import {NotebookPlaceHolder} from '../../components/ListPlaceholders'; @@ -8,6 +7,7 @@ import SelectionWrapper from '../../components/SelectionWrapper'; import SimpleList from '../../components/SimpleList'; import {useTracked} from '../../provider'; import {ACTIONS} from '../../provider/actions'; +import { useIsFocused } from '@react-navigation/native'; import { eSendEvent, eSubscribeEvent, @@ -155,8 +155,4 @@ export const Notebook = ({navigation}) => { ); }; -Notebook.navigationOptions = { - header: null, -}; - export default Notebook; diff --git a/apps/mobile/src/views/Notes/index.js b/apps/mobile/src/views/Notes/index.js index 29c35ef61..6bf01f5f1 100644 --- a/apps/mobile/src/views/Notes/index.js +++ b/apps/mobile/src/views/Notes/index.js @@ -1,5 +1,5 @@ import React, {useEffect, useState} from 'react'; -import {useIsFocused} from 'react-navigation-hooks'; +import { useIsFocused } from '@react-navigation/native'; import Container from '../../components/Container'; import {NotesPlaceHolder} from '../../components/ListPlaceholders'; import NoteItem from '../../components/NoteItem'; @@ -21,14 +21,14 @@ import {openEditorAnimation} from '../../utils/animations'; import {db, DDS, editing, ToastEvent} from '../../utils/utils'; import {sideMenuRef} from '../../utils/refs'; -export const Notes = ({navigation}) => { +export const Notes = ({route,navigation}) => { const [state, dispatch] = useTracked(); const {colors, selectionMode, currentEditingNote, colorNotes} = state; const allNotes = state.notes; const [notes, setNotes] = useState([]); const [refreshing, setRefreshing] = useState(false); const isFocused = useIsFocused(); - let params = navigation.state ? navigation.state.params : null; + let params = route.params ? route.params : null; useEffect(() => { if (!params) { @@ -64,24 +64,21 @@ export const Notes = ({navigation}) => { }, []); const init = (data) => { - params = navigation.state.params; + params = route.params; if (data) { params = data; } eSendEvent(eScrollEvent, 0); if (params.type === 'tag') { let notesInTag = db.notes.tagged(params.tag.title); - setNotes([...notesInTag]); } else if (params.type == 'color') { let notesInColors = db.notes.colored(params.color.title); - setNotes([...notesInColors]); } else { let allNotes = db.notebooks .notebook(params.notebookId) .topics.topic(params.title).all; - if (allNotes && allNotes.length > 0) { setNotes([...allNotes]); } @@ -200,8 +197,4 @@ export const Notes = ({navigation}) => { ); }; -Notes.navigationOptions = { - header: null, -}; - export default Notes; diff --git a/apps/mobile/src/views/Settings/index.js b/apps/mobile/src/views/Settings/index.js index 4ba31b34f..308624f20 100644 --- a/apps/mobile/src/views/Settings/index.js +++ b/apps/mobile/src/views/Settings/index.js @@ -780,8 +780,5 @@ export const Settings = ({navigation}) => { ); }; -Settings.navigationOptions = { - header: null, -}; export default Settings; diff --git a/apps/mobile/src/views/Signup/index.js b/apps/mobile/src/views/Signup/index.js index 29241245e..6be9030b5 100644 --- a/apps/mobile/src/views/Signup/index.js +++ b/apps/mobile/src/views/Signup/index.js @@ -10,7 +10,7 @@ import { } from 'react-native'; import {TextInput} from 'react-native-gesture-handler'; import QRCode from 'react-native-qrcode-generator'; -import {useIsFocused} from 'react-navigation-hooks'; +import { useIsFocused } from '@react-navigation/native'; import {opacity, pv, SIZE, WEIGHT, ph} from '../../common/common'; import {Header} from '../../components/header'; import {useTracked} from '../../provider'; @@ -704,13 +704,6 @@ export const Signup = ({navigation}) => { ); }; -Signup.navigationOptions = { - header: null, - headerStyle: { - backgroundColor: 'transparent', - borderBottomWidth: 0, - height: 0, - }, -}; + export default Signup; diff --git a/apps/mobile/src/views/Tags/index.js b/apps/mobile/src/views/Tags/index.js index 949db6603..c6a58783c 100644 --- a/apps/mobile/src/views/Tags/index.js +++ b/apps/mobile/src/views/Tags/index.js @@ -1,6 +1,6 @@ import React, {useEffect} from 'react'; import {Text, TouchableOpacity, View} from 'react-native'; -import {useIsFocused} from 'react-navigation-hooks'; +import { useIsFocused } from '@react-navigation/native'; import {pv, SIZE, WEIGHT} from '../../common/common'; import Container from '../../components/Container'; import {TagsPlaceHolder} from '../../components/ListPlaceholders'; @@ -99,8 +99,4 @@ export const Tags = ({navigation}) => { ); }; -Tags.navigationOptions = { - header: null, -}; - export default Tags; diff --git a/apps/mobile/src/views/Trash/index.js b/apps/mobile/src/views/Trash/index.js index 1aab8dfde..17b3ef37c 100644 --- a/apps/mobile/src/views/Trash/index.js +++ b/apps/mobile/src/views/Trash/index.js @@ -1,5 +1,5 @@ import React, {useEffect} from 'react'; -import {useIsFocused} from 'react-navigation-hooks'; +import { useIsFocused } from '@react-navigation/native'; import Container from '../../components/Container'; import {simpleDialogEvent} from '../../components/DialogManager/recievers'; import {TEMPLATE_EMPTY_TRASH} from '../../components/DialogManager/templates'; @@ -108,8 +108,4 @@ export const Trash = ({navigation}) => { ); }; -Trash.navigationOptions = { - header: null, -}; - export default Trash;