From a9acbec05c598fe98040c17aead7ce3d440d9e93 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Mon, 21 May 2018 15:39:26 -0300 Subject: [PATCH] =?UTF-8?q?Update=20react-navigation=20to=20the=20latest?= =?UTF-8?q?=20version=20=F0=9F=9A=80=20(#293)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(package): update react-navigation to version 2.0.0 * Code updated to support breaking changes of react-navigation --- app/containers/Sidebar.js | 10 +-- app/containers/routes/AuthRoutes.js | 6 +- app/containers/routes/NavigationService.js | 6 +- app/containers/routes/PublicRoutes.js | 10 +-- app/views/RoomsListView/Header/index.js | 2 +- package-lock.json | 72 +++++++++++++++++++--- package.json | 2 +- 7 files changed, 79 insertions(+), 29 deletions(-) diff --git a/app/containers/Sidebar.js b/app/containers/Sidebar.js index 46ef2acbc..4ba019fcd 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 ee753d424..c38082c59 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 ad53eb8ed..a57d72150 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 2fdc690e4..99fe3a314 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 9fb5f5913..da5ad3b5f 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()} >