ENEI2019-Public/App/app/Router.js

216 lines
6.0 KiB
JavaScript
Raw Normal View History

2019-01-08 19:09:50 +00:00
import React from 'react';
2019-02-18 17:44:02 +00:00
import {
TouchableOpacity,
Text,
2019-03-02 18:18:04 +00:00
View,
2019-03-11 01:30:37 +00:00
Image,
2019-02-18 17:44:02 +00:00
} from 'react-native';
import {
createStackNavigator,
createAppContainer,
createSwitchNavigator,
2019-03-11 01:30:37 +00:00
createBottomTabNavigator,
HeaderBackButton
} from 'react-navigation';
2019-01-08 19:09:50 +00:00
import * as Screens from './screens';
2019-02-12 23:07:19 +00:00
2019-03-11 01:30:37 +00:00
/*Icons*/
import Icon from "react-native-vector-icons/Ionicons"
import IconF from "react-native-vector-icons/Foundation"
import IconFA from "react-native-vector-icons/FontAwesome5"
2019-01-30 14:32:25 +00:00
import AuthLoadingScreen from './screens/AuthLoading'
2019-01-08 19:09:50 +00:00
2019-01-30 14:32:25 +00:00
import Eventos from './screens/Eventos'
2019-03-02 18:18:04 +00:00
import Jogo from './screens/Jogo'
2019-01-30 14:32:25 +00:00
import Scan from './screens/Scan'
import Calendar from './screens/Calendar'
2019-01-31 00:46:49 +00:00
import Home from './screens/Home'
2019-02-12 23:07:19 +00:00
2019-01-31 00:46:49 +00:00
2019-02-08 14:23:56 +00:00
import Profile from "./screens/Profile";
2019-02-18 17:44:02 +00:00
import editCalendar from './screens/editCalendar';
import choosePath from './screens/choosePath';
2019-02-22 23:38:34 +00:00
import calendarDetail from './screens/calendarDetail';
2019-01-30 14:32:25 +00:00
2019-03-11 01:30:37 +00:00
const navigationOptions = ({navigation}) => ({
headerLeft: <HeaderBackButton onPress={() => navigation.goBack(null)}/>,
headerStyle: {backgroundColor: 'transparent', zIndex: 100 },
});
const AppStack = createBottomTabNavigator(
{
2019-03-02 18:18:04 +00:00
Calendário: {
2019-02-18 17:44:02 +00:00
screen: Calendar,
2019-01-30 14:32:25 +00:00
navigationOptions: {
2019-01-31 00:46:49 +00:00
tabBarIcon: ({tintColor}) => (
2019-02-18 17:44:02 +00:00
<IconF name="calendar" color={tintColor} size={30}/>
2019-01-31 00:46:49 +00:00
)
},
2019-01-30 14:32:25 +00:00
},
2019-03-11 01:30:37 +00:00
2019-03-02 18:18:04 +00:00
'Jogo do...': {
screen: Jogo,
2019-01-30 14:32:25 +00:00
navigationOptions: {
2019-01-31 00:46:49 +00:00
tabBarIcon: ({tintColor}) => (
2019-03-11 01:30:37 +00:00
<Image style={{width: 30, height: 30}} source={require('./assets/img/logo2.png')}></Image>
2019-01-31 00:46:49 +00:00
)
},
2019-01-30 14:32:25 +00:00
},
2019-02-08 14:23:56 +00:00
2019-01-31 00:46:49 +00:00
Scan: {
screen: Scan,
2019-01-30 14:32:25 +00:00
navigationOptions: {
2019-01-31 00:46:49 +00:00
tabBarIcon: ({tintColor}) => (
2019-02-22 23:38:34 +00:00
<Icon name="ios-qr-scanner" color={tintColor} size={30}/>
2019-01-31 00:46:49 +00:00
),
},
2019-01-30 14:32:25 +00:00
},
2019-01-31 00:46:49 +00:00
2019-03-11 01:30:37 +00:00
Eventos: {
2019-02-18 17:44:02 +00:00
screen: Eventos,
2019-01-31 00:46:49 +00:00
navigationOptions: {
tabBarIcon: ({tintColor}) => (
2019-02-18 17:44:02 +00:00
<Icon name="ios-beer" color={tintColor} size={30}/>
2019-01-31 00:46:49 +00:00
)
},
2019-01-30 14:32:25 +00:00
},
2019-03-11 01:30:37 +00:00
2019-02-18 17:44:02 +00:00
Home: {
screen: Home,
2019-01-30 14:32:25 +00:00
navigationOptions: {
2019-01-31 00:46:49 +00:00
tabBarIcon: ({tintColor}) => (
2019-02-22 23:38:34 +00:00
<Icon name="ios-person" color={tintColor} size={30}/>
2019-01-31 00:46:49 +00:00
)
2019-01-30 14:32:25 +00:00
},
},
2019-02-08 14:23:56 +00:00
2019-01-31 00:46:49 +00:00
},
{
2019-03-12 03:34:40 +00:00
initialRouteName: 'Home',
2019-01-31 00:46:49 +00:00
tabBarOptions: {
2019-02-22 23:38:34 +00:00
showLabel: true, // hide labels
activeTintColor: '#CC1A17', // active icon color
2019-03-02 18:18:04 +00:00
inactiveTintColor: 'black', // inactive icon color
2019-01-31 00:46:49 +00:00
style: {
backgroundColor: '#fff' // TabBar background
}
}
2019-01-31 00:46:49 +00:00
}
);
2019-01-08 19:09:50 +00:00
2019-02-08 14:23:56 +00:00
const Stack = createStackNavigator({
tabs: {
screen: AppStack,
navigationOptions: ({navigation}) => {
const index = navigation.state.index;
2019-03-12 03:34:40 +00:00
2019-02-18 17:44:02 +00:00
if (navigation.state.routes[index].routeName == 'Home') {
2019-02-08 14:23:56 +00:00
return {
headerTitle: `${navigation.state.routes[index].routeName}`,
headerRight: (
2019-03-11 01:30:37 +00:00
<TouchableOpacity style={{marginRight: 20, flex: 1, flexDirection: 'row'}}
onPress={() => navigation.navigate('Profile')}>
2019-02-22 23:38:34 +00:00
<Text>editar</Text>
2019-02-08 14:23:56 +00:00
<IconFA name="user-edit" size={22}/>
2019-03-11 01:30:37 +00:00
2019-02-08 14:23:56 +00:00
</TouchableOpacity>
)
}
2019-02-18 17:44:02 +00:00
}
2019-03-11 01:30:37 +00:00
else if (navigation.state.routes[index].routeName == 'Calendário') {
2019-02-18 17:44:02 +00:00
return {
headerTitle: 'Calendário',
headerRight: (
2019-03-11 01:30:37 +00:00
<View style={{flex: 1, flexDirection: 'row'}}>
<TouchableOpacity style={{marginRight: 20, flex: 1, flexDirection: 'row'}}
onPress={() => navigation.navigate('Edit')}>
<Text>FAQ</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginRight: 20, flex: 1, flexDirection: 'row'}}
onPress={() => navigation.navigate('choosePath')}>
<Text>Escolher</Text>
<IconFA name="user-edit" size={22}/>
</TouchableOpacity></View>
2019-02-18 17:44:02 +00:00
)
}
2019-03-11 01:30:37 +00:00
}
else if (navigation.state.routes[index].routeName == 'choosePath') {
2019-03-01 17:36:52 +00:00
return {
headerTitle: 'Calendário',
headerRight: (
2019-03-11 01:30:37 +00:00
<View style={{flex: 1, flexDirection: 'row'}}>
<TouchableOpacity style={{marginRight: 20, flex: 1, flexDirection: 'row'}}
onPress={() => navigation.navigate('Edit')}>
<Text>FAQ</Text>
</TouchableOpacity>
<TouchableOpacity style={{marginRight: 20, flex: 1, flexDirection: 'row'}}
onPress={() => navigation.navigate('choosePath')}>
<Text>Escolher</Text>
<IconFA name="user-edit" size={22}/>
</TouchableOpacity></View>
2019-03-01 17:36:52 +00:00
)
}
2019-03-11 01:30:37 +00:00
}
2019-02-18 17:44:02 +00:00
else {
2019-02-08 14:23:56 +00:00
return {
header: null
2019-01-31 00:46:49 +00:00
}
}
}
2019-02-08 14:23:56 +00:00
},
Profile: {
screen: Profile
2019-02-18 17:44:02 +00:00
},
2019-03-11 01:30:37 +00:00
Edit: {
2019-02-18 17:44:02 +00:00
screen: editCalendar
},
2019-03-11 01:30:37 +00:00
choosePath: {
2019-02-18 17:44:02 +00:00
screen: choosePath
2019-02-22 23:38:34 +00:00
},
2019-03-11 01:30:37 +00:00
calendarDetail: {
screen: calendarDetail,
},
2019-02-18 17:44:02 +00:00
2019-02-08 14:23:56 +00:00
});
export default createAppContainer(createSwitchNavigator(
{
AuthLoading: AuthLoadingScreen,
App: Stack,
2019-03-11 01:30:37 +00:00
},
{
2019-01-31 00:46:49 +00:00
initialRouteName: 'App'
})
);
2019-01-08 19:09:50 +00:00