[mobile] fix bug 58068

This commit is contained in:
Maxim Kadushkin 2022-07-13 17:15:18 +03:00
parent 7e9ccd694a
commit 8099221efb
4 changed files with 22 additions and 6 deletions

View file

@ -12,7 +12,9 @@ class ThemesController {
id: 'theme-light',
type: 'light'
}};
}
init() {
const obj = LocalStorage.getItem("ui-theme");
let theme = this.themes_map.light;
if ( !!obj )
@ -23,10 +25,7 @@ class ThemesController {
LocalStorage.setItem("ui-theme", JSON.stringify(theme));
}
const $$ = Dom7;
const $body = $$('body');
$body.attr('class') && $body.attr('class', $body.attr('class').replace(/\s?theme-type-(?:dark|light)/, ''));
$body.addClass(`theme-type-${theme.type}`);
this.switchDarkTheme(theme, true);
}
get isCurrentDark() {
@ -35,12 +34,23 @@ class ThemesController {
}
switchDarkTheme(dark) {
const theme = this.themes_map[dark ? 'dark' : 'light'];
LocalStorage.setItem("ui-theme", JSON.stringify(theme));
const theme = typeof dark == 'object' ? dark : this.themes_map[dark ? 'dark' : 'light'];
const refresh_only = !!arguments[1];
if ( !refresh_only )
LocalStorage.setItem("ui-theme", JSON.stringify(theme));
const $body = $$('body');
$body.attr('class') && $body.attr('class', $body.attr('class').replace(/\s?theme-type-(?:dark|light)/, ''));
$body.addClass(`theme-type-${theme.type}`);
const on_engine_created = api => {
api.asc_setSkin(theme.id);
};
const api = Common.EditorApi ? Common.EditorApi.get() : undefined;
if(!api) Common.Notifications.on('engineCreated', on_engine_created);
else on_engine_created(api);
}
}

View file

@ -13,6 +13,7 @@ import routes from '../router/routes';
import Notifications from '../../../../common/mobile/utils/notifications.js'
import {MainController} from '../controller/Main';
import {Device} from '../../../../common/mobile/utils/device'
import {Themes} from '../../../../common/mobile/lib/controller/Themes'
const f7params = {
name: 'Desktop Editor', // App name
@ -26,6 +27,7 @@ export default class extends React.Component {
super(props);
Common.Notifications = new Notifications();
Themes.init();
}
render() {

View file

@ -13,6 +13,7 @@ import routes from '../router/routes.js';
import Notifications from '../../../../common/mobile/utils/notifications.js'
import {MainController} from '../controller/Main';
import {Device} from '../../../../common/mobile/utils/device'
import {Themes} from '../../../../common/mobile/lib/controller/Themes'
// Framework7 Parameters
const f7params = {
@ -27,6 +28,7 @@ export default class extends React.Component {
super();
Common.Notifications = new Notifications();
Themes.init();
}
render() {

View file

@ -17,6 +17,7 @@ import Notifications from '../../../../common/mobile/utils/notifications.js';
import {MainController} from '../controller/Main';
import {Device} from '../../../../common/mobile/utils/device';
import CellEditor from '../controller/CellEditor';
import {Themes} from '../../../../common/mobile/lib/controller/Themes'
const f7params = {
name: 'Spreadsheet Editor', // App name
@ -31,6 +32,7 @@ export default class extends React.Component {
Common.Notifications = new Notifications();
Common.localStorage = LocalStorage;
Themes.init();
}
render() {