2022-04-24 05:59:14 +05:00
|
|
|
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
|
2022-01-22 12:57:05 +05:00
|
|
|
import { NavigationContainer } from '@react-navigation/native';
|
2022-06-13 10:55:56 +05:00
|
|
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
2020-10-13 17:02:14 +05:00
|
|
|
import * as React from 'react';
|
2022-02-28 13:48:59 +05:00
|
|
|
import Container from '../components/container';
|
2022-02-28 15:32:55 +05:00
|
|
|
import Favorites from '../screens/favorites';
|
|
|
|
|
import Home from '../screens/home';
|
|
|
|
|
import Notebook from '../screens/notebook';
|
2022-04-24 05:59:14 +05:00
|
|
|
import Notebooks from '../screens/notebooks';
|
|
|
|
|
import { ColoredNotes } from '../screens/notes/colored';
|
|
|
|
|
import { Monographs } from '../screens/notes/monographs';
|
|
|
|
|
import { TaggedNotes } from '../screens/notes/tagged';
|
|
|
|
|
import { TopicNotes } from '../screens/notes/topic-notes';
|
2022-02-28 15:32:55 +05:00
|
|
|
import { Search } from '../screens/search';
|
|
|
|
|
import Settings from '../screens/settings';
|
|
|
|
|
import Tags from '../screens/tags';
|
|
|
|
|
import Trash from '../screens/trash';
|
2022-04-24 05:59:14 +05:00
|
|
|
import { eSendEvent } from '../services/event-manager';
|
|
|
|
|
import SettingsService from '../services/settings';
|
|
|
|
|
import useNavigationStore from '../stores/use-navigation-store';
|
|
|
|
|
import { useSelectionStore } from '../stores/use-selection-store';
|
2022-06-13 10:55:56 +05:00
|
|
|
import { useThemeStore } from '../stores/use-theme-store';
|
2022-04-24 05:59:14 +05:00
|
|
|
import { history } from '../utils';
|
|
|
|
|
import { rootNavigatorRef } from '../utils/global-refs';
|
|
|
|
|
import { hideAllTooltips } from '../utils/hooks/use-tooltip';
|
2022-06-13 10:55:56 +05:00
|
|
|
const NativeStack = createNativeStackNavigator();
|
2022-04-24 05:59:14 +05:00
|
|
|
const Tabs = React.memo(
|
|
|
|
|
() => {
|
2022-06-13 10:55:56 +05:00
|
|
|
const colors = useThemeStore(state => state.colors);
|
2022-04-24 05:59:14 +05:00
|
|
|
const homepage = SettingsService.get().homepage;
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
useNavigationStore.getState().update({ name: homepage });
|
|
|
|
|
}, 1000);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return (
|
2022-06-13 10:55:56 +05:00
|
|
|
<NativeStack.Navigator
|
2022-04-24 05:59:14 +05:00
|
|
|
tabBar={() => null}
|
|
|
|
|
initialRouteName={homepage}
|
|
|
|
|
backBehavior="history"
|
|
|
|
|
screenOptions={{
|
|
|
|
|
headerShown: false,
|
2022-06-13 10:55:56 +05:00
|
|
|
lazy: false,
|
|
|
|
|
animation: 'none',
|
|
|
|
|
contentStyle: {
|
|
|
|
|
backgroundColor: colors.bg
|
|
|
|
|
}
|
2022-04-24 05:59:14 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-06-13 10:55:56 +05:00
|
|
|
<NativeStack.Screen name="Notes" component={Home} />
|
|
|
|
|
<NativeStack.Screen name="Notebooks" component={Notebooks} />
|
|
|
|
|
<NativeStack.Screen options={{ lazy: true }} name="Favorites" component={Favorites} />
|
|
|
|
|
<NativeStack.Screen options={{ lazy: true }} name="Trash" component={Trash} />
|
|
|
|
|
<NativeStack.Screen options={{ lazy: true }} name="Tags" component={Tags} />
|
|
|
|
|
<NativeStack.Screen name="Settings" component={Settings} />
|
|
|
|
|
<NativeStack.Screen options={{ lazy: true }} name="TaggedNotes" component={TaggedNotes} />
|
|
|
|
|
<NativeStack.Screen options={{ lazy: true }} name="TopicNotes" component={TopicNotes} />
|
|
|
|
|
<NativeStack.Screen options={{ lazy: true }} name="ColoredNotes" component={ColoredNotes} />
|
|
|
|
|
<NativeStack.Screen options={{ lazy: true }} name="Monographs" component={Monographs} />
|
|
|
|
|
<NativeStack.Screen options={{ lazy: true }} name="Notebook" component={Notebook} />
|
|
|
|
|
<NativeStack.Screen options={{ lazy: true }} name="Search" component={Search} />
|
|
|
|
|
</NativeStack.Navigator>
|
2022-04-24 05:59:14 +05:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
() => true
|
|
|
|
|
);
|
2020-10-13 17:02:14 +05:00
|
|
|
|
2022-02-28 15:32:55 +05:00
|
|
|
export const NavigationStack = React.memo(
|
2020-11-14 10:04:11 +05:00
|
|
|
() => {
|
2021-06-05 21:10:20 +05:00
|
|
|
const clearSelection = useSelectionStore(state => state.clearSelection);
|
2022-01-08 11:33:35 +05:00
|
|
|
|
2021-02-15 11:00:13 +05:00
|
|
|
const onStateChange = React.useCallback(() => {
|
2021-04-11 14:04:14 +05:00
|
|
|
if (history.selectionMode) {
|
2021-12-31 12:35:39 +05:00
|
|
|
clearSelection(true);
|
2021-04-11 14:04:14 +05:00
|
|
|
}
|
2022-02-19 13:48:48 +05:00
|
|
|
hideAllTooltips();
|
2021-02-15 11:00:13 +05:00
|
|
|
eSendEvent('navigate');
|
|
|
|
|
});
|
2020-11-26 22:19:15 +05:00
|
|
|
|
2020-11-14 10:04:11 +05:00
|
|
|
return (
|
2022-04-29 00:44:21 +05:00
|
|
|
<Container>
|
2022-04-24 05:59:14 +05:00
|
|
|
<NavigationContainer onStateChange={onStateChange} ref={rootNavigatorRef}>
|
|
|
|
|
<Tabs />
|
2020-11-14 10:04:11 +05:00
|
|
|
</NavigationContainer>
|
|
|
|
|
</Container>
|
|
|
|
|
);
|
|
|
|
|
},
|
2022-01-08 11:33:35 +05:00
|
|
|
() => true
|
2020-11-14 10:04:11 +05:00
|
|
|
);
|