From 7e7dd5244e8d26485ad7950a89c04c98c4fef83f Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 11 Mar 2019 21:00:02 +0400 Subject: Initial commit/ --- frontend/app/app.js | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 frontend/app/app.js (limited to 'frontend/app/app.js') diff --git a/frontend/app/app.js b/frontend/app/app.js new file mode 100644 index 0000000..f469e15 --- /dev/null +++ b/frontend/app/app.js @@ -0,0 +1,92 @@ +import React from 'react'; +import { View } from 'react-native'; +import { + AppLoading, + Font, +} from 'expo'; +import { + createDrawerNavigator, + createStackNavigator, +} from 'react-navigation'; +import { withRkTheme } from 'react-native-ui-kitten'; +import { AppRoutes } from './config/navigation/routesBuilder'; +import * as Screens from './screens'; +import { bootstrap } from './config/bootstrap'; +import track from './config/analytics'; +import { data } from './data'; + +bootstrap(); +data.populateData(); + +const KittenApp = createStackNavigator({ + First: { + screen: Screens.SplashScreen, + }, + Home: { + screen: createDrawerNavigator( + { + ...AppRoutes, + }, + { + contentComponent: (props) => { + const SideMenu = withRkTheme(Screens.SideMenu); + return ; + }, + }, + ), + }, +}, { + headerMode: 'none', +}); + +export default class App extends React.Component { + state = { + isLoaded: false, + }; + + componentWillMount() { + this.loadAssets(); + } + + onNavigationStateChange = (previous, current) => { + const screen = { + current: this.getCurrentRouteName(current), + previous: this.getCurrentRouteName(previous), + }; + if (screen.previous !== screen.current) { + track(screen.current); + } + }; + + getCurrentRouteName = (navigation) => { + const route = navigation.routes[navigation.index]; + return route.routes ? this.getCurrentRouteName(route) : route.routeName; + }; + + loadAssets = async () => { + await Font.loadAsync({ + fontawesome: require('./assets/fonts/fontawesome.ttf'), + icomoon: require('./assets/fonts/icomoon.ttf'), + 'Righteous-Regular': require('./assets/fonts/Righteous-Regular.ttf'), + 'Roboto-Bold': require('./assets/fonts/Roboto-Bold.ttf'), + 'Roboto-Medium': require('./assets/fonts/Roboto-Medium.ttf'), + 'Roboto-Regular': require('./assets/fonts/Roboto-Regular.ttf'), + 'Roboto-Light': require('./assets/fonts/Roboto-Light.ttf'), + }); + this.setState({ isLoaded: true }); + }; + + renderLoading = () => ( + + ); + + renderApp = () => ( + + + + ); + + render = () => (this.state.isLoaded ? this.renderApp() : this.renderLoading()); +} + +Expo.registerRootComponent(App); -- cgit v1.2.3