Skip to content

Commit e1bdae5

Browse files
Merge pull request #90 from GetStream/vishal/examples
Updating example apps
2 parents 951f503 + 66d07b6 commit e1bdae5

File tree

84 files changed

+10236
-16989
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+10236
-16989
lines changed

README.md

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
**Quick Links**
1111

12-
* [Stream Chat API](https://getstream.io/chat/) product overview
13-
* [Register](https://getstream.io/chat/trial/) to get an API key for Stream Chat
14-
* [React Native Chat Tutorial](https://getstream.io/chat/react-native-chat/tutorial/)
15-
* [Chat UI Kit](https://getstream.io/chat/ui-kit/)
12+
- [Stream Chat API](https://getstream.io/chat/) product overview
13+
- [Register](https://getstream.io/chat/trial/) to get an API key for Stream Chat
14+
- [React Native Chat Tutorial](https://getstream.io/chat/react-native-chat/tutorial/)
15+
- [Chat UI Kit](https://getstream.io/chat/ui-kit/)
1616

1717
## React Chat Tutorial
1818

19-
The best place to start is the [React Native Chat Tutorial](https://getstream.io/chat/react-native-chat/tutorial/). It teaches you how to use this SDK and also shows how to make common changes.
19+
The best place to start is the [React Native Chat Tutorial](https://getstream.io/chat/react-native-chat/tutorial/). It teaches you how to use this SDK and also shows how to make common changes.
2020

2121
## Example Apps
2222

@@ -28,10 +28,8 @@ This repo includes 2 example apps. One that's used with Expo, and one for native
2828
2. ```bash
2929
yarn global add expo-cli
3030
git clone https://github.com/GetStream/stream-chat-react-native.git
31-
cd stream-chat-react-native
32-
make
33-
cd examples/one
34-
yarn start
31+
cd stream-chat-react-native/examples/ExpoMessaging
32+
yarn && yarn start
3533
```
3634

3735
### Native example
@@ -42,9 +40,8 @@ This repo includes 2 example apps. One that's used with Expo, and one for native
4240

4341
4. ```bash
4442
git clone https://github.com/GetStream/stream-chat-react-native.git
45-
cd stream-chat-react-native
46-
make
47-
cd examples/two
43+
cd stream-chat-react-native/examples/NativeMessaging
44+
yarn install
4845
```
4946
5. - For iOS
5047
```bash
@@ -57,7 +54,7 @@ This repo includes 2 example apps. One that's used with Expo, and one for native
5754

5855
## Docs
5956

60-
The [styleguidist docs for stream-chat-react-native](https://getstream.github.io/stream-chat-react-native/) document how all the components work.
57+
The [styleguidist docs for stream-chat-react-native](https://getstream.github.io/stream-chat-react-native/) document how all the components work.
6158

6259
The React Native components are created using the stream-chat-js library. If you're customizing the components it's important to learn how the Chat Server API works. You'll want to review our [JS chat API docs](https://getstream.io/chat/docs/js/).
6360
@@ -227,8 +224,6 @@ In current context, dependencies such as `react-native-document-picker` and (if
227224

228225
## Common issues
229226

230-
231-
232227
#### While running native example, you may (not necessarily) run into following issues:
233228

234229
1. When you execute `react-native run-ios` for the first time, it starts a metro bundler in parallel. It can result into some errors, since build process isn't complete yet. Try the following to fix this:
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"f9155ac790fd02fadcdeca367b02581c04a353aa6d5aa84409a59f6804c87acd": true,
3+
"89ed26367cdb9b771858e026f2eb95bfdb90e5ae943e716575327ec325f39c44": true
4+
}

examples/one/.gitignore renamed to examples/ExpoMessaging/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ node_modules/**/*
22
.expo/*
33
npm-debug.*
44
*.jks
5+
*.p8
56
*.p12
67
*.key
78
*.mobileprovision
9+
*.orig.*
10+
web-build/
11+
web-report/
12+
13+
# macOS
14+
.DS_Store

examples/one/App.js renamed to examples/ExpoMessaging/App.js

Lines changed: 38 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,22 @@ import {
88
MessageInput,
99
ChannelList,
1010
Thread,
11-
ChannelPreviewMessenger,
1211
CloseButton,
13-
TypingIndicator,
12+
ChannelPreviewMessenger,
1413
} from 'stream-chat-expo';
1514

1615
import { createAppContainer, createStackNavigator } from 'react-navigation';
1716

18-
import { YellowBox } from 'react-native';
19-
20-
YellowBox.ignoreWarnings(['Remote debugger']);
21-
22-
const server = {
23-
// API_KEY: 'qk4nn7rpcn75',
24-
// TOKEN:
25-
// 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjoidGhpZXJyeSJ9.EJ6poZ2UbnJJvbCi6ZiImeEPeIoXVEBSdZN_-2YC3t0',
26-
// USER: 'thierry',
27-
// SERVER_ENDPOINT: 'http://localhost:3030',
28-
};
29-
30-
const apiKey = server.API_KEY || 'qk4nn7rpcn75';
17+
const chatClient = new StreamChat('qk4nn7rpcn75');
3118
const userToken =
32-
server.TOKEN ||
3319
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYmlsbG93aW5nLWZpcmVmbHktOCJ9.CQTVyJ6INIM8u28BxkneY2gdYpamjLzSVUOTZKzfQlg';
34-
const user = server.USER || 'billowing-firefly-8';
35-
36-
const chatClient = new StreamChat(apiKey);
37-
20+
const user = {
21+
id: 'billowing-firefly-8',
22+
name: 'Billowing firefly',
23+
image:
24+
'https://stepupandlive.files.wordpress.com/2014/09/3d-animated-frog-image.jpg',
25+
};
26+
// Read more about style customizations at - https://getstream.io/chat/react-native-chat/tutorial/#custom-styles
3827
const theme = {
3928
avatar: {
4029
image: {
@@ -51,30 +40,15 @@ const theme = {
5140
`,
5241
},
5342
};
54-
55-
if (server.SERVER_ENDPOINT) {
56-
chatClient.setBaseURL(server.SERVER_ENDPOINT);
57-
}
58-
59-
chatClient.setUser(
60-
{
61-
id: user,
62-
},
63-
userToken,
64-
);
43+
6544

6645
const filters = { type: 'messaging' };
67-
const sort = {
68-
last_message_at: -1,
69-
cid: 1,
70-
};
46+
const sort = { last_message_at: -1 };
7147
const options = {
72-
member: true,
48+
state: true,
7349
watch: true,
50+
limit: 30,
7451
};
75-
// const channels = chatClient.queryChannels(filters, sort, {
76-
// watch: true,
77-
// });
7852

7953
class ChannelListScreen extends PureComponent {
8054
static navigationOptions = () => ({
@@ -84,13 +58,13 @@ class ChannelListScreen extends PureComponent {
8458
render() {
8559
return (
8660
<SafeAreaView>
87-
<Chat style={theme} client={chatClient}>
61+
<Chat client={chatClient} style={theme}>
8862
<View style={{ display: 'flex', height: '100%', padding: 10 }}>
8963
<ChannelList
90-
Preview={ChannelPreviewMessenger}
9164
filters={filters}
9265
sort={sort}
9366
options={options}
67+
Preview={ChannelPreviewMessenger}
9468
onSelect={(channel) => {
9569
this.props.navigation.navigate('Channel', {
9670
channel,
@@ -120,11 +94,10 @@ class ChannelScreen extends PureComponent {
12094

12195
return (
12296
<SafeAreaView>
123-
<Chat style={theme} client={chatClient}>
97+
<Chat client={chatClient} style={theme}>
12498
<Channel client={chatClient} channel={channel}>
12599
<View style={{ display: 'flex', height: '100%' }}>
126100
<MessageList
127-
TypingIndicator={TypingIndicator}
128101
onThreadSelect={(thread) => {
129102
this.props.navigation.navigate('Thread', {
130103
thread,
@@ -176,7 +149,7 @@ class ThreadScreen extends PureComponent {
176149

177150
return (
178151
<SafeAreaView>
179-
<Chat style={theme} client={chatClient}>
152+
<Chat client={chatClient}>
180153
<Channel
181154
client={chatClient}
182155
channel={channel}
@@ -219,7 +192,27 @@ const RootStack = createStackNavigator(
219192
const AppContainer = createAppContainer(RootStack);
220193

221194
export default class App extends React.Component {
195+
constructor(props) {
196+
super(props);
197+
this.state = {
198+
clientReady: false
199+
}
200+
}
201+
202+
async componentDidMount() {
203+
204+
await chatClient.setUser(
205+
user,
206+
userToken,
207+
);
208+
209+
this.setState({
210+
clientReady: true
211+
})
212+
}
222213
render() {
223-
return <AppContainer />;
214+
if (this.state.clientReady)
215+
return <AppContainer />;
216+
else return null;
224217
}
225218
}

examples/one/app.json renamed to examples/ExpoMessaging/app.json

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
22
"expo": {
3-
"name": "Example one - stream chat react native",
4-
"slug": "one",
3+
"name": "ExpoMessaging",
4+
"slug": "ExpoMessaging",
55
"privacy": "public",
6-
"sdkVersion": "32.0.0",
7-
"platforms": ["ios", "android"],
6+
"sdkVersion": "35.0.0",
7+
"platforms": [
8+
"ios",
9+
"android",
10+
"web"
11+
],
812
"version": "1.0.0",
913
"orientation": "portrait",
1014
"icon": "./assets/icon.png",
@@ -16,7 +20,9 @@
1620
"updates": {
1721
"fallbackToCacheTimeout": 0
1822
},
19-
"assetBundlePatterns": ["**/*"],
23+
"assetBundlePatterns": [
24+
"**/*"
25+
],
2026
"ios": {
2127
"supportsTablet": true
2228
}
1.07 KB
Loading
File renamed without changes.

examples/one/babel.config.js renamed to examples/ExpoMessaging/babel.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-env node */
21
module.exports = function(api) {
32
api.cache(true);
43
return {

examples/two/metro.config.js renamed to examples/ExpoMessaging/metro.config.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,13 @@ const FS = require('fs'),
138138
const repoDir = PATH.dirname(PATH.dirname(__dirname));
139139

140140
const moduleBlacklist = [
141-
new RegExp(repoDir + '/examples/one/.*'),
142-
new RegExp(repoDir + '/expo-package/.*'),
143-
new RegExp(repoDir + '/native-package/node_modules/.*'),
144-
new RegExp(repoDir + '/node_modules/.*'),
145-
/public.*/,
146-
/node_modules[^/]+\/.*/,
147-
/[^-]build\..*/,
148-
/.*\.bak\/.*/,
149-
/app\/pages\/browser\/.*/,
141+
new RegExp(repoDir + '/projects/stream-chat-react-native/examples/two/.*'),
142+
new RegExp(repoDir + '/projects/stream-chat-react-native/examples/one/.*'),
143+
new RegExp(repoDir + '/projects/stream-chat-react-native/examples/three/.*'),
144+
// new RegExp(repoDir + '/native-example/(.*)'),
145+
new RegExp(repoDir + '/projects/stream-chat-react-native/native-package/.*'),
146+
new RegExp(repoDir + '/projects/stream-chat-react-native/expo-package/node_modules/.*'),
147+
new RegExp(repoDir + '/projects/stream-chat-react-native/node_modules/.*'),
150148
],
151149
baseModulePath = resolvePath(__dirname, 'node_modules'),
152150
// watch alternate roots (outside of project root)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"main": "node_modules/expo/AppEntry.js",
3+
"scripts": {
4+
"start": "expo start",
5+
"android": "expo start --android",
6+
"ios": "expo start --ios",
7+
"web": "expo start --web",
8+
"eject": "expo eject"
9+
},
10+
"dependencies": {
11+
"expo": "^35.0.0",
12+
"react": "16.8.3",
13+
"react-dom": "16.8.3",
14+
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
15+
"react-native-gesture-handler": "~1.3.0",
16+
"react-native-reanimated": "~1.2.0",
17+
"react-native-web": "^0.11.7",
18+
"react-navigation": "3.2.1",
19+
"stream-chat-expo": "^0.3.9"
20+
},
21+
"devDependencies": {
22+
"babel-preset-expo": "^7.1.0"
23+
},
24+
"private": true
25+
}

0 commit comments

Comments
 (0)