From 8b3bb9164453498b78e497e4e8f3a5252b4159ea Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Thu, 8 Jul 2021 17:42:17 -0400 Subject: Hook up navigation to custom category creation --- src/components/moments/Moment.tsx | 2 -- src/routes/main/MainStackNavigator.tsx | 5 ++++- src/screens/profile/CategorySelection.tsx | 1 + src/screens/profile/ChoosingCategoryScreen.tsx | 4 ++-- src/screens/profile/CreateCustomCategory.tsx | 4 ++-- 5 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/components/moments/Moment.tsx b/src/components/moments/Moment.tsx index a1621f2e..ca736b92 100644 --- a/src/components/moments/Moment.tsx +++ b/src/components/moments/Moment.tsx @@ -39,8 +39,6 @@ const Moment: React.FC = ({ move, externalStyles, }) => { - const navigation = useNavigation(); - return ( diff --git a/src/routes/main/MainStackNavigator.tsx b/src/routes/main/MainStackNavigator.tsx index e840eb38..05f5138f 100644 --- a/src/routes/main/MainStackNavigator.tsx +++ b/src/routes/main/MainStackNavigator.tsx @@ -49,7 +49,9 @@ export type MainStackParams = { selectedTags?: MomentTagType[]; moment?: MomentType; }; - ChoosingCategoryScreen: {}; + ChoosingCategoryScreen: { + newCustomCategory: string; + }; TagFriendsScreen: { media: { uri: string; @@ -88,6 +90,7 @@ export type MainStackParams = { }; CreateCustomCategory: { existingCategories: string[]; + fromScreen: 'ChoosingCategoryScreen' | 'CategorySelection'; }; Notifications: { screenType: ScreenType; diff --git a/src/screens/profile/CategorySelection.tsx b/src/screens/profile/CategorySelection.tsx index ea443fce..9b8672ea 100644 --- a/src/screens/profile/CategorySelection.tsx +++ b/src/screens/profile/CategorySelection.tsx @@ -170,6 +170,7 @@ const CategorySelection: React.FC = ({ onPress={() => { navigation.push('CreateCustomCategory', { existingCategories: momentCategories.concat(selectedCategories), + fromScreen: 'CategorySelection', }); }}> diff --git a/src/screens/profile/ChoosingCategoryScreen.tsx b/src/screens/profile/ChoosingCategoryScreen.tsx index daf7642d..24db015e 100644 --- a/src/screens/profile/ChoosingCategoryScreen.tsx +++ b/src/screens/profile/ChoosingCategoryScreen.tsx @@ -43,7 +43,7 @@ const ChoosingCategoryScreen: React.FC = ({ const tabBarHeight = useBottomTabBarHeight(); const insetTop = useSafeAreaInsets().top; - const MomentItem: FC<{ + const ListItem: FC<{ title: string; onPress: () => void; }> = ({title, onPress}) => { @@ -80,7 +80,7 @@ const ChoosingCategoryScreen: React.FC = ({ style={{height: SCREEN_HEIGHT * 0.9}} contentContainerStyle={{paddingBottom: tabBarHeight}}> {momentCategories.map((title) => ( - diff --git a/src/screens/profile/CreateCustomCategory.tsx b/src/screens/profile/CreateCustomCategory.tsx index c4b17b1e..91083c7c 100644 --- a/src/screens/profile/CreateCustomCategory.tsx +++ b/src/screens/profile/CreateCustomCategory.tsx @@ -37,14 +37,14 @@ const CreateCustomCategory: React.FC = ({ /** * Same component to be used for category selection while onboarding and while on profile */ - const {existingCategories} = route.params; + const {existingCategories, fromScreen} = route.params; const [newCategory, setNewCategory] = useState(''); const handleButtonPress = () => { if (existingCategories.includes(newCategory)) { Alert.alert('Looks like you already have that one created!'); } else { - navigation.navigate('CategorySelection', { + navigation.navigate(fromScreen, { newCustomCategory: newCategory, }); } -- cgit v1.2.3-70-g09d2