Refactoring Color Schemes
This commit is contained in:
parent
8b8286e593
commit
1d93bbf63b
|
@ -77,12 +77,9 @@ class DocumentSettingsController extends Component {
|
|||
return api.asc_GetCurrentColorSchemeIndex();
|
||||
}
|
||||
|
||||
onColorSchemeChange(newScheme, curScheme) {
|
||||
onColorSchemeChange(newScheme) {
|
||||
const api = Common.EditorApi.get();
|
||||
if(newScheme !== curScheme) {
|
||||
api.asc_ChangeColorSchemeByIdx(+newScheme);
|
||||
}
|
||||
|
||||
api.asc_ChangeColorSchemeByIdx(+newScheme);
|
||||
}
|
||||
|
||||
render () {
|
||||
|
|
|
@ -61,12 +61,7 @@ export class storeDocumentSettings {
|
|||
|
||||
// Color Schemes
|
||||
|
||||
|
||||
@observable curScheme;
|
||||
|
||||
// @action changeColorScheme(value) {
|
||||
// this.curScheme = +value;
|
||||
// }
|
||||
@observable allSchemes;
|
||||
|
||||
@action addSchemes(arr) {
|
||||
this.allSchemes = arr;
|
||||
|
|
|
@ -132,14 +132,8 @@ const PageDocumentColorSchemes = props => {
|
|||
const [stateScheme, setScheme] = useState(curScheme);
|
||||
const _t = t('Settings', {returnObjects: true});
|
||||
const storeSettings = props.storeDocumentSettings;
|
||||
// const curScheme = storeSettings.curScheme;
|
||||
const allSchemes = storeSettings.allSchemes;
|
||||
|
||||
const changeScheme = (newScheme, curScheme) => {
|
||||
// storeSettings.changeColorScheme(newScheme);
|
||||
props.onColorSchemeChange(newScheme, curScheme);
|
||||
}
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<Navbar title={_t.textColorSchemes} backLink={_t.textBack} />
|
||||
|
@ -149,8 +143,10 @@ const PageDocumentColorSchemes = props => {
|
|||
return (
|
||||
<ListItem radio={true} className="color-schemes-menu" key={index} title={scheme.get_name()} checked={stateScheme === index}
|
||||
onChange={() => {
|
||||
setScheme(index);
|
||||
changeScheme(index, curScheme);
|
||||
if(index !== curScheme) {
|
||||
setScheme(index);
|
||||
props.onColorSchemeChange(index);
|
||||
};
|
||||
}}>
|
||||
<div slot="before-title">
|
||||
<span className="color-schema-block">
|
||||
|
@ -169,13 +165,13 @@ const PageDocumentColorSchemes = props => {
|
|||
</div>
|
||||
</ListItem>
|
||||
)
|
||||
}) : null
|
||||
}) : null
|
||||
}
|
||||
</List>
|
||||
</Page>
|
||||
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
const PageDocumentSettings = props => {
|
||||
const { t } = useTranslation();
|
||||
|
@ -241,4 +237,4 @@ export {
|
|||
DocumentFormats,
|
||||
DocumentMargins,
|
||||
DocumentColorSchemes
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue