Skip to content

Commit abf1bd7

Browse files
Updating example apps
1 parent 951f503 commit abf1bd7

File tree

84 files changed

+10214
-17003
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

+10214
-17003
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: 35 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -9,72 +9,22 @@ import {
99
ChannelList,
1010
Thread,
1111
ChannelPreviewMessenger,
12-
CloseButton,
13-
TypingIndicator,
1412
} from 'stream-chat-expo';
1513

1614
import { createAppContainer, createStackNavigator } from 'react-navigation';
1715

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';
16+
const chatClient = new StreamChat('qk4nn7rpcn75');
3117
const userToken =
32-
server.TOKEN ||
3318
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoiYmlsbG93aW5nLWZpcmVmbHktOCJ9.CQTVyJ6INIM8u28BxkneY2gdYpamjLzSVUOTZKzfQlg';
34-
const user = server.USER || 'billowing-firefly-8';
3519

36-
const chatClient = new StreamChat(apiKey);
37-
38-
const theme = {
39-
avatar: {
40-
image: {
41-
size: 32,
42-
},
43-
},
44-
colors: {
45-
primary: 'magenta',
46-
},
47-
spinner: {
48-
css: `
49-
width: 15px;
50-
height: 15px;
51-
`,
52-
},
53-
};
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-
);
6520

6621
const filters = { type: 'messaging' };
67-
const sort = {
68-
last_message_at: -1,
69-
cid: 1,
70-
};
22+
const sort = { last_message_at: -1 };
7123
const options = {
72-
member: true,
24+
state: true,
7325
watch: true,
26+
limit: 30,
7427
};
75-
// const channels = chatClient.queryChannels(filters, sort, {
76-
// watch: true,
77-
// });
7828

7929
class ChannelListScreen extends PureComponent {
8030
static navigationOptions = () => ({
@@ -84,13 +34,13 @@ class ChannelListScreen extends PureComponent {
8434
render() {
8535
return (
8636
<SafeAreaView>
87-
<Chat style={theme} client={chatClient}>
37+
<Chat client={chatClient}>
8838
<View style={{ display: 'flex', height: '100%', padding: 10 }}>
8939
<ChannelList
90-
Preview={ChannelPreviewMessenger}
9140
filters={filters}
9241
sort={sort}
9342
options={options}
43+
Preview={ChannelPreviewMessenger}
9444
onSelect={(channel) => {
9545
this.props.navigation.navigate('Channel', {
9646
channel,
@@ -120,11 +70,10 @@ class ChannelScreen extends PureComponent {
12070

12171
return (
12272
<SafeAreaView>
123-
<Chat style={theme} client={chatClient}>
73+
<Chat client={chatClient}>
12474
<Channel client={chatClient} channel={channel}>
12575
<View style={{ display: 'flex', height: '100%' }}>
12676
<MessageList
127-
TypingIndicator={TypingIndicator}
12877
onThreadSelect={(thread) => {
12978
this.props.navigation.navigate('Thread', {
13079
thread,
@@ -161,7 +110,7 @@ class ThreadScreen extends PureComponent {
161110
borderRadius: 20,
162111
}}
163112
>
164-
<CloseButton />
113+
<Text>X</Text>
165114
</TouchableOpacity>
166115
),
167116
});
@@ -176,7 +125,7 @@ class ThreadScreen extends PureComponent {
176125

177126
return (
178127
<SafeAreaView>
179-
<Chat style={theme} client={chatClient}>
128+
<Chat client={chatClient}>
180129
<Channel
181130
client={chatClient}
182131
channel={channel}
@@ -219,7 +168,32 @@ const RootStack = createStackNavigator(
219168
const AppContainer = createAppContainer(RootStack);
220169

221170
export default class App extends React.Component {
171+
constructor(props) {
172+
super(props);
173+
this.state = {
174+
clientReady: false
175+
}
176+
}
177+
178+
async componentDidMount() {
179+
180+
await chatClient.setUser(
181+
{
182+
id: 'billowing-firefly-8',
183+
name: 'Billowing firefly',
184+
image:
185+
'https://stepupandlive.files.wordpress.com/2014/09/3d-animated-frog-image.jpg',
186+
},
187+
userToken,
188+
);
189+
190+
this.setState({
191+
clientReady: true
192+
})
193+
}
222194
render() {
223-
return <AppContainer />;
195+
if (this.state.clientReady)
196+
return <AppContainer />;
197+
else return null;
224198
}
225199
}

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)