mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-29 00:21:41 +03:00
Working on splash
This commit is contained in:
parent
58948f6a72
commit
0fd01239a6
@ -30,6 +30,6 @@ export default SwitchNavigator({
|
||||
[ROUTES.SCREENS.EDITOR]: { screen: RootComponent()(Editor) },
|
||||
[ROUTES.SCREENS.PINCODE]: { screen: RootComponent()(PinCode) },
|
||||
[ROUTES.SCREENS.PROFILE]: { screen: RootComponent()(Profile) },
|
||||
[ROUTES.SCREENS.SPLASH]: { screen: RootComponent()(Splash) },
|
||||
[ROUTES.SCREENS.SPLASH]: { screen: Splash },
|
||||
[ROUTES.SCREENS.STEEM_CONNECT]: { screen: RootComponent()(SteemConnect) },
|
||||
});
|
||||
|
@ -1,5 +1,9 @@
|
||||
import {
|
||||
LOGIN, LOGOUT, OPEN_PIN_CODE_MODAL, CLOSE_PIN_CODE_MODAL,
|
||||
LOGIN,
|
||||
LOGOUT,
|
||||
OPEN_PIN_CODE_MODAL,
|
||||
CLOSE_PIN_CODE_MODAL,
|
||||
ACTIVE_APPLICATION,
|
||||
} from '../constants/constants';
|
||||
|
||||
export const login = () => ({
|
||||
@ -17,3 +21,7 @@ export const openPinCodeModal = () => ({
|
||||
export const closePinCodeModal = () => ({
|
||||
type: CLOSE_PIN_CODE_MODAL,
|
||||
});
|
||||
|
||||
export const activeApplication = () => ({
|
||||
type: ACTIVE_APPLICATION,
|
||||
});
|
||||
|
@ -17,3 +17,4 @@ export const FETCH_ACCOUNT_FAIL = 'FETCH_ACCOUNT_FAIL';
|
||||
export const IS_LOGGED_IN = 'IS_LOGGED_IN';
|
||||
export const OPEN_PIN_CODE_MODAL = 'OPEN_PIN_CODE_MODAL';
|
||||
export const CLOSE_PIN_CODE_MODAL = 'CLOSE_PIN_CODE_MODAL';
|
||||
export const ACTIVE_APPLICATION = 'ACTIVE_APPLICATION';
|
||||
|
@ -1,11 +1,16 @@
|
||||
import {
|
||||
LOGIN, LOGOUT, OPEN_PIN_CODE_MODAL, CLOSE_PIN_CODE_MODAL,
|
||||
LOGIN,
|
||||
LOGOUT,
|
||||
OPEN_PIN_CODE_MODAL,
|
||||
CLOSE_PIN_CODE_MODAL,
|
||||
ACTIVE_APPLICATION,
|
||||
} from '../constants/constants';
|
||||
|
||||
const initialState = {
|
||||
isLoggedIn: false, // Has any logged in user.
|
||||
loading: false, // It is lock to all screen and shows loading animation.
|
||||
isPinCodeReqiure: false,
|
||||
isActive: false,
|
||||
};
|
||||
|
||||
export default function (state = initialState, action) {
|
||||
@ -30,6 +35,11 @@ export default function (state = initialState, action) {
|
||||
...state,
|
||||
isPinCodeReqiure: false,
|
||||
};
|
||||
case ACTIVE_APPLICATION:
|
||||
return {
|
||||
...state,
|
||||
isActive: true,
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ import { openPinCodeModal } from '../../../redux/actions/applicationActions';
|
||||
import { Modal } from '../../../components';
|
||||
import { PinCode } from '../..';
|
||||
|
||||
// Constants
|
||||
import { default as ROUTES } from '../../../constants/routeNames';
|
||||
|
||||
const RootContainer = () => (WrappedComponent) => {
|
||||
class RootComponent extends Component {
|
||||
constructor(props) {
|
||||
@ -20,6 +23,13 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
};
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
const { isActive, navigation } = this.props;
|
||||
if (!isActive) {
|
||||
navigation.navigate(ROUTES.SCREENS.SPLASH);
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
AppState.addEventListener('change', this._handleAppStateChange);
|
||||
}
|
||||
@ -74,6 +84,7 @@ const RootContainer = () => (WrappedComponent) => {
|
||||
}
|
||||
const mapStateToProps = state => ({
|
||||
isPinCodeReqiure: state.application.isPinCodeReqiure,
|
||||
isActiveApp: state.application.isActive,
|
||||
});
|
||||
|
||||
return connect(mapStateToProps)(RootComponent);
|
||||
|
@ -16,13 +16,16 @@ class SplashContainer extends Component {
|
||||
const { navigation } = this.props;
|
||||
|
||||
getAuthStatus().then((res) => {
|
||||
console.log('=========res=========', res);
|
||||
|
||||
getUserData().then((response) => {
|
||||
if (response) {
|
||||
navigation.navigate(ROUTES.SCREENS.PINCODE);
|
||||
// navigation.navigate(ROUTES.DRAWER.MAIN);
|
||||
} else {
|
||||
navigation.navigate(ROUTES.SCREENS.LOGIN);
|
||||
}
|
||||
console.log('=========response=========', response);
|
||||
// if (response) {
|
||||
// navigation.navigate(ROUTES.SCREENS.PINCODE);
|
||||
// // navigation.navigate(ROUTES.DRAWER.MAIN);
|
||||
// } else {
|
||||
// navigation.navigate(ROUTES.SCREENS.LOGIN);
|
||||
// }
|
||||
});
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user