-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
171 lines (155 loc) · 5.09 KB
/
App.js
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import React, {useEffect} from 'react';
import {NavigationContainer, DarkTheme} from '@react-navigation/native';
import {RecoilRoot} from 'recoil';
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
import {StyleSheet, Text, View} from 'react-native';
import {ColorfulTabBar} from 'react-navigation-tabbar-collection';
import Icon from 'react-native-vector-icons/AntDesign';
import HomeIndex from './src/screens/Home/Index';
import PlayerScreen from './src/screens/Player';
import analytics from '@react-native-firebase/analytics';
import {StoreProvider} from 'easy-peasy';
import SettingScreen from './src/screens/Setting/index';
import LikesScreen from './src/screens/Likes/index';
import Onboarding from './src/screens/Onboarding/index'
// import easyPeasyStore from './src/providers/EasyPeasyStore'
import messaging from '@react-native-firebase/messaging';
const Tab = createBottomTabNavigator();
const DemoScreen = ({route}) => (
<View style={styles.screen}>
<Text style={{color: 'white'}}>All Your Liked/Saved Bayans Will Appear Here...</Text>
</View>
);
const App = () => {
// for firebase analytics
const routeNameRef = React.useRef();
const navigationRef = React.useRef();
useEffect(() => {
// Assume a message-notification contains a "type" property in the data payload of the screen to open
messaging().onNotificationOpenedApp(remoteMessage => {
console.log(
'Notification caused app to open from background state:',
remoteMessage.notification,
);
// navigation.navigate(remoteMessage.data.type);
});
// Check whether an initial notification is available
messaging()
.getInitialNotification()
.then(remoteMessage => {
if (remoteMessage) {
console.log(
'Notification caused app to open from quit state:',
remoteMessage.notification,
);
// setInitialRoute(remoteMessage.data.type); // e.g. "Settings"
}
// setLoading(false);
});
async function getToken(){
await messaging().registerDeviceForRemoteMessages();
const token = await messaging().getToken();
return token;
}
console.log('token= '+ JSON.stringify(getToken()));
}, []);
return (
<RecoilRoot>
{/* <Onboarding /> */}
<NavigationContainer
theme={DarkTheme}
ref={navigationRef}
onReady={() => {
routeNameRef.current = navigationRef.current.getCurrentRoute().name;
}}
onStateChange={async () => {
const previousRouteName = routeNameRef.current;
const currentRouteName = navigationRef.current.getCurrentRoute().name;
if (previousRouteName !== currentRouteName) {
await analytics().logScreenView({
screen_name: currentRouteName,
screen_class: currentRouteName,
});
}
routeNameRef.current = currentRouteName;
}}>
<Tab.Navigator
initialRouteName="Home"
tabBar={props => <ColorfulTabBar {...props} darkMode={true} />}>
<Tab.Screen
name="Home"
component={HomeIndex}
options={{
title: 'Home',
headerShown: false,
icon: ({focused, color, size}) => (
<Icon name="home" size={size} color={color} />
),
color: 'primary',
}}
/>
{/* <Tab.Screen
name="Player"
component={PlayerScreen}
options={{
title: 'Player',
icon: ({focused, color, size}) => (
<Icon name="sharealt" size={size} color={color} />
),
color: 'info',
}}
/>
<Tab.Screen
name="Chat"
component={DemoScreen}
options={{
title: 'Chat',
icon: ({focused, color, size}) => (
<Icon name="API" size={size} color={color} />
),
color: 'warning',
}}
/> */}
<Tab.Screen
name="Likes"
component={LikesScreen}
options={{
title: 'Liked',
headerStyle: {
backgroundColor: '#181818',
},
headerTintColor: 'white',
icon: ({focused, color, size}) => (
<Icon name="hearto" size={size} color={color} />
),
color: 'danger',
}}
/>
<Tab.Screen
name="Settings"
component={SettingScreen}
options={{
headerShown: false,
title: 'Settings',
icon: ({focused, color, size}) => (
<Icon name="setting" size={size} color={color} />
),
color: 'success',
}}
/>
</Tab.Navigator>
</NavigationContainer>
</RecoilRoot>
);
};
export default App;
const styles = StyleSheet.create({
screen: {
width: '100%',
height: '100%',
flex: 6,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: 'black',
},
});