2022-08-26 16:19:39 +05:00
|
|
|
import { NavigationContainer } from "@react-navigation/native";
|
|
|
|
|
import { createNativeStackNavigator } from "@react-navigation/native-stack";
|
|
|
|
|
import * as React from "react";
|
|
|
|
|
import Container from "../components/container";
|
|
|
|
|
import Intro from "../components/intro";
|
|
|
|
|
import Favorites from "../screens/favorites";
|
|
|
|
|
import Home from "../screens/home";
|
|
|
|
|
import Notebook from "../screens/notebook";
|
|
|
|
|
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";
|
|
|
|
|
import { Search } from "../screens/search";
|
|
|
|
|
import Settings from "../screens/settings";
|
|
|
|
|
import AppLock from "../screens/settings/app-lock";
|
|
|
|
|
import Tags from "../screens/tags";
|
|
|
|
|
import Trash from "../screens/trash";
|
|
|
|
|
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";
|
|
|
|
|
import { useThemeStore } from "../stores/use-theme-store";
|
|
|
|
|
import { history } from "../utils";
|
|
|
|
|
import { rootNavigatorRef } from "../utils/global-refs";
|
|
|
|
|
import { hideAllTooltips } from "../hooks/use-tooltip";
|
|
|
|
|
import { useWindowDimensions } from "react-native";
|
|
|
|
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
|
|
|
import { useSettingStore } from "../stores/use-setting-store";
|
2022-06-13 10:55:56 +05:00
|
|
|
const NativeStack = createNativeStackNavigator();
|
2022-07-05 14:33:48 +05:00
|
|
|
const IntroStack = createNativeStackNavigator();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Intro Stack:
|
|
|
|
|
*
|
|
|
|
|
* Welcome Page
|
|
|
|
|
* Select Privacy Mode Page
|
|
|
|
|
* Login/Signup Page
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const IntroStackNavigator = () => {
|
2022-08-26 16:19:39 +05:00
|
|
|
const colors = useThemeStore((state) => state.colors);
|
2022-07-05 14:33:48 +05:00
|
|
|
return (
|
|
|
|
|
<IntroStack.Navigator
|
|
|
|
|
screenOptions={{
|
|
|
|
|
headerShown: false,
|
|
|
|
|
lazy: false,
|
2022-08-26 16:19:39 +05:00
|
|
|
animation: "none",
|
2022-07-05 14:33:48 +05:00
|
|
|
contentStyle: {
|
|
|
|
|
backgroundColor: colors.bg
|
|
|
|
|
}
|
|
|
|
|
}}
|
2022-08-26 16:19:39 +05:00
|
|
|
initialRouteName={"Intro"}
|
2022-07-05 14:33:48 +05:00
|
|
|
>
|
|
|
|
|
<NativeStack.Screen name="Intro" component={Intro} />
|
|
|
|
|
<NativeStack.Screen name="AppLock" component={AppLock} />
|
|
|
|
|
</IntroStack.Navigator>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2022-04-24 05:59:14 +05:00
|
|
|
const Tabs = React.memo(
|
|
|
|
|
() => {
|
2022-08-26 16:19:39 +05:00
|
|
|
const colors = useThemeStore((state) => state.colors);
|
2022-04-24 05:59:14 +05:00
|
|
|
const homepage = SettingsService.get().homepage;
|
2022-08-26 16:19:39 +05:00
|
|
|
const introCompleted = useSettingStore(
|
|
|
|
|
(state) => state.settings.introCompleted
|
|
|
|
|
);
|
|
|
|
|
const height = useSettingStore((state) => state.dimensions.height);
|
2022-07-20 09:16:38 +05:00
|
|
|
const insets = useSafeAreaInsets();
|
|
|
|
|
const screenHeight = height - (50 + insets.top + insets.bottom);
|
2022-04-24 05:59:14 +05:00
|
|
|
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}
|
2022-08-26 16:19:39 +05:00
|
|
|
initialRouteName={!introCompleted ? "Welcome" : homepage}
|
2022-04-24 05:59:14 +05:00
|
|
|
backBehavior="history"
|
|
|
|
|
screenOptions={{
|
|
|
|
|
headerShown: false,
|
2022-06-13 10:55:56 +05:00
|
|
|
lazy: false,
|
2022-08-26 16:19:39 +05:00
|
|
|
animation: "none",
|
2022-06-13 10:55:56 +05:00
|
|
|
contentStyle: {
|
2022-07-20 09:16:38 +05:00
|
|
|
backgroundColor: colors.bg,
|
2022-07-20 11:11:12 +05:00
|
|
|
height: !introCompleted ? undefined : screenHeight
|
2022-06-13 10:55:56 +05:00
|
|
|
}
|
2022-04-24 05:59:14 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2022-07-05 14:33:48 +05:00
|
|
|
<NativeStack.Screen name="Welcome" component={IntroStackNavigator} />
|
2022-06-13 10:55:56 +05:00
|
|
|
<NativeStack.Screen name="Notes" component={Home} />
|
|
|
|
|
<NativeStack.Screen name="Notebooks" component={Notebooks} />
|
2022-08-26 16:19:39 +05:00
|
|
|
<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}
|
|
|
|
|
/>
|
2022-06-13 10:55:56 +05:00
|
|
|
<NativeStack.Screen name="Settings" component={Settings} />
|
2022-08-26 16:19:39 +05:00
|
|
|
<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}
|
|
|
|
|
/>
|
2022-06-13 10:55:56 +05:00
|
|
|
</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
|
|
|
() => {
|
2022-08-26 16:19:39 +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();
|
2022-08-26 16:19:39 +05:00
|
|
|
eSendEvent("navigate");
|
2021-02-15 11:00:13 +05:00
|
|
|
});
|
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-08-26 16:19:39 +05:00
|
|
|
<NavigationContainer
|
|
|
|
|
onStateChange={onStateChange}
|
|
|
|
|
ref={rootNavigatorRef}
|
|
|
|
|
>
|
2022-04-24 05:59:14 +05:00
|
|
|
<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
|
|
|
);
|