Skip to content

Commit

Permalink
Merge pull request redacademy#121 from redacademy/feature-dismiss-mod…
Browse files Browse the repository at this point in the history
…al-on-nav

Write and implement method to dismiss modal when new scene is pushed
  • Loading branch information
codedavinci authored Sep 21, 2017
2 parents a5e98f6 + 6ec02bc commit e03875d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6,168 deletions.
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

0 comments on commit e03875d

Please sign in to comment.