Skip to content
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

Write and implement method to dismiss modal when new scene is pushed #121

Merged
merged 1 commit into from
Sep 21, 2017
Merged
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
30 changes: 25 additions & 5 deletions js/components/NavMenuPopUp/NavMenuPopUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import {
Text,
View,
TouchableOpacity,
Image
Image,
Alert
} from 'react-native';
import PropTypes from 'prop-types';
import Modal from 'react-native-modal';
import { logout } from '../../config/helpers';
import { auth } from '../../config/firebase';
import { pushSceneFromModal } from '../../navigation/navHelpers';
import { popModal } from '../../redux/modules/moreModal';
import { styles } from './styles';
Expand All @@ -19,11 +21,29 @@ import question from '../../assets/icons/quick_guide.png';

const NavMenuPopUp = ({ isModalVisible, navigatorUID, dispatch }) => {

function dismissModalWithPush([navigatorUID, scene]) {
if(auth.currentUser) {
dispatch(popModal(!isModalVisible));
pushSceneFromModal([navigatorUID, scene]);
} else {
Alert.alert('You must be logged in to view the requested page')
}
}

function combinedLogout([navigatorUID, scene]) {
if(auth.currentUser) {
dispatch(popModal(!isModalVisible));
logout();
pushSceneFromModal([navigatorUID, scene]);
} else {
Alert.alert('You are not currently logged in');
}
}

const popUpItems = [
{title: 'Settings', icon: settings, func: console.log, action: 'settings page'},
{title: 'View / Edit Profile', icon: profile, func: console.log, action: 'profile page'},
{title: 'Survey', icon: question, func: pushSceneFromModal, action: [navigatorUID, 'surveys']},
{title: 'Log Out', icon: logoutIcon, func: logout, action: null},
{title: 'Settings', icon: settings, func: dismissModalWithPush, action: [navigatorUID, 'settings']},
{title: 'View / Edit Profile', icon: profile, func: dismissModalWithPush, action: [navigatorUID, 'profile']},
{title: 'Log Out', icon: logoutIcon, func: combinedLogout, action: [navigatorUID, 'landing']},
];

const PopUpList = ({ data }) => {
Expand Down
Loading