Commit b5cb71a9 authored by Gijs Hendriksen's avatar Gijs Hendriksen
Browse files

Fixed some navigation issues

The sidebar now closes when the current scene is selected again. Furthermore, upon entering a new `section` of the app, the history is cleared so we don't get a tremendous amount of previous scenes.
Also fixed some lint issues.
parent 6b7af0f9
import * as types from './actionTypes';
export function navigate(scene) {
export function navigate(scene, newSection = false) {
return {
type: types.NAVIGATE,
scene,
newSection,
};
}
......
......@@ -13,14 +13,14 @@ const background = require('../img/huygens.jpg');
const Sidebar = (props) => {
const buttons = [
{
onPress: () => props.navigate('welcome'),
onPress: () => props.navigate('welcome', true),
iconName: 'home',
text: 'Welkom',
style: {},
scene: 'welcome',
},
{
onPress: () => props.navigate('eventList'),
onPress: () => props.navigate('eventList', true),
iconName: 'event',
text: 'Agenda',
style: {},
......@@ -96,7 +96,7 @@ const mapStateToProps = state => ({
});
const mapDispatchToProps = dispatch => ({
navigate: scene => dispatch(actions.navigate(scene)),
navigate: (scene, newSection = false) => dispatch(actions.navigate(scene, newSection)),
logout: () => dispatch(loginActions.logout()),
});
......
......@@ -53,7 +53,7 @@ const ReduxNavigator = (props) => {
mainOverlay: {
backgroundColor: colors.black,
opacity: 0,
elevation: 100
elevation: 100,
},
}}
tweenHandler={ratio => ({ mainOverlay: { opacity: ratio * 0.75 } })}
......
......@@ -17,12 +17,12 @@ const styles = StyleSheet.create({
alignItems: 'center',
flexWrap: 'wrap',
flexDirection: 'row',
elevation: 4
elevation: 4,
},
title: {
color: colors.white,
fontSize: 20,
fontFamily: 'sans-serif-medium'
fontFamily: 'sans-serif-medium',
},
icon: {
paddingLeft: 20,
......
......@@ -34,7 +34,17 @@ export default function navigate(state = initialState, action = {}) {
}
case types.NAVIGATE: {
if (action.scene === currentScene) {
return state;
return {
...state,
drawerOpen: false,
};
} else if (action.newSection) {
return {
previousScenes: [],
currentScene: action.scene,
loggedIn,
drawerOpen: false,
};
}
return {
previousScenes: [
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment