diff --git a/app/containers/Sidebar.js b/app/containers/Sidebar.js index 46ef2acb..4ba019fc 100644 --- a/app/containers/Sidebar.js +++ b/app/containers/Sidebar.js @@ -2,6 +2,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { ScrollView, Text, View, StyleSheet, FlatList, TouchableHighlight } from 'react-native'; import { connect } from 'react-redux'; +import { DrawerActions } from 'react-navigation'; import database from '../lib/realm'; import { setServer } from '../actions/server'; @@ -64,16 +65,9 @@ export default class Sidebar extends Component { database.databases.serversDB.removeListener('change', this.updateState); } - onItemPress = ({ route, focused }) => { - this.props.navigation.navigate({ key: 'DrawerClose', routeName: 'DrawerClose' }); - if (!focused) { - this.props.navigation.navigate(route.routeName, undefined); - } - } - onPressItem = (item) => { this.props.selectServer(item.id); - this.props.navigation.navigate({ key: 'DrawerClose', routeName: 'DrawerClose' }); + this.props.navigation.dispatch(DrawerActions.closeDrawer()); } getState = () => ({ diff --git a/app/containers/routes/AuthRoutes.js b/app/containers/routes/AuthRoutes.js index ee753d42..c38082c5 100644 --- a/app/containers/routes/AuthRoutes.js +++ b/app/containers/routes/AuthRoutes.js @@ -1,5 +1,5 @@ import { Platform } from 'react-native'; -import { StackNavigator, DrawerNavigator } from 'react-navigation'; +import { createStackNavigator, createDrawerNavigator } from 'react-navigation'; import Sidebar from '../../containers/Sidebar'; import RoomsListView from '../../views/RoomsListView'; @@ -18,7 +18,7 @@ import RoomMembersView from '../../views/RoomMembersView'; import RoomInfoView from '../../views/RoomInfoView'; import RoomInfoEditView from '../../views/RoomInfoEditView'; -const AuthRoutes = StackNavigator( +const AuthRoutes = createStackNavigator( { RoomsList: { screen: RoomsListView @@ -125,7 +125,7 @@ const AuthRoutes = StackNavigator( } ); -const Routes = DrawerNavigator( +const Routes = createDrawerNavigator( { Home: { screen: AuthRoutes diff --git a/app/containers/routes/NavigationService.js b/app/containers/routes/NavigationService.js index ad53eb8e..a57d7215 100644 --- a/app/containers/routes/NavigationService.js +++ b/app/containers/routes/NavigationService.js @@ -1,4 +1,4 @@ -import { NavigationActions } from 'react-navigation'; +import { NavigationActions, StackActions } from 'react-navigation'; const config = {}; @@ -24,7 +24,7 @@ export function goBack() { export function goRoomsList() { if (config.navigator) { - const action = NavigationActions.reset({ + const action = StackActions.reset({ index: 0, actions: [NavigationActions.navigate({ key: 'RoomsList', routeName: 'RoomsList' })] }); @@ -41,7 +41,7 @@ export function goRoom({ rid, name }, counter = 0) { return setTimeout(() => goRoom({ rid, name }, counter + 1), 100); } - const action = NavigationActions.reset({ + const action = StackActions.reset({ index: 1, actions: [ NavigationActions.navigate({ key: 'RoomsList', routeName: 'RoomsList' }), diff --git a/app/containers/routes/PublicRoutes.js b/app/containers/routes/PublicRoutes.js index 2fdc690e..99fe3a31 100644 --- a/app/containers/routes/PublicRoutes.js +++ b/app/containers/routes/PublicRoutes.js @@ -1,6 +1,6 @@ import React from 'react'; import { TouchableOpacity } from 'react-native'; -import { StackNavigator } from 'react-navigation'; +import { createStackNavigator } from 'react-navigation'; import Icon from 'react-native-vector-icons/FontAwesome'; import ListServerView from '../../views/ListServerView'; @@ -19,7 +19,7 @@ const hasServers = () => { return db.length > 0; }; -const ServerStack = StackNavigator({ +const ServerStack = createStackNavigator({ ListServer: { screen: ListServerView, navigationOptions({ navigation }) { @@ -55,7 +55,7 @@ const ServerStack = StackNavigator({ initialRouteName: hasServers() ? 'ListServer' : 'AddServer' }); -const LoginStack = StackNavigator({ +const LoginStack = createStackNavigator({ Login: { screen: LoginView, navigationOptions: { @@ -73,7 +73,7 @@ const LoginStack = StackNavigator({ headerMode: 'screen' }); -const RegisterStack = StackNavigator({ +const RegisterStack = createStackNavigator({ Register: { screen: RegisterView, navigationOptions: { @@ -98,7 +98,7 @@ const RegisterStack = StackNavigator({ headerMode: 'screen' }); -const PublicRoutes = StackNavigator( +const PublicRoutes = createStackNavigator( { Server: { screen: ServerStack diff --git a/app/views/RoomsListView/Header/index.js b/app/views/RoomsListView/Header/index.js index 9fb5f591..da5ad3b5 100644 --- a/app/views/RoomsListView/Header/index.js +++ b/app/views/RoomsListView/Header/index.js @@ -124,7 +124,7 @@ export default class RoomsListHeaderView extends React.PureComponent { this.props.navigation.navigate({ key: 'DrawerOpen', routeName: 'DrawerOpen' })} + onPress={() => this.props.navigation.openDrawer()} >