Skip to content

Commit

Permalink
feat(chat): navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
LuisCusihuaman committed Nov 9, 2023
1 parent b8b87ad commit c1ee5db
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/navigation/tab-data.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { IconDefinition } from '@fortawesome/free-solid-svg-icons';
import { faFeed, faMessage, faSearch } from '@fortawesome/free-solid-svg-icons';

import { Chat, Search } from '@/screens';
import { Search } from '@/screens';
import { ChatNavigator } from '@/screens/chat/chat-navigator';

import { FeedNavigator } from './feed-navigator';

Expand Down Expand Up @@ -36,9 +37,9 @@ export const tabs: TabType[] = [
icon: faSearch,
},
{
name: 'Chat',
component: Chat, // React Chat component screen
label: 'Chat',
name: 'ChatNavigator',
component: ChatNavigator, // React Chat component screen
label: 'ChatNavigator',
icon: faMessage,
},
];
2 changes: 1 addition & 1 deletion src/navigation/tab-navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const TabNavigator: React.FC = () => {
return (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarInactiveTintColor: colorScheme === 'dark' ? '#1DA1F' : '#65776',
tabBarInactiveTintColor: colorScheme === 'dark' ? '#1DA1F' : '#A9A9A9',
tabBarIcon: ({ color }) => renderTabBarIcon({ color, route }),
})}
>
Expand Down
7 changes: 6 additions & 1 deletion src/navigation/types.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import type { RouteProp as NRouteProp } from '@react-navigation/native';

import type { ChatStackParamList } from '@/screens/chat/chat-navigator';

import type { AuthStackParamList } from './auth-navigator';
import type { FeedStackParamList } from './feed-navigator';

export type RootStackParamList = AuthStackParamList & FeedStackParamList; // & FooStackParamList & BarStackParamList
// TODO: change, this must be dynamic
export type RootStackParamList = AuthStackParamList &
FeedStackParamList &
ChatStackParamList; // & FooStackParamList & BarStackParamList
// very important to type check useNavigation hook
declare global {
namespace ReactNavigation {
Expand Down
4 changes: 2 additions & 2 deletions src/screens/chat/chat-list-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const ChatListScreen = () => {
},
];

const navigate = useNavigation();
const { navigate } = useNavigation();

return (
<View style={styles.container}>
Expand All @@ -52,7 +52,7 @@ const ChatListScreen = () => {
<ChatListHeader />

{/* List of chats */}
<ChatListBody chats={chats} onPress={() => navigate.navigate('Feed')} />
<ChatListBody chats={chats} onPress={() => navigate('ChatScreen')} />
{/* <ChatListBody chats={chats} onPress={() => console.log('Me undieron')} /> */}

{/* <ChatScreen /> */}
Expand Down
23 changes: 23 additions & 0 deletions src/screens/chat/chat-navigator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import * as React from 'react';

import { Chat } from '@/screens';

import ChatScreen from './chat-screen';

export type ChatStackParamList = {
ChatPrincipal: undefined;
// Snap: { id: number };
ChatScreen: undefined;
};

const Stack = createNativeStackNavigator<ChatStackParamList>();

export const ChatNavigator = () => {
return (
<Stack.Navigator>
<Stack.Screen name="ChatPrincipal" component={Chat} />
<Stack.Screen name="ChatScreen" component={ChatScreen} />
</Stack.Navigator>
);
};

0 comments on commit c1ee5db

Please sign in to comment.