Skip to content

Commit 7c2177f

Browse files
committed
Fixed: [LVGL] Style preview for Screen doesn't show colors #642
1 parent 16bb20c commit 7c2177f

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

packages/project-editor/features/style/theme.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ function getThemedColorInProject(
684684
}
685685

686686
export function getThemedColor(projectStore: ProjectStore, colorValue: string) {
687-
if (colorValue.startsWith("#")) {
687+
if (typeof colorValue != "string" || colorValue.startsWith("#")) {
688688
return { colorValue, isFromTheme: false };
689689
}
690690

packages/project-editor/lvgl/page-runtime.ts

+6-18
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export abstract class LVGLPageRuntime {
442442
}
443443

444444
getThemedColor(colorValue: string) {
445-
if (colorValue.startsWith("#")) {
445+
if (typeof colorValue != "string" || colorValue.startsWith("#")) {
446446
return { colorValue, isFromTheme: false };
447447
}
448448

@@ -1313,6 +1313,8 @@ export class LVGLStylesEditorRuntime extends LVGLPageRuntime {
13131313
10
13141314
);
13151315

1316+
this.lvglWidgetsMap.set(lvglScreenWidget.type, lvglScreenWidget);
1317+
13161318
for (const component of lvglScreenWidget.children) {
13171319
this.lvglWidgetsMap.set(component.type, component);
13181320
}
@@ -1418,27 +1420,13 @@ export class LVGLStylesEditorRuntime extends LVGLPageRuntime {
14181420
lvglWidget._useStyleForStylePreview = "";
14191421
lvglWidget.states = "";
14201422

1421-
flags.push("HIDDEN");
1423+
if (lvglWidget != this.page.lvglScreenWidget) {
1424+
flags.push("HIDDEN");
1425+
}
14221426
}
14231427

14241428
lvglWidget.widgetFlags = flags.join("|");
14251429
}
1426-
1427-
const lvglScreenWidget = this.page.lvglScreenWidget!;
1428-
if (
1429-
this.selectedStyle &&
1430-
this.canvas &&
1431-
lvglScreenWidget.type ==
1432-
this.selectedStyle.forWidgetType
1433-
) {
1434-
lvglScreenWidget._useStyleForStylePreview =
1435-
this.selectedStyle.name;
1436-
lvglScreenWidget.states =
1437-
this.project._store.uiStateStore.lvglState;
1438-
} else {
1439-
lvglScreenWidget._useStyleForStylePreview = "";
1440-
lvglScreenWidget.states = "";
1441-
}
14421430
});
14431431

14441432
const pageObj = this.lvglCreatePage();

0 commit comments

Comments
 (0)