1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-12 08:54:00 +02:00
joplin/ElectronClient/app/gui/Navigator.jsx

53 lines
1.2 KiB
React
Raw Normal View History

const React = require('react'); const Component = React.Component;
const { connect } = require('react-redux');
2017-11-11 19:36:47 +02:00
const { app } = require('../app.js');
const { bridge } = require('electron').remote.require('./bridge');
class NavigatorComponent extends Component {
componentWillReceiveProps(newProps) {
if (newProps.route) {
const screenInfo = this.props.screens[newProps.route.routeName];
let windowTitle = ['Joplin'];
if (screenInfo.title) {
windowTitle.push(screenInfo.title());
}
this.updateWindowTitle(windowTitle.join(' - '));
}
}
updateWindowTitle(title) {
bridge().window().setTitle(title);
}
render() {
if (!this.props.route) throw new Error('Route must not be null');
const route = this.props.route;
2017-11-11 19:36:47 +02:00
const screenProps = route.props ? route.props : {};
const screenInfo = this.props.screens[route.routeName];
const Screen = screenInfo.screen;
const screenStyle = {
width: this.props.style.width,
height: this.props.style.height,
};
return (
<div style={this.props.style}>
2017-11-11 19:36:47 +02:00
<Screen style={screenStyle} {...screenProps}/>
</div>
);
}
}
const Navigator = connect(
(state) => {
return {
route: state.route,
};
}
)(NavigatorComponent)
module.exports = { Navigator };