pub trait Screen: Render + 'static {
// Required method
fn id(&self) -> &'static str;
// Provided methods
fn on_enter(&mut self, _cx: &mut Context<'_, Self>)
where Self: Sized { ... }
fn on_exit(&mut self, _cx: &mut Context<'_, Self>)
where Self: Sized { ... }
}Expand description
A screen that can be displayed in the navigation stack.
Screens must implement both Render and this trait to be used with the navigator.
§Example
ⓘ
use gpui::*;
use gpui_nav::Screen;
pub struct MyScreen {
// your fields
}
impl Screen for MyScreen {
fn id(&self) -> &'static str {
"my_screen"
}
}
impl Render for MyScreen {
fn render(&mut self, _: &mut Window, _: &mut Context<Self>) -> impl IntoElement {
div().child("My Screen")
}
}Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.