diff --git a/src/App.tsx b/src/App.tsx index fbe132f..0699aef 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -18,51 +18,13 @@ import "react-native-gesture-handler"; import { enableScreens } from "react-native-screens"; import { useSelector } from "react-redux"; import { StoreState } from "./store"; -import { RootStackParamList } from "./RootStackParamList"; +import { linking } from "./NavigationConfig"; import { DarkTheme, LightTheme } from "./theme"; enableScreens(); const DrawerNavigation = createDrawerNavigator(); -type RootStackScreens = { - [route in keyof RootStackParamList]: string; -}; - -const rootStackScreens: RootStackScreens = { - Home: "", - Login: "login", - Signup: "signup", - CollectionCreate: "new-notebook", - Collection: "notebook/:colUid", - CollectionEdit: "notebook/:colUid/edit", - CollectionChangelog: "notebook/:colUid/manage", - CollectionMembers: "notebook/:colUid/members", - NoteCreate: "new-note", - NoteEdit: "notebook/:colUid/note/:itemUid", - NoteProps: "notebook/:colUid/note/:itemUid/properties", - NoteMove: "notebook/:colUid/note/:itemUid/move", - Invitations: "invitations", - Settings: "settings", - About: "settings/about", - Password: "settings/password", - DebugLogs: "settings/logs", - AccountWizard: "account-wizard", - "404": "*", -}; - -const linking = { - prefixes: ["https://notes.etesync.com", "com.etesync.notes://"], - config: { - screens: { - Root: { - path: "", - screens: rootStackScreens, - }, - }, - }, -}; - function InnerApp() { // XXX Workaround for react-navigation #7561 (flashing drawer) const [initRender, setInitRender] = React.useState(true); diff --git a/src/Drawer.tsx b/src/Drawer.tsx index b41a5c4..04cc5e0 100644 --- a/src/Drawer.tsx +++ b/src/Drawer.tsx @@ -21,7 +21,7 @@ import LogoutDialog from "./components/LogoutDialog"; import * as C from "./constants"; import { useCredentials } from "./credentials"; -import { RootStackParamList } from "./RootStackParamList"; +import { RootStackParamList } from "./NavigationConfig"; type MenuItem = { title: string; diff --git a/src/NavigationConfig.tsx b/src/NavigationConfig.tsx new file mode 100644 index 0000000..862b339 --- /dev/null +++ b/src/NavigationConfig.tsx @@ -0,0 +1,76 @@ + +import { StackNavigationProp } from "@react-navigation/stack"; + +export type RootStackParamList = { + Home: undefined; + Login: undefined; + Signup: undefined; + CollectionCreate: undefined; + Collection: { colUid: string }; + CollectionEdit: { colUid: string }; + CollectionChangelog: { colUid: string }; + CollectionMembers: { colUid: string }; + NoteCreate: { + colUid: string; + itemUid?: undefined; + } | undefined; + NoteEdit: { + colUid: string; + itemUid: string; + }; + NoteProps: { + colUid: string; + itemUid: string; + }; + NoteMove: { + colUid: string; + itemUid: string; + }; + Invitations: undefined; + Settings: undefined; + Password: undefined; + About: undefined; + DebugLogs: undefined; + AccountWizard: undefined; + "404": undefined; +}; + +export type DefaultNavigationProp = StackNavigationProp; + +type RootStackScreens = { + [route in keyof RootStackParamList]: string; +}; + +const rootStackScreens: RootStackScreens = { + Home: "", + Login: "login", + Signup: "signup", + CollectionCreate: "new-notebook", + Collection: "notebook/:colUid", + CollectionEdit: "notebook/:colUid/edit", + CollectionChangelog: "notebook/:colUid/manage", + CollectionMembers: "notebook/:colUid/members", + NoteCreate: "new-note", + NoteEdit: "notebook/:colUid/note/:itemUid", + NoteProps: "notebook/:colUid/note/:itemUid/properties", + NoteMove: "notebook/:colUid/note/:itemUid/move", + Invitations: "invitations", + Settings: "settings", + About: "settings/about", + Password: "settings/password", + DebugLogs: "settings/logs", + AccountWizard: "account-wizard", + "404": "*", +}; + +export const linking = { + prefixes: ["https://notes.etesync.com", "com.etesync.notes://"], + config: { + screens: { + Root: { + path: "", + screens: rootStackScreens, + }, + }, + }, +}; diff --git a/src/RootNavigator.tsx b/src/RootNavigator.tsx index e00cdde..564078e 100644 --- a/src/RootNavigator.tsx +++ b/src/RootNavigator.tsx @@ -32,7 +32,7 @@ import { useAppStateCb } from "./helpers"; import * as C from "./constants"; import { StoreState } from "./store"; -import { RootStackParamList } from "./RootStackParamList"; +import { RootStackParamList } from "./NavigationConfig"; import MenuButton from "./widgets/MenuButton"; import Appbar from "./widgets/Appbar"; diff --git a/src/RootStackParamList.tsx b/src/RootStackParamList.tsx deleted file mode 100644 index 2c8f309..0000000 --- a/src/RootStackParamList.tsx +++ /dev/null @@ -1,38 +0,0 @@ - -import { StackNavigationProp } from "@react-navigation/stack"; - -export type RootStackParamList = { - Home: undefined; - Login: undefined; - Signup: undefined; - CollectionCreate: undefined; - Collection: { colUid: string }; - CollectionEdit: { colUid: string }; - CollectionChangelog: { colUid: string }; - CollectionMembers: { colUid: string }; - NoteCreate: { - colUid: string; - itemUid?: undefined; - } | undefined; - NoteEdit: { - colUid: string; - itemUid: string; - }; - NoteProps: { - colUid: string; - itemUid: string; - }; - NoteMove: { - colUid: string; - itemUid: string; - }; - Invitations: undefined; - Settings: undefined; - Password: undefined; - About: undefined; - DebugLogs: undefined; - AccountWizard: undefined; - "404": undefined; -}; - -export type DefaultNavigationProp = StackNavigationProp; diff --git a/src/screens/AccountWizardScreen.tsx b/src/screens/AccountWizardScreen.tsx index 750fcef..435ea0e 100644 --- a/src/screens/AccountWizardScreen.tsx +++ b/src/screens/AccountWizardScreen.tsx @@ -21,7 +21,7 @@ import { useDispatch } from "react-redux"; import { performSync } from "../store/actions"; import * as C from "../constants"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; const wizardPages = [ (props: PagePropsType) => ( diff --git a/src/screens/ChangePasswordScreen.tsx b/src/screens/ChangePasswordScreen.tsx index 7796798..d7c3c76 100644 --- a/src/screens/ChangePasswordScreen.tsx +++ b/src/screens/ChangePasswordScreen.tsx @@ -19,7 +19,7 @@ import ErrorOrLoadingDialog from "../widgets/ErrorOrLoadingDialog"; import PasswordInput from "../widgets/PasswordInput"; import ScrollView from "../widgets/ScrollView"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; interface PasswordFormErrors { oldPassword?: string; diff --git a/src/screens/CollectionChangelogScreen.tsx b/src/screens/CollectionChangelogScreen.tsx index b429fc0..ab8541b 100644 --- a/src/screens/CollectionChangelogScreen.tsx +++ b/src/screens/CollectionChangelogScreen.tsx @@ -19,7 +19,7 @@ import NotFound from "../widgets/NotFound"; import AppbarAction from "../widgets/AppbarAction"; import { defaultColor } from "../helpers"; -import { DefaultNavigationProp, RootStackParamList } from "../RootStackParamList"; +import { DefaultNavigationProp, RootStackParamList } from "../NavigationConfig"; import ColorBox from "../widgets/ColorBox"; diff --git a/src/screens/CollectionEditScreen.tsx b/src/screens/CollectionEditScreen.tsx index afcd88d..e6a2b2f 100644 --- a/src/screens/CollectionEditScreen.tsx +++ b/src/screens/CollectionEditScreen.tsx @@ -23,7 +23,7 @@ import FormButton from "../widgets/FormButton"; import AppbarAction from "../widgets/AppbarAction"; import { useLoading, defaultColor } from "../helpers"; -import { DefaultNavigationProp, RootStackParamList } from "../RootStackParamList"; +import { DefaultNavigationProp, RootStackParamList } from "../NavigationConfig"; import ColorPicker from "../widgets/ColorPicker"; import * as C from "../constants"; diff --git a/src/screens/CollectionMembersScreen.tsx b/src/screens/CollectionMembersScreen.tsx index f826028..3571b20 100644 --- a/src/screens/CollectionMembersScreen.tsx +++ b/src/screens/CollectionMembersScreen.tsx @@ -22,7 +22,7 @@ import ErrorDialog from "../widgets/ErrorDialog"; import NotFound from "../widgets/NotFound"; import AppbarAction from "../widgets/AppbarAction"; import CollectionMemberAddDialog from "../components/CollectionMemberAddDialog"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; type NavigationProp = StackNavigationProp; diff --git a/src/screens/HomeScreen.tsx b/src/screens/HomeScreen.tsx index 482e73a..e268bf6 100644 --- a/src/screens/HomeScreen.tsx +++ b/src/screens/HomeScreen.tsx @@ -4,7 +4,7 @@ import * as React from "react"; import { BottomNavigation } from "react-native-paper"; import { RouteProp } from "@react-navigation/native"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; import NoteListScreen from "./NoteListScreen"; import SearchScreen from "./SearchScreen"; diff --git a/src/screens/LoginScreen.tsx b/src/screens/LoginScreen.tsx index b18790a..1c0c226 100644 --- a/src/screens/LoginScreen.tsx +++ b/src/screens/LoginScreen.tsx @@ -24,7 +24,7 @@ import { useCredentials } from "../credentials"; import LinkButton from "../widgets/LinkButton"; import { useNavigation } from "@react-navigation/native"; import { StackNavigationProp } from "@react-navigation/stack"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; type NavigationProp = StackNavigationProp; diff --git a/src/screens/NotFoundScreen.tsx b/src/screens/NotFoundScreen.tsx index 1316a7c..9523879 100644 --- a/src/screens/NotFoundScreen.tsx +++ b/src/screens/NotFoundScreen.tsx @@ -1,7 +1,7 @@ import * as React from "react"; import { useNavigation } from "@react-navigation/native"; import { StackNavigationProp } from "@react-navigation/stack"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; import NotFound from "../widgets/NotFound"; type NavigationProp = StackNavigationProp; diff --git a/src/screens/NoteEditScreen.tsx b/src/screens/NoteEditScreen.tsx index ac1e65a..8c58ed4 100644 --- a/src/screens/NoteEditScreen.tsx +++ b/src/screens/NoteEditScreen.tsx @@ -24,7 +24,7 @@ import ConfirmationDialog from "../widgets/ConfirmationDialog"; import NotFound from "../widgets/NotFound"; import AppbarAction from "../widgets/AppbarAction"; import { fontFamilies } from "../helpers"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; import { canShare, shareItem } from "../import-export"; type NavigationProp = StackNavigationProp; diff --git a/src/screens/NoteListScreen.tsx b/src/screens/NoteListScreen.tsx index 153d826..6155d38 100644 --- a/src/screens/NoteListScreen.tsx +++ b/src/screens/NoteListScreen.tsx @@ -18,7 +18,7 @@ import Appbar from "../widgets/Appbar"; import Menu from "../widgets/Menu"; import MenuItem from "../widgets/MenuItem"; import AppbarAction from "../widgets/AppbarAction"; -import { DefaultNavigationProp } from "../RootStackParamList"; +import { DefaultNavigationProp } from "../NavigationConfig"; import { useTheme } from "../theme"; interface PropsType { diff --git a/src/screens/NoteMoveScreen.tsx b/src/screens/NoteMoveScreen.tsx index 4917847..6868cf8 100644 --- a/src/screens/NoteMoveScreen.tsx +++ b/src/screens/NoteMoveScreen.tsx @@ -22,7 +22,7 @@ import TextInputWithIcon from "../widgets/TextInputWithIcon"; import NotFound from "../widgets/NotFound"; import { useLoading } from "../helpers"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; interface FormErrors { notebook?: string; diff --git a/src/screens/NotePropertiesScreen.tsx b/src/screens/NotePropertiesScreen.tsx index 9253503..f4e02aa 100644 --- a/src/screens/NotePropertiesScreen.tsx +++ b/src/screens/NotePropertiesScreen.tsx @@ -25,7 +25,7 @@ import NotFound from "../widgets/NotFound"; import FormButton from "../widgets/FormButton"; import { useLoading, NoteMetadata } from "../helpers"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; interface FormErrors { name?: string; diff --git a/src/screens/NotebookListScreen.tsx b/src/screens/NotebookListScreen.tsx index 6dfcc75..76bd4a8 100644 --- a/src/screens/NotebookListScreen.tsx +++ b/src/screens/NotebookListScreen.tsx @@ -18,7 +18,7 @@ import Menu from "../widgets/Menu"; import MenuItem from "../widgets/MenuItem"; import NotFound from "../widgets/NotFound"; import { defaultColor } from "../helpers"; -import { DefaultNavigationProp } from "../RootStackParamList"; +import { DefaultNavigationProp } from "../NavigationConfig"; import { useTheme } from "../theme"; interface PropsType { diff --git a/src/screens/SearchScreen.tsx b/src/screens/SearchScreen.tsx index bbeb2d5..f5f0ff9 100644 --- a/src/screens/SearchScreen.tsx +++ b/src/screens/SearchScreen.tsx @@ -12,7 +12,7 @@ import { useSyncGate } from "../SyncGate"; import { StoreState } from "../store"; import Link from "../widgets/Link"; -import { DefaultNavigationProp } from "../RootStackParamList"; +import { DefaultNavigationProp } from "../NavigationConfig"; import SearchToolbar from "../widgets/SearchToolbar"; diff --git a/src/screens/SettingsScreen.tsx b/src/screens/SettingsScreen.tsx index e589e8e..f3be783 100644 --- a/src/screens/SettingsScreen.tsx +++ b/src/screens/SettingsScreen.tsx @@ -23,7 +23,7 @@ import { StackNavigationProp } from "@react-navigation/stack"; import AnchorButton from "../widgets/AnchorButton"; import FontSelector from "../widgets/FontSelector"; import Select from "../widgets/Select"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; import { useTheme } from "../theme"; function DarkModePreferenceSelector() { diff --git a/src/screens/SignupScreen.tsx b/src/screens/SignupScreen.tsx index 8292931..6b3f7c6 100644 --- a/src/screens/SignupScreen.tsx +++ b/src/screens/SignupScreen.tsx @@ -27,7 +27,7 @@ import { useCredentials } from "../credentials"; import LinkButton from "../widgets/LinkButton"; import { useNavigation } from "@react-navigation/native"; import { StackNavigationProp } from "@react-navigation/stack"; -import { RootStackParamList } from "../RootStackParamList"; +import { RootStackParamList } from "../NavigationConfig"; interface FormErrors { username?: string;