Theme Change

theme-change feature is used to enable system theme change related types and event builder. It is suitable for when the system switches from light mode to dark mode, updating the application theme or rebuilding related styles.

[dependencies]
flor = { version = "0.1.0", features = ["direct2d", "theme-change"] }

Event Entry

After enabling feature, can use on_theme_changed(...):

use flor::base::platform::ThemeMode;
use flor::view::builder::EventBuilder;
use flor_lys::label::label;

let root = label("Theme")
    .on_theme_changed(|_view_id, mode| {
        match mode {
            ThemeMode::Light => println!("light"),
            ThemeMode::Dark => println!("dark"),
        }
    });

ThemeMode currently has two values:

ValueMeaning
ThemeMode::LightLight mode.
ThemeMode::DarkDark mode.

Complete signature and current dispatch status see Handler API's Theme Change Events. If you only need normal view state styles, don't need to enable this feature; it faces system theme change.