Skip to content

Commit

Permalink
Fixed: [LVGL] Style preview for Screen doesn't show colors #642
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Nov 19, 2024
1 parent 16bb20c commit 7c2177f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/project-editor/features/style/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ function getThemedColorInProject(
}

export function getThemedColor(projectStore: ProjectStore, colorValue: string) {
if (colorValue.startsWith("#")) {
if (typeof colorValue != "string" || colorValue.startsWith("#")) {
return { colorValue, isFromTheme: false };
}

Expand Down
24 changes: 6 additions & 18 deletions packages/project-editor/lvgl/page-runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ export abstract class LVGLPageRuntime {
}

getThemedColor(colorValue: string) {
if (colorValue.startsWith("#")) {
if (typeof colorValue != "string" || colorValue.startsWith("#")) {
return { colorValue, isFromTheme: false };
}

Expand Down Expand Up @@ -1313,6 +1313,8 @@ export class LVGLStylesEditorRuntime extends LVGLPageRuntime {
10
);

this.lvglWidgetsMap.set(lvglScreenWidget.type, lvglScreenWidget);

for (const component of lvglScreenWidget.children) {
this.lvglWidgetsMap.set(component.type, component);
}
Expand Down Expand Up @@ -1418,27 +1420,13 @@ export class LVGLStylesEditorRuntime extends LVGLPageRuntime {
lvglWidget._useStyleForStylePreview = "";
lvglWidget.states = "";

flags.push("HIDDEN");
if (lvglWidget != this.page.lvglScreenWidget) {
flags.push("HIDDEN");
}
}

lvglWidget.widgetFlags = flags.join("|");
}

const lvglScreenWidget = this.page.lvglScreenWidget!;
if (
this.selectedStyle &&
this.canvas &&
lvglScreenWidget.type ==
this.selectedStyle.forWidgetType
) {
lvglScreenWidget._useStyleForStylePreview =
this.selectedStyle.name;
lvglScreenWidget.states =
this.project._store.uiStateStore.lvglState;
} else {
lvglScreenWidget._useStyleForStylePreview = "";
lvglScreenWidget.states = "";
}
});

const pageObj = this.lvglCreatePage();
Expand Down

0 comments on commit 7c2177f

Please sign in to comment.