Skip to content

Support for Register screen #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: nestedTab
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/Components/LoginScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@ import React, { Component } from "react";
import { connect } from "react-redux";
import { Text, View, TouchableOpacity, StyleSheet } from "react-native";
import { login } from "../Actions/actionCreator";
import { NavigationActions } from "react-navigation";

class LoginScreen extends Component {
static navigationOptions = {
title: "Login"
};
navigate = () => {
const navigateToRegister = NavigationActions.navigate({
routeName: "screen1"

});
this.props.navigation.dispatch(navigateToRegister);
};
render() {
return (
<View style={styles.rootContainer}>
Expand All @@ -27,6 +35,12 @@ class LoginScreen extends Component {
>
<Text style={{ color: "white", fontSize: 22 }}>Login</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={this.navigate}
style={styles.touchableStyles}
>
<Text style={{ color: "white", fontSize: 22 }}>Register</Text>
</TouchableOpacity>
</View>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Components/screen2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class LogoutScreen extends Component {
alignItems: "center"
}}
>
<Text>{this.props.navigation.state.params.name}</Text>
<Text>{'Test'}</Text>
<TouchableOpacity
onPress={this.props.logout}
style={styles.touchableStyles}
Expand Down
1 change: 1 addition & 0 deletions src/Navigation/navigationStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ const navigator = StackNavigator({
}
});

export {Tabs}
export default navigator;
12 changes: 6 additions & 6 deletions src/Reducers/navigationReducer.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { NavigationActions } from "react-navigation";

import AppNavigator from "../Navigation/navigationStack";
import AppNavigator, {Tabs} from "../Navigation/navigationStack";
import { Login, Logout } from "../Actions/actionTypes";

const ActionForLoggedOut = AppNavigator.router.getActionForPathAndParams(
"login"
);

const ActionForLoggedIn = AppNavigator.router.getActionForPathAndParams(
"screen1"
const ActionForLoggedIn = Tabs.router.getActionForPathAndParams(
"feed"
);

const stateForLoggedOut = AppNavigator.router.getStateForAction(
ActionForLoggedOut
);

const stateForLoggedIn = AppNavigator.router.getStateForAction(
const stateForLoggedIn = Tabs.router.getStateForAction(
ActionForLoggedIn
);

Expand Down Expand Up @@ -52,10 +52,10 @@ const navigationReducer = (state = initialState, action) => {
)
};

/* Other logic for logging out, more cleaner but unlike the above isn't telling the reader
/* Other logic for logging out, more cleaner but unlike the above isn't telling the reader
that navigation is reset, that's why I chose the *reset* one for the article. I prefer
this one, what about you?

case 'LOGOUT':
nextState = { ...state, initialStateForLoggedIn, initialStateForLoggedOut}
break;
Expand Down