2016-04-01 06:52:03 +08:00
|
|
|
import React from 'react';
|
|
|
|
import {RetinaImg, Flexbox} from 'nylas-component-kit';
|
|
|
|
|
|
|
|
class AppearanceModeSwitch extends React.Component {
|
|
|
|
|
|
|
|
static displayName = 'AppearanceModeSwitch';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
config: React.PropTypes.object.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super();
|
|
|
|
this.state = {
|
|
|
|
value: props.config.get('core.workspace.mode'),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillReceiveProps(nextProps) {
|
|
|
|
this.setState({
|
|
|
|
value: nextProps.config.get('core.workspace.mode'),
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_onApplyChanges = () => {
|
2016-04-25 01:16:25 +08:00
|
|
|
NylasEnv.commands.dispatch(`application:select-${this.state.value}-mode`);
|
2016-04-01 06:52:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
_renderModeOptions() {
|
|
|
|
return ['list', 'split'].map((mode) =>
|
|
|
|
<AppearanceModeOption
|
|
|
|
mode={mode}
|
|
|
|
key={mode}
|
|
|
|
active={this.state.value === mode}
|
2016-05-07 07:24:40 +08:00
|
|
|
onClick={() => this.setState({value: mode})}
|
|
|
|
/>
|
2016-04-01 06:52:03 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const hasChanges = this.state.value !== this.props.config.get('core.workspace.mode');
|
|
|
|
let applyChangesClass = "btn";
|
|
|
|
if (!hasChanges) applyChangesClass += " btn-disabled";
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="appearance-mode-switch">
|
|
|
|
<Flexbox
|
|
|
|
direction="row"
|
|
|
|
style={{alignItems: "center"}}
|
2016-05-07 07:24:40 +08:00
|
|
|
className="item"
|
|
|
|
>
|
2016-04-01 06:52:03 +08:00
|
|
|
{this._renderModeOptions()}
|
|
|
|
</Flexbox>
|
|
|
|
<div className={applyChangesClass} onClick={this._onApplyChanges}>Apply Layout</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-05-07 07:24:40 +08:00
|
|
|
const AppearanceModeOption = function AppearanceModeOption(props) {
|
|
|
|
let classname = "appearance-mode";
|
|
|
|
if (props.active) classname += " active";
|
|
|
|
|
|
|
|
const label = {
|
|
|
|
list: 'Single Panel',
|
|
|
|
split: 'Two Panel',
|
|
|
|
}[props.mode];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={classname} onClick={props.onClick}>
|
|
|
|
<RetinaImg name={`appearance-mode-${props.mode}.png`} mode={RetinaImg.Mode.ContentIsMask} />
|
|
|
|
<div>{label}</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
AppearanceModeOption.propTypes = {
|
|
|
|
mode: React.PropTypes.string.isRequired,
|
|
|
|
active: React.PropTypes.bool,
|
|
|
|
onClick: React.PropTypes.func,
|
2016-04-01 06:52:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
class PreferencesAppearance extends React.Component {
|
|
|
|
|
|
|
|
static displayName = 'PreferencesAppearance';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
config: React.PropTypes.object,
|
|
|
|
configSchema: React.PropTypes.object,
|
|
|
|
}
|
|
|
|
|
2016-04-20 08:14:25 +08:00
|
|
|
onClick = () => {
|
2016-04-25 01:16:25 +08:00
|
|
|
NylasEnv.commands.dispatch("window:launch-theme-picker");
|
2016-04-20 08:14:25 +08:00
|
|
|
}
|
|
|
|
|
2016-04-01 06:52:03 +08:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div className="container-appearance">
|
|
|
|
<label>Change layout:</label>
|
|
|
|
<AppearanceModeSwitch config={this.props.config} />
|
2016-04-20 08:14:25 +08:00
|
|
|
<button className="btn btn-large" onClick={this.onClick}>Change theme...</button>
|
2016-04-01 06:52:03 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default PreferencesAppearance;
|