2017-12-01 15:06:56 +00:00
|
|
|
import { FOREGROUND, BACKGROUND, INACTIVE } from 'redux-enhancer-react-native-appstate';
|
2017-09-21 17:08:00 +00:00
|
|
|
import { APP } from '../actions/actionsTypes';
|
|
|
|
|
|
|
|
const initialState = {
|
2017-12-01 15:06:56 +00:00
|
|
|
starting: true,
|
|
|
|
ready: false,
|
|
|
|
inactive: false,
|
|
|
|
background: false
|
2017-09-21 17:08:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function app(state = initialState, action) {
|
|
|
|
switch (action.type) {
|
2017-12-01 15:06:56 +00:00
|
|
|
case FOREGROUND:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
inactive: false,
|
|
|
|
foreground: true,
|
|
|
|
background: false
|
|
|
|
};
|
|
|
|
case BACKGROUND:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
inactive: false,
|
|
|
|
foreground: false,
|
|
|
|
background: true
|
|
|
|
};
|
|
|
|
case INACTIVE:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
inactive: true,
|
|
|
|
foreground: false,
|
|
|
|
background: false
|
|
|
|
};
|
2017-09-21 17:08:00 +00:00
|
|
|
case APP.INIT:
|
|
|
|
return {
|
|
|
|
...state,
|
2017-12-01 15:06:56 +00:00
|
|
|
ready: false,
|
2017-09-21 17:08:00 +00:00
|
|
|
starting: true
|
|
|
|
};
|
|
|
|
case APP.READY:
|
|
|
|
return {
|
|
|
|
...state,
|
2017-12-01 15:06:56 +00:00
|
|
|
ready: true,
|
2017-09-21 17:08:00 +00:00
|
|
|
starting: false
|
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|