2017-09-21 17:08:00 +00:00
|
|
|
import React from 'react';
|
2017-11-14 22:49:17 +00:00
|
|
|
import { Platform } from 'react-native';
|
2017-11-07 16:28:02 +00:00
|
|
|
import { StackNavigator, DrawerNavigator, NavigationActions, HeaderBackButton } from 'react-navigation';
|
2017-09-21 17:08:00 +00:00
|
|
|
|
|
|
|
import Sidebar from '../../containers/Sidebar';
|
|
|
|
import DrawerMenuButton from '../../presentation/DrawerMenuButton';
|
|
|
|
|
|
|
|
import RoomsListView from '../../views/RoomsListView';
|
|
|
|
import RoomView from '../../views/RoomView';
|
|
|
|
import CreateChannelView from '../../views/CreateChannelView';
|
2017-09-25 13:15:28 +00:00
|
|
|
import SelectUsersView from '../../views/SelectUsersView';
|
2017-09-21 17:08:00 +00:00
|
|
|
|
|
|
|
const drawerPosition = 'left';
|
|
|
|
const drawerIconPosition = 'headerLeft';
|
|
|
|
|
2017-09-25 13:15:28 +00:00
|
|
|
const backToScreen = (navigation, routeName) => {
|
|
|
|
const action = NavigationActions.reset({
|
|
|
|
index: 0,
|
|
|
|
actions: [NavigationActions.navigate({ routeName })]
|
|
|
|
});
|
|
|
|
navigation.dispatch(action);
|
|
|
|
};
|
2017-09-21 17:08:00 +00:00
|
|
|
|
|
|
|
const AuthRoutes = StackNavigator(
|
|
|
|
{
|
|
|
|
RoomsList: {
|
|
|
|
screen: RoomsListView,
|
|
|
|
navigationOptions({ navigation }) {
|
|
|
|
return {
|
|
|
|
title: 'Rooms',
|
2017-09-25 13:15:28 +00:00
|
|
|
[drawerIconPosition]: <DrawerMenuButton navigation={navigation} />
|
2017-09-21 17:08:00 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
Room: {
|
|
|
|
screen: RoomView,
|
|
|
|
navigationOptions({ navigation }) {
|
|
|
|
return {
|
2017-09-25 13:15:28 +00:00
|
|
|
title: navigation.state.params.title || 'Room',
|
|
|
|
headerLeft: (
|
2017-11-07 16:28:02 +00:00
|
|
|
<HeaderBackButton
|
2017-11-13 12:58:35 +00:00
|
|
|
title='Back'
|
2017-11-07 16:28:02 +00:00
|
|
|
onPress={() => backToScreen(navigation, 'RoomsList')}
|
|
|
|
/>
|
2017-09-25 13:15:28 +00:00
|
|
|
)
|
2017-09-21 17:08:00 +00:00
|
|
|
// [drawerIconPosition]: (<DrawerMenuButton navigation={navigation} />)÷
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CreateChannel: {
|
|
|
|
screen: CreateChannelView,
|
|
|
|
navigationOptions: {
|
|
|
|
title: 'Create Channel'
|
|
|
|
}
|
2017-09-25 13:15:28 +00:00
|
|
|
},
|
|
|
|
SelectUsers: {
|
|
|
|
screen: SelectUsersView,
|
|
|
|
navigationOptions: {
|
|
|
|
title: 'Select Users'
|
|
|
|
}
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
|
|
|
},
|
2017-09-25 13:15:28 +00:00
|
|
|
{}
|
2017-09-21 17:08:00 +00:00
|
|
|
);
|
|
|
|
|
2017-09-25 13:15:28 +00:00
|
|
|
const Routes = DrawerNavigator(
|
|
|
|
{
|
|
|
|
Home: {
|
|
|
|
screen: AuthRoutes,
|
|
|
|
navigationOptions({ navigation }) {
|
|
|
|
return {
|
|
|
|
title: 'Rooms',
|
|
|
|
[drawerIconPosition]: <DrawerMenuButton navigation={navigation} />
|
|
|
|
};
|
|
|
|
}
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
2017-09-25 13:15:28 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
contentComponent: Sidebar,
|
2017-11-14 22:49:17 +00:00
|
|
|
drawerPosition,
|
|
|
|
navigationOptions: {
|
|
|
|
drawerLockMode: Platform.OS === 'ios' ? 'locked-closed' : 'unlocked'
|
|
|
|
}
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
2017-09-25 13:15:28 +00:00
|
|
|
);
|
2017-09-21 17:08:00 +00:00
|
|
|
|
|
|
|
export default Routes;
|