Skip to content

Commit 0badc03

Browse files
committed
Added types for navigation
1 parent b4b58a4 commit 0badc03

25 files changed

+180
-76
lines changed

constants/api.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const API = {
22
QUOTE_URL: 'http://api.forismatic.com/api/1.0',
33
IMAGE_URL: 'https://picsum.photos'
4-
}
4+
} as const;
55

6-
export { API };
6+
export { API };

constants/colors.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
const COLORS_LIGHT = {
2-
appBackground: "#EEECEC",
3-
primary900: "#00146D",
4-
primary300: "#6d78bd",
5-
primary200: "#969ecf",
6-
primary100: "#B0B7E5",
7-
secondary800: "#6d0014",
8-
grey600: "#757575",
9-
grey300: "#BDBDBD",
10-
fontMain: "#000000",
11-
fontInverse: "#FFFFFF",
2+
APP_BACKGROUND: "#EEECEC",
3+
PRIMARY__900: "#00146D",
4+
PRIMARY_300: "#6d78bd",
5+
PRIMARY_200: "#969ecf",
6+
PRIMARY_100: "#B0B7E5",
7+
SECONDARY_800: "#6d0014",
8+
GREY__600: "#757575",
9+
GREY_300: "#BDBDBD",
10+
FONT_MAIN: "#000000",
11+
FONT_INVERSE: "#FFFFFF",
1212
} as const;
1313

1414
const COLORS_DARK = {
15-
appBackground: "#262626",
16-
primary900: "#BA68C8",
17-
primary300: "#e1bee7",
18-
primary200: "#514951",
19-
primary100: "#351401",
20-
secondary800: "#c86876",
21-
grey300: "#757575",
22-
grey600: "#BDBDBD",
23-
fontInverse: "#000000",
24-
fontMain: "#FFFFFF",
15+
APP_BACKGROUND: "#262626",
16+
PRIMARY_900: "#BA68C8",
17+
PRIMARY_300: "#e1bee7",
18+
PRIMARY_200: "#514951",
19+
PRIMARY_100: "#351401",
20+
SECONDARY_800: "#c86876",
21+
GREY_300: "#757575",
22+
GREY_600: "#BDBDBD",
23+
FONT_INVERSE: "#000000",
24+
FONT_MAIN: "#FFFFFF",
2525
} as const;
2626

2727
export { COLORS_DARK, COLORS_LIGHT };

constants/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { API } from './api';
22
export { COLORS_DARK, COLORS_LIGHT } from './colors';
3+
export { ROUTE_NAME } from './routes';

constants/routes.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const ROUTE_NAME = {
2+
DASHBOARD: 'Dashboard',
3+
SETTINGS: 'Settings',
4+
ADD_INSPIRATION: 'AddInspiration',
5+
BOTTOM_TABS_NAVIGATOR: 'BottomTabsNavigator',
6+
} as const;
7+
8+
export { ROUTE_NAME };

contexts/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { ThemeProvider, ThemeContext } from './theme-context';
1+
export { ThemeProvider, ThemeContext } from './theme-context';

contexts/theme-context.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ const ThemeProvider: React.FC<{ children: ReactNode }> = ({ children }) => {
2828
);
2929
};
3030

31-
export { ThemeProvider, ThemeContext };
31+
export { ThemeProvider, ThemeContext };

helpers/get-random-number.helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ const getRandomNumber = (min?: number, max?: number): number => {
66
return Math.floor(Math.random() * 100);
77
}
88

9-
export { getRandomNumber };
9+
export { getRandomNumber };

helpers/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { getRandomNumber } from './get-random-number.helper';
1+
export { getRandomNumber } from './get-random-number.helper';

hooks/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { useTheme } from './use-theme';
1+
export { useTheme } from './use-theme';

hooks/use-theme.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ const useTheme = () => {
88
return context;
99
};
1010

11-
export { useTheme };
11+
export { useTheme };

navigation/bottom-tabs-navigator.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Text } from "react-native";
2+
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
3+
4+
import { Dashboard, Settings } from '../screens';
5+
6+
const BottomTabs = createBottomTabNavigator();
7+
8+
const BottomTabsNavigator = () => {
9+
return (
10+
// Add BottomTabs.Navigator here
11+
<></>
12+
)
13+
}
14+
15+
export { BottomTabsNavigator };

navigation/drawer-navigator.tsx

-15
This file was deleted.

navigation/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { RootNavigator } from './root-navigator';
1+
export { RootNavigator } from './root-navigator';

navigation/root-navigator.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
import { NavigationContainer } from "@react-navigation/native";
21
import { StatusBar } from "expo-status-bar";
32
import { SafeAreaView, useSafeAreaInsets } from "react-native-safe-area-context";
3+
import { NavigationContainer } from "@react-navigation/native";
4+
import { createNativeStackNavigator } from "@react-navigation/native-stack";
5+
6+
import { BottomTabsNavigator } from "./bottom-tabs-navigator";
7+
import { RootStackParamList } from "../types";
48

5-
import { DrawerNavigator } from "./drawer-navigator";
9+
const Stack = createNativeStackNavigator<RootStackParamList>();
610

