-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathApp.tsx
128 lines (112 loc) · 3.61 KB
/
App.tsx
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
import React from 'react';
import TimelineScreen from './src/screens/timeline/timeline';
import { createBottomTabNavigator, createStackNavigator, createSwitchNavigator, createAppContainer, NavigationActions } from 'react-navigation';
import { FontAwesome } from '@expo/vector-icons';
import firebase from 'firebase';
import LoginScreen from './src/screens/login/login';
import ProfileScreen from './src/screens/profile/profile';
import PostScreen from './src/screens/post/post';
import AppLoadingScreen from './src/screens/app-loading/app-loading';
import ProfileCreationScreen from './src/screens/profile-creation/profile-creation';
import ChannelsScreen from './src/screens/channels/channels';
import ProfileEditionScreen from './src/screens/profile-edition/profile-edition';
import THEME from './src/theme/theme';
import NotificationsScreen from './src/screens/notifications/notifications';
import i18n from 'i18n-js';
import moment from 'moment';
import 'moment/min/locales';
import * as Localization from 'expo-localization';
// languages
import en from './src/locales/en';
import pt from './src/locales/pt';
const firebaseConfig = require('./firebase.json');
firebase.initializeApp(firebaseConfig);
Localization.getLocalizationAsync().then(localization => {
const locale = localization.locale;
i18n.fallbacks = true;
i18n.translations = { en, pt };
i18n.locale = locale;
if (moment.locales().find(l => l === locale.toLowerCase())) {
moment.locale(locale.toLowerCase());
} else {
moment.locale('en');
}
});
const TabsNavigator = createBottomTabNavigator({
TimelineStack: createStackNavigator({
TimelineScreen,
ProfileScreen,
PostScreen,
NotificationsScreen
}, {
defaultNavigationOptions: {
headerTintColor: 'white',
}
}),
ChannelsStack: createStackNavigator({
ChannelsScreen,
TimelineScreen,
ProfileScreen,
PostScreen
}, {
defaultNavigationOptions: {
headerTintColor: 'white',
}
}),
ProfileStack: createStackNavigator({
ProfileScreen,
PostScreen,
ProfileEditionScreen
}, {
defaultNavigationOptions: {
headerTintColor: 'white',
}
})
},
{
defaultNavigationOptions: ({ navigation }) => ({
tabBarOptions: {
showLabel: false,
activeTintColor: THEME.colors.primary.default,
style: {
backgroundColor: '#F5F5F5',
height: 60
},
},
headerTintColor: 'white',
tabBarIcon: ({ focused, tintColor }) => {
const { routeName } = navigation.state;
const size = focused? 30: 25;
if (routeName === 'TimelineStack') {
return <FontAwesome name="home" size={size} color={tintColor}/>;
} else if (routeName === 'ChannelsStack') {
return <FontAwesome name="hashtag" size={size} color={tintColor}/>;
} else if (routeName === 'ProfileStack') {
return <FontAwesome name="user" size={size} color={tintColor}/>;
}
},
})
});
const AppContainer = createAppContainer(createSwitchNavigator({
AppLoadingScreen,
LoginScreen,
TabsNavigator,
ProfileCreationScreen
}));
class HablaApp extends React.Component<any, any> {
navigator: any;
constructor(props) {
super(props);
// Linking.parseInitialURLAsync().then(this.handleLink);
// Linking.addEventListener('url', event => this.handleLink(Linking.parse(event.url)));
}
render() {
return <AppContainer ref={navigator => this.navigator = navigator}/>
}
// handleLink = (link) => {
// if (link.path === "post") {
// this.navigator.dispatch(NavigationActions.navigate("LoginScreen", { postId: link.queryParams.postId }));
// }
// }
}
export default HablaApp;