The generated code sequence is incorrect, resulting in UI effects that do not match expectations

I created a switch and set the background color of the indicator in the checked state to theme color 1, and set the switch state to checked.
However, the color displayed on the device is still the default color. After checking the generated UI code, I found that the code sequence is to first set the button status to checked and then set the color corresponding to the checked status, which led to the problem. The display effect achieved the expected result after manual adjustment.
Generated problematic code:
ui_enableMotorSwitch = lv_switch_create(ui_Screen1);
lv_obj_set_width(ui_enableMotorSwitch, 50);
lv_obj_set_height(ui_enableMotorSwitch, 25);
lv_obj_set_x(ui_enableMotorSwitch, 92);
lv_obj_set_y(ui_enableMotorSwitch, -96);
lv_obj_set_align(ui_enableMotorSwitch, LV_ALIGN_CENTER);
lv_obj_add_state(ui_enableMotorSwitch, LV_STATE_CHECKED); /// States

ui_object_set_themeable_style_property(ui_enableMotorSwitch, LV_PART_INDICATOR | LV_STATE_CHECKED, LV_STYLE_BG_COLOR,
                                       _ui_theme_color_color1);
ui_object_set_themeable_style_property(ui_enableMotorSwitch, LV_PART_INDICATOR | LV_STATE_CHECKED, LV_STYLE_BG_OPA,
                                       _ui_theme_alpha_color1);

Manually modified correct code:
ui_enableMotorSwitch = lv_switch_create(ui_Screen1);
lv_obj_set_width(ui_enableMotorSwitch, 50);
lv_obj_set_height(ui_enableMotorSwitch, 25);
lv_obj_set_x(ui_enableMotorSwitch, 92);
lv_obj_set_y(ui_enableMotorSwitch, -96);
lv_obj_set_align(ui_enableMotorSwitch, LV_ALIGN_CENTER);

ui_object_set_themeable_style_property(ui_enableMotorSwitch, LV_PART_INDICATOR | LV_STATE_CHECKED, LV_STYLE_BG_COLOR,
                                       _ui_theme_color_color1);
ui_object_set_themeable_style_property(ui_enableMotorSwitch, LV_PART_INDICATOR | LV_STATE_CHECKED, LV_STYLE_BG_OPA,
                                       _ui_theme_alpha_color1);
lv_obj_add_state(ui_enableMotorSwitch, LV_STATE_CHECKED);       /// States

SquareLineStudio v1.5.1
LVGL v9.1.0
based on Arduino TFT_eSPI

Hi, thanks for reporting this issue, kirl. Your fix is correct - setting the style properties before changing the state is the right approach. We’ll look into whether this is an LVGL issue or something we can fix in our code generation. For now, your workaround is the way to go.