711
const RootNavigator = () => {
812
const insets = useSafeAreaInsets();

package-lock.json

+35-20
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
},
1111
"dependencies": {
1212
"@expo/vector-icons": "^14.0.2",
13-
"@react-navigation/drawer": "^6.7.0",
13+
"@react-native-async-storage/async-storage": "1.23.1",
14+
"@react-navigation/bottom-tabs": "^6.6.0",
1415
"@react-navigation/native": "^6.1.17",
16+
"@react-navigation/native-stack": "^6.10.0",
1517
"axios": "^1.7.2",
1618
"expo": "~51.0.19",
1719
"expo-font": "~12.0.7",
@@ -20,8 +22,7 @@
2022
"react-native": "0.74.3",
2123
"react-native-gesture-handler": "~2.16.1",
2224
"react-native-reanimated": "~3.10.1",
23-
"react-native-safe-area-context": "4.10.1",
24-
"@react-native-async-storage/async-storage": "1.23.1"
25+
"react-native-safe-area-context": "4.10.1"
2526
},
2627
"devDependencies": {
2728
"@babel/core": "^7.20.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const AddInspiration: React.FC = () => {
2+
return (
3+
<></>
4+
);
5+
}
6+
7+
export { AddInspiration };

screens/dashboard/dashboard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ const Dashboard: React.FC = () => {
44
);
55
}
66

7-
export { Dashboard };
7+
export { Dashboard };

screens/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { Settings } from './settings/settings';
2-
export { Dashboard } from './dashboard/dashboard';
2+
export { Dashboard } from './dashboard/dashboard';
3+
export { AddInspiration } from './add-inspiration/add-inspiration';

screens/settings/settings.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ const Settings: React.FC = () => {
44
);
55
}
66

7-
export { Settings };
7+
export { Settings };

types/get-image-response-dto.type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ type GetImageResponseDto = {
77
download_url: string
88
}
99

10-
export type { GetImageResponseDto };
10+
export type { GetImageResponseDto };

types/get-quote-response-dto.type.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ type GetQuoteResponseDto = {
66
quoteLink: string
77
}
88

9-
export { type GetQuoteResponseDto };
9+
export { type GetQuoteResponseDto };

types/index.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
export type { GetQuoteResponseDto } from './get-quote-response-dto.type';
2-
export type { GetImageResponseDto } from './get-image-response-dto.type';
1+
export type { GetQuoteResponseDto } from "./get-quote-response-dto.type";
2+
export type { GetImageResponseDto } from "./get-image-response-dto.type";
3+
export type { Inspiration } from "./inspiration.type";
4+
export type {
5+
BottomTabsParamList,
6+
BottomTabsScreenProps,
7+
NavigationRoute,
8+
RootStackParamList,
9+
RootStackScreenProps,
10+
} from "./navigation.type";

types/inspiration.type.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type Inspiration = {
2+
quote?: string;
3+
quote_url?: string;
4+
image_url?: string;
5+
}
6+
7+
export type { Inspiration };

types/navigation.type.ts

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import type {
2+
NavigatorScreenParams,
3+
CompositeScreenProps,
4+
} from "@react-navigation/native";
5+
import type { NativeStackScreenProps } from "@react-navigation/native-stack";
6+
import type { BottomTabScreenProps as RNBottomTabScreenProps } from "@react-navigation/bottom-tabs";
7+
8+
import type { ROUTE_NAME } from "../constants";
9+
import { Inspiration } from "./inspiration.type";
10+
11+
type NavigationRoute = (typeof ROUTE_NAME)[keyof typeof ROUTE_NAME];
12+
13+
type RootStackParamList = {
14+
[ROUTE_NAME.BOTTOM_TABS_NAVIGATOR]: NavigatorScreenParams<BottomTabsParamList>;
15+
[ROUTE_NAME.ADD_INSPIRATION]: undefined;
16+
};
17+
18+
type BottomTabsParamList = {
19+
[ROUTE_NAME.DASHBOARD]:
20+
| {
21+
inspiration?: Inspiration;
22+
}
23+
| undefined;
24+
[ROUTE_NAME.SETTINGS]: undefined;
25+
};
26+
27+
declare global {
28+
// eslint-disable-next-line @typescript-eslint/no-namespace
29+
namespace ReactNavigation {
30+
interface RootParamList extends RootStackParamList {}
31+
}
32+
}
33+
34+
type RootStackScreenProps<T extends keyof RootStackParamList> =
35+
NativeStackScreenProps<RootStackParamList, T>;
36+
37+
type BottomTabsScreenProps<T extends keyof BottomTabsParamList> =
38+
CompositeScreenProps<
39+
RNBottomTabScreenProps<BottomTabsParamList, T>,
40+
NativeStackScreenProps<
41+
RootStackParamList,
42+
typeof ROUTE_NAME.BOTTOM_TABS_NAVIGATOR
43+
>
44+
>;
45+
46+
export type {
47+
NavigationRoute,
48+
RootStackParamList,
49+
BottomTabsParamList,
50+
RootStackScreenProps,
51+
BottomTabsScreenProps,
52+
};

0 commit comments

Comments
 (0)