Skip to content

Commit

Permalink
feat(routing): add chat and channel routing
Browse files Browse the repository at this point in the history
  • Loading branch information
prathameshkurunkar7 committed Dec 20, 2024
1 parent 460af4f commit 96ddf86
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 2 deletions.
9 changes: 8 additions & 1 deletion apps/mobile/app/[site_id]/(tabs)/home/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import { View } from 'react-native';
import { ThemeToggle } from '@components/nativewindui/ThemeToggle';
import ChannelList from '@components/features/chat/ChannelList/ChannelList';
import { useRouter } from 'expo-router';

export default function Home() {

const router = useRouter()
const handleChannelSelect = (channelId: string) => {
router.push('../chat/' + channelId)
}

return (
<View className="flex flex-col gap-4">
<ThemeToggle />
Expand Down Expand Up @@ -105,7 +112,7 @@ export default function Home() {
last_message_timestamp: "2024-12-18T14:00:00Z",
},
]}
onChannelSelect={() => console.log('channel selected')}
onChannelSelect={handleChannelSelect}
onLongPress={() => console.log('channel long pressed')} />
</View>
)
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/app/[site_id]/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default function SiteLayout() {
siteName={siteInfo?.sitename}>
<Providers>
<Stack>
<Stack.Screen name="(tabs)" options={{ headerShown: false }} />
<Stack.Screen name="(tabs)" options={{ headerShown: false, title: 'Home' }} />
</Stack>
</Providers>
</FrappeProvider>
Expand Down
29 changes: 29 additions & 0 deletions apps/mobile/app/[site_id]/chat/[id]/_layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { useColorScheme } from "@hooks/useColorScheme"
import { Stack } from "expo-router"


const ChatLayout = () => {
const { colors } = useColorScheme()

return (
<Stack screenOptions={{
headerShadowVisible: false,
headerStyle: { backgroundColor: colors.background }
}}>
<Stack.Screen name='index'
options={{
title: 'Chat',
headerLargeTitle: false
}}
/>
<Stack.Screen name='channel-settings'
options={{
title: 'Channel Settings',
headerLargeTitle: false
}}
/>
</Stack>
)
}

export default ChatLayout
12 changes: 12 additions & 0 deletions apps/mobile/app/[site_id]/chat/[id]/channel-settings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { View } from "react-native"
import { Text } from '@components/nativewindui/Text'

const ChannelSettings = () => {
return (
<View>
<Text>Channel Settings</Text>
</View>
)
}

export default ChannelSettings
18 changes: 18 additions & 0 deletions apps/mobile/app/[site_id]/chat/[id]/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@


import { View, Text } from 'react-native'
import { useLocalSearchParams } from 'expo-router';

const Chat = () => {
const { id } = useLocalSearchParams();

console.log("Channel id: ", id);

return (
<View>
<Text>{id}</Text>
</View>
)
}

export default Chat
1 change: 1 addition & 0 deletions apps/mobile/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "expo/tsconfig.base",
"compilerOptions": {
"jsx": "react-jsx",
"strict": true,
"composite": true,
"moduleResolution": "bundler",
Expand Down

0 comments on commit 96ddf86

Please sign in to comment.