View plugins for literals

This commit is contained in:
2026-02-01 17:46:40 +01:00
parent 44a4837647
commit 76984187a0
3 changed files with 50 additions and 13 deletions
+11 -2
View File
@@ -10,7 +10,7 @@ use crate::{engine::CommandExecutor, View, ViewWrapper};
use super::{context::Context, ComponentImpl};
/// A scope groups child components and manages their rendering
///
///
/// Scopes form the hierarchical structure of a component tree.
/// Each scope contains references to its child components and their
/// optional view wrappers (for layout/styling).
@@ -31,7 +31,7 @@ impl Scope {
}
/// Adds a child component to this scope
///
///
/// The view_wrapper is optional and can be used for layout or styling.
pub fn child<F: ComponentImpl + 'static>(
self: &Arc<Self>,
@@ -53,4 +53,13 @@ impl Scope {
self.children.lock().unwrap().push((ctx, None));
}
/// Adds a view directly to this scope
pub fn view_wrapped(self: &Arc<Self>, view: View, view_wrapper: ViewWrapper) {
let ctx = Context::new(view, self.executor.clone());
ctx.refresh();
self.children.lock().unwrap().push((ctx, Some(view_wrapper)));
}
}