Skip to content

Commit ea10daa

Browse files
authored
feat: introduce expo-router to expo messaging app (#2150)
* feat: introduce expo-router to expo messaging app * refactor: move api key, user details and token to constants.ts * fix: app name in package.json
1 parent 0fa3d94 commit ea10daa

File tree

20 files changed

+686
-390
lines changed

20 files changed

+686
-390
lines changed

examples/ExpoMessaging/App.tsx

Lines changed: 0 additions & 236 deletions
This file was deleted.

examples/ExpoMessaging/app.json

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33
"name": "ExpoMessaging",
44
"slug": "ExpoMessaging",
55
"privacy": "public",
6-
"platforms": [
7-
"ios",
8-
"android",
9-
"web"
10-
],
116
"version": "1.0.0",
127
"orientation": "portrait",
138
"icon": "./assets/icon.png",
@@ -19,19 +14,26 @@
1914
"updates": {
2015
"fallbackToCacheTimeout": 0
2116
},
22-
"assetBundlePatterns": [
23-
"**/*"
24-
],
17+
"assetBundlePatterns": ["**/*"],
2518
"ios": {
2619
"supportsTablet": true,
2720
"usesIcloudStorage": true,
2821
"bundleIdentifier": "io.stream.expomessaging"
2922
},
23+
"android": {
24+
"package": "io.stream.expomessaging",
25+
"adaptiveIcon": {
26+
"foregroundImage": "./assets/adaptive-icon.png",
27+
"backgroundColor": "#ffffff"
28+
}
29+
},
30+
"web": {
31+
"favicon": "./assets/favicon.png",
32+
"bundler": "metro"
33+
},
3034
"experiments": {
3135
"turboModules": true
3236
},
33-
"android": {
34-
"package": "io.stream.expomessaging"
35-
}
37+
"scheme": "ExpoMessaging"
3638
}
3739
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Stack } from "expo-router";
2+
import { GestureHandlerRootView } from "react-native-gesture-handler";
3+
import { ChatWrapper } from "../components/ChatWrapper";
4+
import { AppProvider } from "../context/AppContext";
5+
import { StyleSheet } from "react-native";
6+
7+
export default function Layout() {
8+
return (
9+
<GestureHandlerRootView style={styles.container}>
10+
<ChatWrapper>
11+
<AppProvider>
12+
<Stack />
13+
</AppProvider>
14+
</ChatWrapper>
15+
</GestureHandlerRootView>
16+
);
17+
}
18+
19+
const styles = StyleSheet.create({
20+
container: {
21+
flex: 1,
22+
},
23+
});
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React, { useContext } from 'react';
2+
import { SafeAreaView, View } from 'react-native';
3+
import { Channel, MessageInput, MessageList } from 'stream-chat-expo';
4+
import { Stack, useRouter } from 'expo-router';
5+
import { AuthProgressLoader } from '../../../components/AuthProgressLoader';
6+
import { AppContext } from '../../../context/AppContext';
7+
8+
export default function ChannelScreen() {
9+
const router = useRouter();
10+
const { setThread, channel } = useContext(AppContext);
11+
12+
if (!channel) {
13+
return <AuthProgressLoader />;
14+
}
15+
16+
return (
17+
<SafeAreaView>
18+
<Stack.Screen options={{ title: 'Channel Screen' }} />
19+
{channel && (
20+
<Channel channel={channel}>
21+
<View style={{ flex: 1 }}>
22+
<MessageList
23+
onThreadSelect={(thread) => {
24+
setThread(thread);
25+
router.push(`/channel/${channel.cid}/thread/${thread.cid}`);
26+
}}
27+
/>
28+
<MessageInput />
29+
</View>
30+
</Channel>
31+
)}
32+
</SafeAreaView>
33+
);
34+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, { useContext } from "react";
2+
import { SafeAreaView, View } from "react-native";
3+
import { Channel, Thread } from "stream-chat-expo";
4+
import { Stack } from "expo-router";
5+
import { AppContext } from "../../../../../context/AppContext";
6+
7+
export default function ThreadScreen() {
8+
const { channel, thread, setThread } = useContext(AppContext);
9+
return (
10+
<SafeAreaView>
11+
<Stack.Screen options={{ title: "Thread Screen" }} />
12+
13+
<Channel channel={channel} thread={thread} threadList>
14+
<View
15+
style={{
16+
flex: 1,
17+
justifyContent: "flex-start",
18+
}}
19+
>
20+
<Thread
21+
onThreadDismount={() => {
22+
setThread(undefined);
23+
}}
24+
/>
25+
</View>
26+
</Channel>
27+
</SafeAreaView>
28+
);
29+
}

0 commit comments

Comments
 (0)