✨ Añade soporte a temas en la API de extensiones
- Incluye una opción de configuración para definir el tema por defecto. - Añade un tema básico predeterminado.
This commit is contained in:
parent
f4e142a242
commit
86e4c4f110
13 changed files with 148 additions and 5 deletions
30
src/core/theme/definition.rs
Normal file
30
src/core/theme/definition.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
use crate::core::extension::ExtensionTrait;
|
||||
|
||||
/// Representa una referencia a un tema.
|
||||
///
|
||||
/// Los temas son también extensiones. Por tanto se deben definir igual, es decir, como instancias
|
||||
/// estáticas globales que implementan [`ThemeTrait`], pero también [`ExtensionTrait`].
|
||||
pub type ThemeRef = &'static dyn ThemeTrait;
|
||||
|
||||
/// Interfaz común que debe implementar cualquier tema de `PageTop`.
|
||||
///
|
||||
/// Un tema implementará [`ThemeTrait`] y los métodos que sean necesarios de [`ExtensionTrait`],
|
||||
/// aunque el único obligatorio es [`theme()`](crate::core::extension::ExtensionTrait#method.theme).
|
||||
///
|
||||
/// ```rust
|
||||
/// use pagetop::prelude::*;
|
||||
///
|
||||
/// pub struct MyTheme;
|
||||
///
|
||||
/// impl ExtensionTrait for MyTheme {
|
||||
/// fn name(&self) -> L10n { L10n::n("My theme") }
|
||||
/// fn description(&self) -> L10n { L10n::n("Un tema personal") }
|
||||
///
|
||||
/// fn theme(&self) -> Option<ThemeRef> {
|
||||
/// Some(&Self)
|
||||
/// }
|
||||
/// }
|
||||
///
|
||||
/// impl ThemeTrait for MyTheme {}
|
||||
/// ```
|
||||
pub trait ThemeTrait: ExtensionTrait + Send + Sync {}
|
Loading…
Add table
Add a link
Reference in a new issue