How to find if the dark mode is on or off for the default theme

Description

How can I find if the dark mode for default theme is on or off?

What MCU/Processor/Board and compiler are you using?

esp32

What LVGL version are you using?

8.0.2

What do you want to achieve?

I want to find whether the default theme’s dark mode is on or off in runtime.

What have you tried so far?

Code to reproduce

Screenshot and/or video

There is no API to do it it. For v8.0 you can use:

lv_theme_t * theme = lv_disp_get_theme(lv_disp_get_default());
bool is_dark = theme->flags & 1; /* MODE_DARK in lv_theme_default.c */

However, this will break if the flag moves in a future version.

@kisvegabor Should we move MODE_DARK into lv_theme_default.h so that this approach is more stable?

Yes, I agree. E.g. as LV_THEME_DEFAULT_FLAG_DARK