[mobile] fix bug 58068
This commit is contained in:
parent
7e9ccd694a
commit
8099221efb
|
@ -12,7 +12,9 @@ class ThemesController {
|
||||||
id: 'theme-light',
|
id: 'theme-light',
|
||||||
type: 'light'
|
type: 'light'
|
||||||
}};
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
const obj = LocalStorage.getItem("ui-theme");
|
const obj = LocalStorage.getItem("ui-theme");
|
||||||
let theme = this.themes_map.light;
|
let theme = this.themes_map.light;
|
||||||
if ( !!obj )
|
if ( !!obj )
|
||||||
|
@ -23,10 +25,7 @@ class ThemesController {
|
||||||
LocalStorage.setItem("ui-theme", JSON.stringify(theme));
|
LocalStorage.setItem("ui-theme", JSON.stringify(theme));
|
||||||
}
|
}
|
||||||
|
|
||||||
const $$ = Dom7;
|
this.switchDarkTheme(theme, true);
|
||||||
const $body = $$('body');
|
|
||||||
$body.attr('class') && $body.attr('class', $body.attr('class').replace(/\s?theme-type-(?:dark|light)/, ''));
|
|
||||||
$body.addClass(`theme-type-${theme.type}`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get isCurrentDark() {
|
get isCurrentDark() {
|
||||||
|
@ -35,12 +34,23 @@ class ThemesController {
|
||||||
}
|
}
|
||||||
|
|
||||||
switchDarkTheme(dark) {
|
switchDarkTheme(dark) {
|
||||||
const theme = this.themes_map[dark ? 'dark' : 'light'];
|
const theme = typeof dark == 'object' ? dark : this.themes_map[dark ? 'dark' : 'light'];
|
||||||
LocalStorage.setItem("ui-theme", JSON.stringify(theme));
|
const refresh_only = !!arguments[1];
|
||||||
|
|
||||||
|
if ( !refresh_only )
|
||||||
|
LocalStorage.setItem("ui-theme", JSON.stringify(theme));
|
||||||
|
|
||||||
const $body = $$('body');
|
const $body = $$('body');
|
||||||
$body.attr('class') && $body.attr('class', $body.attr('class').replace(/\s?theme-type-(?:dark|light)/, ''));
|
$body.attr('class') && $body.attr('class', $body.attr('class').replace(/\s?theme-type-(?:dark|light)/, ''));
|
||||||
$body.addClass(`theme-type-${theme.type}`);
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import routes from '../router/routes';
|
||||||
import Notifications from '../../../../common/mobile/utils/notifications.js'
|
import Notifications from '../../../../common/mobile/utils/notifications.js'
|
||||||
import {MainController} from '../controller/Main';
|
import {MainController} from '../controller/Main';
|
||||||
import {Device} from '../../../../common/mobile/utils/device'
|
import {Device} from '../../../../common/mobile/utils/device'
|
||||||
|
import {Themes} from '../../../../common/mobile/lib/controller/Themes'
|
||||||
|
|
||||||
const f7params = {
|
const f7params = {
|
||||||
name: 'Desktop Editor', // App name
|
name: 'Desktop Editor', // App name
|
||||||
|
@ -26,6 +27,7 @@ export default class extends React.Component {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
Common.Notifications = new Notifications();
|
Common.Notifications = new Notifications();
|
||||||
|
Themes.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import routes from '../router/routes.js';
|
||||||
import Notifications from '../../../../common/mobile/utils/notifications.js'
|
import Notifications from '../../../../common/mobile/utils/notifications.js'
|
||||||
import {MainController} from '../controller/Main';
|
import {MainController} from '../controller/Main';
|
||||||
import {Device} from '../../../../common/mobile/utils/device'
|
import {Device} from '../../../../common/mobile/utils/device'
|
||||||
|
import {Themes} from '../../../../common/mobile/lib/controller/Themes'
|
||||||
|
|
||||||
// Framework7 Parameters
|
// Framework7 Parameters
|
||||||
const f7params = {
|
const f7params = {
|
||||||
|
@ -27,6 +28,7 @@ export default class extends React.Component {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
Common.Notifications = new Notifications();
|
Common.Notifications = new Notifications();
|
||||||
|
Themes.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -17,6 +17,7 @@ import Notifications from '../../../../common/mobile/utils/notifications.js';
|
||||||
import {MainController} from '../controller/Main';
|
import {MainController} from '../controller/Main';
|
||||||
import {Device} from '../../../../common/mobile/utils/device';
|
import {Device} from '../../../../common/mobile/utils/device';
|
||||||
import CellEditor from '../controller/CellEditor';
|
import CellEditor from '../controller/CellEditor';
|
||||||
|
import {Themes} from '../../../../common/mobile/lib/controller/Themes'
|
||||||
|
|
||||||
const f7params = {
|
const f7params = {
|
||||||
name: 'Spreadsheet Editor', // App name
|
name: 'Spreadsheet Editor', // App name
|
||||||
|
@ -31,6 +32,7 @@ export default class extends React.Component {
|
||||||
|
|
||||||
Common.Notifications = new Notifications();
|
Common.Notifications = new Notifications();
|
||||||
Common.localStorage = LocalStorage;
|
Common.localStorage = LocalStorage;
|
||||||
|
Themes.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
Loading…
Reference in a new issue