Scope view

This commit is contained in:
2026-01-25 02:27:36 +01:00
parent 470512a542
commit 6b3e9239c9
2 changed files with 11 additions and 6 deletions
+2 -5
View File
@@ -84,12 +84,9 @@ fn app(cx: &Arc<Context>) -> View {
scope.children.lock().unwrap().clear();
for i in 0..count.get_dl() {
scope.child(
my_component,
Some(Arc::new(move |ctx, _| {
scope.view(Arc::new(move |ctx| {
ctx.draw_text(Point { x: 0, y: i }, &format!("{i}"));
})),
);
}));
}
}
},
+8
View File
@@ -190,4 +190,12 @@ impl Scope {
self.children.lock().unwrap().push((ctx, view_wrapper));
}
pub fn view(self: &Arc<Self>, view: View) {
let ctx = Context::new(move |_| view.clone());
ctx.refresh();
self.children.lock().unwrap().push((ctx, None));
}
}