forked from GetStream/react-native-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
124 lines (111 loc) · 3.09 KB
/
App.js
File metadata and controls
124 lines (111 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//@flow
import React from 'react';
import {
createStackNavigator,
createBottomTabNavigator,
} from 'react-navigation';
import {
STREAM_API_KEY,
STREAM_API_TOKEN,
STREAM_APP_ID,
} from 'babel-dotenv';
import Icon from './components/Icon';
import HomeScreen from './screens/HomeScreen';
import SearchScreen from './screens/SearchScreen';
import NotificationsScreen from './screens/NotificationsScreen';
import ProfileScreen from './screens/ProfileScreen';
import EditProfileScreen from './screens/EditProfileScreen';
import SinglePostScreen from './screens/SinglePostScreen';
import StatusUpdateScreen from './screens/StatusUpdateScreen';
import {
Avatar,
StreamApp,
IconBadge,
} from 'expo-activity-feed';
import type { UserResponse } from './types';
// $FlowFixMe
const NotificationsStack = createStackNavigator({
Notifications: { screen: NotificationsScreen },
});
const ProfileStack = createStackNavigator({
Profile: { screen: ProfileScreen },
});
const SearchStack = createStackNavigator({
Search: { screen: SearchScreen },
});
const HomeStack = createStackNavigator({
Home: { screen: HomeScreen },
});
const TabNavigator = createBottomTabNavigator(
{
Home: HomeStack,
Search: SearchStack,
Notifications: NotificationsStack,
Profile: ProfileStack,
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: () => {
const { routeName } = navigation.state;
if (routeName === 'Home') {
return <Icon name="home" />;
} else if (routeName === 'Search') {
return <Icon name="search" />;
} else if (routeName === 'Notifications') {
return (
<IconBadge showNumber>
<Icon name="notifications" />
</IconBadge>
);
} else if (routeName === 'Profile') {
return (
<Avatar
source={(userData: UserResponse) => userData.data.profileImage}
size={25}
noShadow
/>
);
}
},
}),
initialRouteName: 'Home',
},
);
const doNotShowHeaderOption = {
navigationOptions: {
header: null,
},
};
const Navigation = createStackNavigator({
Tabs: {
screen: TabNavigator,
...doNotShowHeaderOption,
},
SinglePost: { screen: SinglePostScreen },
NewPost: { screen: StatusUpdateScreen },
EditProfile: { screen: EditProfileScreen },
});
const App = () => {
let apiKey = STREAM_API_KEY;
let appId = STREAM_APP_ID;
let token = STREAM_API_TOKEN;
return (
<StreamApp
apiKey={apiKey}
appId={appId}
token={token}
defaultUserData={{
name: 'Batman',
url: 'batsignal.com',
desc: 'Smart, violent and brutally tough solutions to crime.',
profileImage:
'https://i.kinja-img.com/gawker-media/image/upload/s--PUQWGzrn--/c_scale,f_auto,fl_progressive,q_80,w_800/yktaqmkm7ninzswgkirs.jpg',
coverImage:
'https://i0.wp.com/photos.smugmug.com/Portfolio/Full/i-mwrhZK2/0/ea7f1268/X2/GothamCity-X2.jpg?resize=1280%2C743&ssl=1',
}}
>
<Navigation />
</StreamApp>
);
};
export default App;