Add ThemeChanged variant to Event in iced_sentinel

This commit is contained in:
Héctor Ramón Jiménez 2024-02-27 15:19:26 +01:00
parent 7f7c5ea337
commit c856d2b513
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
13 changed files with 69 additions and 4 deletions

View file

@ -11,10 +11,11 @@ categories.workspace = true
keywords.workspace = true
[features]
enable = ["iced_sentinel", "once_cell"]
enable = ["dep:iced_sentinel", "dep:once_cell"]
[dependencies]
iced_core.workspace = true
iced_style.workspace = true
iced_sentinel.workspace = true
iced_sentinel.optional = true

View file

@ -1,4 +1,7 @@
pub use iced_core as core;
pub use iced_style as style;
use crate::style::theme;
pub use internal::Timer;
@ -6,6 +9,10 @@ pub fn open_axe() {}
pub fn log_message(_message: &impl std::fmt::Debug) {}
pub fn theme_changed(palette: theme::Palette) {
internal::theme_changed(palette);
}
pub fn boot_time() -> Timer {
internal::boot_time()
}
@ -41,6 +48,7 @@ pub fn time(name: impl AsRef<str>) -> Timer {
#[cfg(feature = "enable")]
mod internal {
use crate::core::time::Instant;
use crate::style::theme;
use iced_sentinel::client::{self, Client};
use iced_sentinel::timing::{self, Timing};
@ -48,6 +56,10 @@ mod internal {
use once_cell::sync::Lazy;
use std::sync::{Mutex, MutexGuard};
pub fn theme_changed(palette: theme::Palette) {
lock().sentinel.report_theme_change(palette);
}
pub fn boot_time() -> Timer {
timer(timing::Stage::Boot)
}
@ -120,6 +132,10 @@ mod internal {
#[cfg(not(feature = "enable"))]
mod internal {
use crate::style::theme;
pub fn theme_changed(_palette: theme::Palette) {}
pub fn boot_time() -> Timer {
Timer
}