Skip to content

Commit 46451f0

Browse files
authored
Merge pull request #220 from luke-h1/@luke-h1/chore/cleanup-nav-structure
feat(app): cleanup nav structure
2 parents 894ec87 + 156d6b6 commit 46451f0

File tree

11 files changed

+109
-18
lines changed

11 files changed

+109
-18
lines changed

src/navigators/AppNavigator.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { AuthContextProvider } from '@app/context';
22
import {
33
AuthLoadingScreen,
44
CategoryScreen,
5-
ChangelogScreen,
65
LoginScreen,
76
StorybookScreen,
87
} from '@app/screens';
@@ -22,6 +21,10 @@ import {
2221
DevToolsParamList,
2322
DevToolsStackNavigator,
2423
} from './DevToolsStackNavigator';
24+
import {
25+
OtherStackNavigator,
26+
OtherStackParamList,
27+
} from './OtherStackNavigator';
2528
import {
2629
PreferenceStackNavigator,
2730
PreferenceStackParamList,
@@ -65,9 +68,6 @@ export type AppStackParamList = {
6568
// login screen
6669
Login: undefined;
6770

68-
// changelog
69-
Changelog: undefined;
70-
7171
// sb
7272
Storybook: undefined;
7373

@@ -76,6 +76,9 @@ export type AppStackParamList = {
7676

7777
// dev-tools
7878
DevTools: NavigatorScreenParams<DevToolsParamList>;
79+
80+
// other
81+
Other: NavigatorScreenParams<OtherStackParamList>;
7982
};
8083

8184
/**
@@ -117,7 +120,7 @@ const AppStack = () => {
117120
<Stack.Screen name="Login" component={LoginScreen} />
118121

119122
{/* Changelog */}
120-
<Stack.Screen name="Changelog" component={ChangelogScreen} />
123+
<Stack.Screen name="Other" component={OtherStackNavigator} />
121124

122125
{/* sb */}
123126
<Stack.Screen name="Storybook" component={StorybookScreen} />
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { ChangelogScreen } from '@app/screens';
2+
import { AboutScreen, FaqScreen } from '@app/screens/Other';
3+
import { createNativeStackNavigator } from '@react-navigation/native-stack';
4+
import { StackScreenProps } from '@react-navigation/stack';
5+
6+
export type OtherStackParamList = {
7+
About: undefined;
8+
Changelog: undefined;
9+
Faq: undefined;
10+
};
11+
12+
const Stack = createNativeStackNavigator<OtherStackParamList>();
13+
14+
export type OtherStackScreenProps<T extends keyof OtherStackParamList> =
15+
StackScreenProps<OtherStackParamList, T>;
16+
17+
export function OtherStackNavigator() {
18+
return (
19+
<Stack.Navigator>
20+
<Stack.Screen
21+
name="About"
22+
component={AboutScreen}
23+
options={{ headerShown: false }}
24+
/>
25+
<Stack.Screen
26+
name="Changelog"
27+
component={ChangelogScreen}
28+
options={{ headerShown: false }}
29+
/>
30+
<Stack.Screen
31+
name="Faq"
32+
component={FaqScreen}
33+
options={{ headerShown: false }}
34+
/>
35+
</Stack.Navigator>
36+
);
37+
}

src/navigators/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ export const BaseConfig: ConfigBaseProps = {
2020
* This is a list of all the route names that will exit the app if the back button
2121
* is pressed while in that screen. Only affects Android.
2222
*/
23-
exitRoutes: ['AuthLoadingScreen'],
23+
exitRoutes: [''],
2424
};

src/navigators/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export * from './config';
77
export * from './BackButton';
88
export * from './PreferenceStackNavigator';
99
export * from './DevToolsStackNavigator';
10+
export * from './OtherStackNavigator';

src/screens/AuthLoading.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
import { Spinner, Typography } from '@app/components';
21
import { useAuthContext } from '@app/context';
32
import { useAppNavigation } from '@app/hooks';
43
import { useEffect } from 'react';
5-
import { View } from 'react-native';
64

75
export function AuthLoadingScreen() {
86
const { populateAuthState, authState } = useAuthContext();
97
const { navigate } = useAppNavigation();
108
useEffect(() => {
11-
// todo - expose if we're anon or logged in an redirect to the following screen if we have an account
129
populateAuthState().then(() => {
1310
if (authState?.isLoggedIn) {
14-
console.log('isAuth true');
1511
navigate('Tabs', {
1612
screen: 'Following',
1713
});
1814
}
1915

2016
if (authState?.isAnonAuth) {
21-
console.log('isAnonAuth true');
2217
navigate('Tabs', {
2318
screen: 'Top',
2419
});
@@ -27,10 +22,5 @@ export function AuthLoadingScreen() {
2722
// eslint-disable-next-line react-hooks/exhaustive-deps
2823
}, []);
2924

30-
return (
31-
<View style={{ flex: 1, padding: 16, justifyContent: 'center' }}>
32-
<Typography>Auth loading...</Typography>
33-
<Spinner />
34-
</View>
35-
);
25+
return null;
3626
}

src/screens/Other/AboutScreen.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Screen, Typography } from '@app/components';
2+
import { useAppNavigation, useHeader } from '@app/hooks';
3+
4+
export function AboutScreen() {
5+
const { goBack } = useAppNavigation();
6+
7+
useHeader({
8+
title: 'About',
9+
leftIcon: 'arrow-left',
10+
onLeftPress: () => goBack(),
11+
});
12+
return (
13+
<Screen>
14+
<Typography>About</Typography>
15+
</Screen>
16+
);
17+
}

src/screens/Other/FaqScreen.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Screen, Typography } from '@app/components';
2+
import { useAppNavigation, useHeader } from '@app/hooks';
3+
4+
export function FaqScreen() {
5+
const { goBack } = useAppNavigation();
6+
7+
useHeader({
8+
title: 'Faq',
9+
leftIcon: 'arrow-left',
10+
onLeftPress: () => goBack(),
11+
});
12+
return (
13+
<Screen>
14+
<Typography>FAQ</Typography>
15+
</Screen>
16+
);
17+
}

src/screens/Other/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './AboutScreen';
2+
export * from './ChangelogScreen';
3+
export * from './FaqScreen';

src/screens/SettingsScreen.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,29 @@ export function SettingsScreen() {
150150
},
151151
],
152152
},
153+
{
154+
title: 'Other',
155+
data: [
156+
{
157+
title: 'About the app',
158+
iconName: '',
159+
description: 'Learn more about the app',
160+
onPress: () => navigate('Other', { screen: 'About' }),
161+
},
162+
{
163+
title: 'Changelog',
164+
description: 'release notes',
165+
iconName: '',
166+
onPress: () => navigate('Other', { screen: 'Changelog' }),
167+
},
168+
{
169+
title: 'FAQ',
170+
description: 'Questions and answers',
171+
iconName: '',
172+
onPress: () => navigate('Other', { screen: 'Faq' }),
173+
},
174+
],
175+
},
153176
];
154177

155178
const bottomSheetSections: NavigationSectionListData = [

0 commit comments

Comments
 (0)