2020-04-15 17:39:54 +00:00
|
|
|
import { APP, APP_STATE } from '../actions/actionsTypes';
|
2017-09-21 17:08:00 +00:00
|
|
|
|
|
|
|
const initialState = {
|
2018-07-10 13:40:32 +00:00
|
|
|
root: null,
|
2017-12-01 15:06:56 +00:00
|
|
|
ready: false,
|
2020-04-15 17:39:54 +00:00
|
|
|
foreground: true,
|
2017-12-01 15:06:56 +00:00
|
|
|
background: false
|
2017-09-21 17:08:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default function app(state = initialState, action) {
|
|
|
|
switch (action.type) {
|
2020-04-15 17:39:54 +00:00
|
|
|
case APP_STATE.FOREGROUND:
|
2017-12-01 15:06:56 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
foreground: true,
|
|
|
|
background: false
|
|
|
|
};
|
2020-04-15 17:39:54 +00:00
|
|
|
case APP_STATE.BACKGROUND:
|
2017-12-01 15:06:56 +00:00
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
foreground: false,
|
|
|
|
background: true
|
|
|
|
};
|
2018-07-10 13:40:32 +00:00
|
|
|
case APP.START:
|
|
|
|
return {
|
|
|
|
...state,
|
|
|
|
root: action.root
|
|
|
|
};
|
2017-09-21 17:08:00 +00:00
|
|
|
case APP.INIT:
|
|
|
|
return {
|
|
|
|
...state,
|
2018-12-05 20:52:08 +00:00
|
|
|
ready: false
|
2017-09-21 17:08:00 +00:00
|
|
|
};
|
|
|
|
case APP.READY:
|
|
|
|
return {
|
|
|
|
...state,
|
2018-12-05 20:52:08 +00:00
|
|
|
ready: true
|
2017-09-21 17:08:00 +00:00
|
|
|
};
|
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
}
|