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