Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move linking config to NavigationConfig #164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 1 addition & 39 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
76 changes: 76 additions & 0 deletions src/NavigationConfig.tsx
Original file line number Diff line number Diff line change
@@ -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<RootStackParamList, keyof RootStackParamList>;

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,
},
},
},
};
2 changes: 1 addition & 1 deletion src/RootNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
38 changes: 0 additions & 38 deletions src/RootStackParamList.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/screens/AccountWizardScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => (
Expand Down
2 changes: 1 addition & 1 deletion src/screens/ChangePasswordScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/CollectionChangelogScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion src/screens/CollectionEditScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/screens/CollectionMembersScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RootStackParamList, "CollectionMembers">;

Expand Down
2 changes: 1 addition & 1 deletion src/screens/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/screens/LoginScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RootStackParamList, "Login">;

Expand Down
2 changes: 1 addition & 1 deletion src/screens/NotFoundScreen.tsx
Original file line number Diff line number Diff line change
@@ -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<RootStackParamList, "404">;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/NoteEditScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<RootStackParamList, "NoteEdit">;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/NoteListScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/NoteMoveScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/NotePropertiesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/screens/NotebookListScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/SearchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";


Expand Down
2 changes: 1 addition & 1 deletion src/screens/SettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/screens/SignupScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down