Expand description
§gpui-nav
A lightweight screen navigation library for GPUI applications.
§Quick Start
use gpui::*;
use gpui_nav::{Navigator, Screen, ScreenContext};
// Define your app state
pub struct AppState {
navigator: Navigator,
}
// Define a screen
pub struct HomeScreen {
ctx: ScreenContext<AppState>,
}
impl Screen for HomeScreen {
fn id(&self) -> &'static str {
"home"
}
}
impl Render for HomeScreen {
fn render(&mut self, _window: &mut Window, _cx: &mut Context<Self>) -> impl IntoElement {
div().child("Home Screen")
}
}§Navigation Operations
§Push a new screen
ⓘ
let settings_screen = SettingsScreen::new(ctx.weak_entity());
app.navigator.push(settings_screen, cx);§Pop the current screen
ⓘ
app.navigator.pop(cx);§Replace the current screen
ⓘ
let login_screen = LoginScreen::new(ctx.weak_entity());
app.navigator.replace(login_screen, cx);§Clear stack and push new screen
ⓘ
let home_screen = HomeScreen::new(ctx.weak_entity());
app.navigator.clear_and_push(home_screen, cx);§Examples
See the basic navigation example for a complete working demonstration.
Re-exports§
pub use context::ScreenContext;
Modules§
Structs§
- Navigator
- A navigation stack that manages screen transitions.
Traits§
- Screen
- A screen that can be displayed in the navigation stack.