Change Room’s back button text to previews screen title (#112)

Closes #108
This commit is contained in:
Rodrigo Nascimento 2017-11-23 17:12:06 -02:00 committed by Guilherme Gazzo
parent 9dc16c8adb
commit ed1448b864
2 changed files with 5 additions and 19 deletions

View File

@ -1,6 +1,6 @@
import React from 'react';
import { Platform } from 'react-native';
import { StackNavigator, DrawerNavigator, NavigationActions, HeaderBackButton } from 'react-navigation';
import { StackNavigator, DrawerNavigator } from 'react-navigation';
import Sidebar from '../../containers/Sidebar';
import DrawerMenuButton from '../../presentation/DrawerMenuButton';
@ -13,14 +13,6 @@ import SelectUsersView from '../../views/SelectUsersView';
const drawerPosition = 'left';
const drawerIconPosition = 'headerLeft';
const backToScreen = (navigation, routeName) => {
const action = NavigationActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName })]
});
navigation.dispatch(action);
};
const AuthRoutes = StackNavigator(
{
RoomsList: {
@ -36,13 +28,7 @@ const AuthRoutes = StackNavigator(
screen: RoomView,
navigationOptions({ navigation }) {
return {
title: navigation.state.params.title || 'Room',
headerLeft: (
<HeaderBackButton
title='Back'
onPress={() => backToScreen(navigation, 'RoomsList')}
/>
)
title: navigation.state.params.title || 'Room'
// [drawerIconPosition]: (<DrawerMenuButton navigation={navigation} />)÷
};
}

View File

@ -193,7 +193,7 @@ export default class RoomsListView extends React.Component {
_onPressItem = (id, item = {}) => {
const navigateToRoom = (room) => {
this.props.navigation.navigate('Room', { room });
this.props.navigation.navigate('Room', { room, title: room.name });
};
const clearSearch = () => {
@ -220,7 +220,7 @@ export default class RoomsListView extends React.Component {
}
});
}))
.then(sub => navigateToRoom({ sid: sub._id }))
.then(sub => navigateToRoom({ sid: sub._id, name: sub.name }))
.then(() => clearSearch());
} else {
clearSearch();
@ -229,7 +229,7 @@ export default class RoomsListView extends React.Component {
return;
}
navigateToRoom({ sid: id, ...item });
navigateToRoom({ sid: id, name: item.name });
clearSearch();
}