[PE mobile] Fixed slide size settings into presentation settings

This commit is contained in:
JuliaSvinareva 2020-12-17 22:52:25 +03:00
parent 44532dc8bd
commit 55f0865749
4 changed files with 23 additions and 12 deletions

View file

@ -169,12 +169,7 @@ class MainController extends Component {
const storePresentationSettings = this.props.storePresentationSettings;
me.api.asc_registerCallback('asc_onPresentationSize', (width, height) => {
const slideSizeArr = storePresentationSettings.getSlideSizes;
slideSizeArr.forEach((array, index) => {
if(Math.abs(array[0] - width) < 0.001 && Math.abs((array[1] - height)) < 0.001) {
storePresentationSettings.changeSizeIndex(index);
}
})
storePresentationSettings.changeSizeIndex(width, height);
});
me.api.asc_registerCallback('asc_onSendThemeColorSchemes', (arr) => {

View file

@ -1,9 +1,19 @@
import React, {Component} from 'React';
import { observer, inject } from "mobx-react";
import {PresentationSettings} from '../../view/settings/PresentationSettings';
class PresentationSettingsController extends Component {
constructor(props) {
super(props);
this.initSlideSize = this.initSlideSize.bind(this);
}
initSlideSize() {
if (!this.init) {
const api = Common.EditorApi.get();
this.props.storePresentationSettings.changeSizeIndex(api.get_PresentationWidth(), api.get_PresentationHeight());
this.init = true;
}
}
onSlideSize(slideSizeArr) {
@ -27,6 +37,7 @@ class PresentationSettingsController extends Component {
render() {
return (
<PresentationSettings
initSlideSize={this.initSlideSize}
onSlideSize={this.onSlideSize}
onColorSchemeChange={this.onColorSchemeChange}
initPageColorSchemes={this.initPageColorSchemes}
@ -35,4 +46,4 @@ class PresentationSettingsController extends Component {
}
}
export default PresentationSettingsController;
export default inject("storePresentationSettings")(observer(PresentationSettingsController));

View file

@ -1,15 +1,19 @@
import {action, observable} from 'mobx';
export class storePresentationSettings {
slideSize = [[254, 190.5], [254, 143]];
@observable slideSizeIndex;
get getSlideSizes() {
return [[254, 190.5], [254, 143]];
return this.slideSize;
}
@action changeSizeIndex(value) {
this.slideSizeIndex = +value;
@action changeSizeIndex(width, height) {
this.slideSize.forEach((array, index) => {
if(Math.abs(array[0] - width) < 0.001 && Math.abs((array[1] - height)) < 0.001) {
this.slideSizeIndex = index;
}
})
}
// Color Schemes

View file

@ -6,6 +6,7 @@ import { useTranslation } from "react-i18next";
const PagePresentationSettings = props => {
const { t } = useTranslation();
const _t = t("View.Settings", { returnObjects: true });
props.initSlideSize();
const store = props.storePresentationSettings;
const slideSizeArr = store.getSlideSizes;
const slideSizeIndex = store.slideSizeIndex;