From c986a294e4b8d68c0dad8adf03ea18bdef183f1b Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Thu, 31 Oct 2024 15:27:45 +0800 Subject: [PATCH] chore: Add `view` method to get the child view from `Root`. (#385) --- crates/ui/src/root.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/ui/src/root.rs b/crates/ui/src/root.rs index 3360f679..06786825 100644 --- a/crates/ui/src/root.rs +++ b/crates/ui/src/root.rs @@ -208,7 +208,7 @@ pub struct Root { active_drawer: Option, active_modals: Vec, pub notification: View, - child: AnyView, + view: AnyView, } #[derive(Clone)] @@ -224,13 +224,13 @@ struct ActiveModal { } impl Root { - pub fn new(child: AnyView, cx: &mut ViewContext) -> Self { + pub fn new(view: AnyView, cx: &mut ViewContext) -> Self { Self { previous_focus_handle: None, active_drawer: None, active_modals: Vec::new(), notification: cx.new_view(NotificationList::new), - child, + view, } } @@ -332,6 +332,11 @@ impl Root { })), ) } + + /// Return the root view of the Root. + pub fn view(&self) -> &AnyView { + &self.view + } } impl Render for Root { @@ -340,6 +345,6 @@ impl Render for Root { .id("root") .size_full() .text_color(cx.theme().foreground) - .child(self.child.clone()) + .child(self.view.clone()) } }