2017-11-04 17:42:20 +02:00
|
|
|
const React = require('react');
|
|
|
|
const { render } = require('react-dom');
|
|
|
|
const { createStore } = require('redux');
|
2017-11-04 18:40:34 +02:00
|
|
|
const { connect, Provider } = require('react-redux');
|
|
|
|
|
2017-11-06 20:35:04 +02:00
|
|
|
const { MainScreen } = require('./MainScreen.min.js');
|
|
|
|
const { OneDriveAuthScreen } = require('./OneDriveAuthScreen.min.js');
|
|
|
|
const { Navigator } = require('./Navigator.min.js');
|
2017-11-04 17:42:20 +02:00
|
|
|
|
2017-11-05 02:17:48 +02:00
|
|
|
const { app } = require('../app');
|
|
|
|
|
|
|
|
const { bridge } = require('electron').remote.require('./bridge');
|
|
|
|
|
|
|
|
async function initialize(dispatch) {
|
|
|
|
bridge().window().on('resize', function() {
|
|
|
|
store.dispatch({
|
|
|
|
type: 'WINDOW_CONTENT_SIZE_SET',
|
|
|
|
size: bridge().windowContentSize(),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
store.dispatch({
|
|
|
|
type: 'WINDOW_CONTENT_SIZE_SET',
|
|
|
|
size: bridge().windowContentSize(),
|
|
|
|
});
|
|
|
|
}
|
2017-11-04 17:42:20 +02:00
|
|
|
|
2017-11-06 20:35:04 +02:00
|
|
|
class RootComponent extends React.Component {
|
2017-11-04 17:42:20 +02:00
|
|
|
|
2017-11-05 02:17:48 +02:00
|
|
|
async componentDidMount() {
|
|
|
|
if (this.props.appState == 'starting') {
|
|
|
|
this.props.dispatch({
|
|
|
|
type: 'SET_APP_STATE',
|
|
|
|
state: 'initializing',
|
|
|
|
});
|
|
|
|
|
|
|
|
await initialize(this.props.dispatch);
|
|
|
|
|
|
|
|
this.props.dispatch({
|
|
|
|
type: 'SET_APP_STATE',
|
|
|
|
state: 'ready',
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-04 17:42:20 +02:00
|
|
|
render() {
|
2017-11-06 20:35:04 +02:00
|
|
|
const navigatorStyle = {
|
2017-11-04 21:46:37 +02:00
|
|
|
width: this.props.size.width,
|
|
|
|
height: this.props.size.height,
|
|
|
|
};
|
|
|
|
|
2017-11-06 20:35:04 +02:00
|
|
|
const screens = {
|
|
|
|
Main: { screen: MainScreen },
|
|
|
|
OneDriveAuth: { screen: OneDriveAuthScreen },
|
2017-11-04 21:46:37 +02:00
|
|
|
};
|
|
|
|
|
2017-11-04 17:42:20 +02:00
|
|
|
return (
|
2017-11-06 20:35:04 +02:00
|
|
|
<Navigator style={navigatorStyle} screens={screens} />
|
2017-11-04 21:46:37 +02:00
|
|
|
);
|
2017-11-04 17:42:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-11-04 18:40:34 +02:00
|
|
|
const mapStateToProps = (state) => {
|
2017-11-04 21:46:37 +02:00
|
|
|
return {
|
|
|
|
size: state.windowContentSize,
|
2017-11-05 02:17:48 +02:00
|
|
|
appState: state.appState,
|
2017-11-04 21:46:37 +02:00
|
|
|
};
|
2017-11-04 18:40:34 +02:00
|
|
|
};
|
|
|
|
|
2017-11-06 20:35:04 +02:00
|
|
|
const Root = connect(mapStateToProps)(RootComponent);
|
2017-11-04 18:40:34 +02:00
|
|
|
|
2017-11-04 17:42:20 +02:00
|
|
|
const store = app().store();
|
|
|
|
|
|
|
|
render(
|
|
|
|
<Provider store={store}>
|
2017-11-06 20:35:04 +02:00
|
|
|
<Root />
|
2017-11-04 17:42:20 +02:00
|
|
|
</Provider>,
|
|
|
|
document.getElementById('react-root')
|
|
|
|
)
|