Write documentation for new ThemeFn traits

This commit is contained in:
Héctor Ramón Jiménez 2025-09-08 12:05:39 +02:00
parent b5974a23cc
commit 323b17d458
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 24 additions and 4 deletions

View file

@ -530,9 +530,19 @@ where
}
}
/// TODO
/// The theme logic of some [`Application`].
///
/// Any implementors of this trait can be provided as an argument to
/// [`Application::theme`].
///
/// `iced` provides two implementors:
/// - the built-in [`Theme`] itself
/// - and any `Fn(&State) -> impl Into<Option<Theme>>`.
pub trait ThemeFn<State, Theme> {
/// TODO
/// Returns the theme of the [`Application`] for the current state.
///
/// If `None` is returned, `iced` will try to use a theme that
/// matches the system color scheme.
fn theme(&self, state: &State) -> Option<Theme>;
}

View file

@ -317,9 +317,19 @@ where
}
}
/// TODO
/// The theme logic of some [`Daemon`].
///
/// Any implementors of this trait can be provided as an argument to
/// [`Daemon::theme`].
///
/// `iced` provides two implementors:
/// - the built-in [`Theme`] itself
/// - and any `Fn(&State, window::Id) -> impl Into<Option<Theme>>`.
pub trait ThemeFn<State, Theme> {
/// TODO
/// Returns the theme of the [`Daemon`] for the current state and window.
///
/// If `None` is returned, `iced` will try to use a theme that
/// matches the system color scheme.
fn theme(&self, state: &State, window: window::Id) -> Option<Theme>;
}