import React from 'react'; import PropTypes from 'prop-types'; import { RetinaImg, Flexbox } from 'nylas-component-kit'; class AppearanceModeSwitch extends React.Component { static displayName = 'AppearanceModeSwitch'; static propTypes = { config: 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 = () => { AppEnv.commands.dispatch(`application:select-${this.state.value}-mode`); }; _renderModeOptions() { return ['list', 'split'].map(mode => ( this.setState({ value: mode })} /> )); } render() { const hasChanges = this.state.value !== this.props.config.get('core.workspace.mode'); let applyChangesClass = 'btn'; if (!hasChanges) applyChangesClass += ' btn-disabled'; return (
{this._renderModeOptions()}
Apply Layout
); } } 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 (
{label}
); }; AppearanceModeOption.propTypes = { mode: PropTypes.string.isRequired, active: PropTypes.bool, onClick: PropTypes.func, }; class PreferencesAppearance extends React.Component { static displayName = 'PreferencesAppearance'; static propTypes = { config: PropTypes.object, configSchema: PropTypes.object, }; onClick = () => { AppEnv.commands.dispatch('window:launch-theme-picker'); }; render() { return (
); } } export default PreferencesAppearance;