import React from 'react'; import {Modal, DeviceEventEmitter, View, TouchableOpacity} from 'react-native'; import {createAppContainer} from 'react-navigation'; import {createStackNavigator} from 'react-navigation-stack'; import {ACTIONS} from '../../provider/actions'; import {updateEvent} from '../DialogManager'; import * as Animatable from 'react-native-animatable'; import Login from '../../views/Login'; import Signup from '../../views/Signup'; import ForgotPassword from '../../views/ForgotPassword'; import {DDS} from '../../../App'; import {getElevation, w} from '../../utils/utils'; import {eSendEvent} from '../../services/eventManager'; import {eLoginDialogNavigateBack} from '../../services/events'; const fade = props => { const {position, scene} = props; const index = scene.index; const translateX = 0; const translateY = 0; const opacity = position.interpolate({ inputRange: [index - 0.7, index, index + 0.7], outputRange: [0.7, 1, 0.7], }); return { opacity, transform: [{translateX}, {translateY}], }; }; const ModalNavigator = createStackNavigator( { Login: { screen: Login, }, Signup: { screen: Signup, }, ForgotPassword: { screen: ForgotPassword, }, }, { initialRouteName: 'Login', defaultNavigationOptions: { gesturesEnabled: false, headerStyle: { backgroundColor: 'transparent', borderBottomWidth: 0, height: 0, }, }, transitionConfig: () => ({ screenInterpolator: props => { return fade(props); }, }), }, ); const Navigator = createAppContainer(ModalNavigator); class LoginDialog extends React.Component { constructor(props) { super(props); this.state = { visible: false, animated: false, }; this.routeIndex = 0; this.count = 0; } open() { updateEvent({type: ACTIONS.LOGIN_NAVIGATOR, enabled: true}); this.setState({ visible: true, }); } close() { this.setState({ visible: false, animated: false, }); } render() { const {visible, animated} = this.state; const {colors} = this.props; return ( { this.setState({ animated: true, }); }} onRequestClose={() => { if (!this.routeIndex || this.routeIndex === 0) { updateEvent({type: ACTIONS.LOGIN_NAVIGATOR, enabled: false}); this.close(); } else { eSendEvent(eLoginDialogNavigateBack); } }} visible={visible} transparent={true}> this.close()} style={{ width: '100%', height: '100%', position: 'absolute', zIndex: 1, }} /> (this.navigation = ref)} onNavigationStateChange={state => { this.routeIndex = state.index; console.log(state); }} /> ); } } export default LoginDialog;