ENEI2019-Public/App/app/Router.js

186 lines
4.7 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,
View
} from 'react-native';
import {
createStackNavigator,
createAppContainer,
createSwitchNavigator,
createBottomTabNavigator
} 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-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'
import Social from './screens/Social'
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-01-30 14:32:25 +00:00
2019-01-31 00:46:49 +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-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
const AppStack = createBottomTabNavigator(
{
2019-02-18 17:44:02 +00:00
Calendar: {
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-02-18 17:44:02 +00:00
2019-01-31 00:46:49 +00:00
Social: {
screen: Social,
2019-01-30 14:32:25 +00:00
navigationOptions: {
2019-01-31 00:46:49 +00:00
tabBarIcon: ({tintColor}) => (
<Icon name="ios-mail" color={tintColor} size={30}/>
)
},
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-02-18 17:44:02 +00:00
Eventos: {
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-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-02-18 17:44:02 +00:00
2019-01-31 00:46:49 +00:00
},
{
initialRouteName: 'Home',
tabBarOptions: {
2019-02-22 23:38:34 +00:00
showLabel: true, // hide labels
activeTintColor: '#CC1A17', // active icon color
2019-01-31 00:46:49 +00:00
inactiveTintColor: '#d8d6c9', // inactive icon color
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-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-02-22 23:38:34 +00:00
<TouchableOpacity style={{marginRight: 20, flex:1, flexDirection:'row'}} onPress={() => navigation.navigate('Profile')}>
<Text>editar</Text>
2019-02-08 14:23:56 +00:00
<IconFA name="user-edit" size={22}/>
2019-02-22 23:38:34 +00:00
2019-02-08 14:23:56 +00:00
</TouchableOpacity>
)
}
2019-02-18 17:44:02 +00:00
}
else if(navigation.state.routes[index].routeName == 'Calendar'){
return {
headerTitle: 'Calendário',
headerRight: (
<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>
)
}
}
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
},
Edit:{
screen: editCalendar
},
choosePath:{
screen: choosePath
2019-02-22 23:38:34 +00:00
},
calendarDetail:{
screen:calendarDetail
2019-02-08 14:23:56 +00:00
}
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-02-12 23:07:19 +00:00
},
{
2019-01-31 00:46:49 +00:00
initialRouteName: 'App'
})
);
2019-01-08 19:09:50 +00:00