pub struct Navigator;Expand description
Navigation API for convenient route navigation
Provides static methods for navigation operations:
Navigator::push(cx, "/path")- Navigate to a new pageNavigator::pop(cx)- Go back to previous pageNavigator::replace(cx, "/path")- Replace current page
Works with any context that has access to App (Context<V>, App, etc.)
§Example
ⓘ
use gpui_navigator::Navigator;
// Navigate to a new route
Navigator::push(cx, "/users/123");
// Go back
Navigator::pop(cx);
// Replace current route
Navigator::replace(cx, "/login");Implementations§
Sourcepub fn of<C: BorrowAppContext>(cx: &mut C) -> NavigatorHandle<'_, C>
pub fn of<C: BorrowAppContext>(cx: &mut C) -> NavigatorHandle<'_, C>
Get a NavigatorHandle for the given context
This allows chained navigation calls:
ⓘ
use gpui_navigator::Navigator;
// Chained style
Navigator::of(cx).push("/users");
Navigator::of(cx).pop();
// Or direct style (also works)
Navigator::push(cx, "/users");
Navigator::pop(cx);Sourcepub fn push(cx: &mut impl BorrowAppContext, route: impl IntoRoute)
pub fn push(cx: &mut impl BorrowAppContext, route: impl IntoRoute)
Sourcepub fn replace(cx: &mut impl BorrowAppContext, route: impl IntoRoute)
pub fn replace(cx: &mut impl BorrowAppContext, route: impl IntoRoute)
Replace current path without adding to history
§Example
ⓘ
use gpui_navigator::{Navigator, PageRoute};
// Simple string path
Navigator::replace(cx, "/login");
// With PageRoute
Navigator::replace(cx, PageRoute::builder("/login", |_, _cx, _params| gpui::div())
.with_param("redirect".into(), "/dashboard".into()));Sourcepub fn pop(cx: &mut impl BorrowAppContext)
pub fn pop(cx: &mut impl BorrowAppContext)
Sourcepub fn back(cx: &mut impl BorrowAppContext)
pub fn back(cx: &mut impl BorrowAppContext)
Alias for pop() - go back (kept for compatibility)
Sourcepub fn forward(cx: &mut impl BorrowAppContext)
pub fn forward(cx: &mut impl BorrowAppContext)
Go forward in history
Sourcepub fn current_path(cx: &App) -> String
pub fn current_path(cx: &App) -> String
Sourcepub fn can_go_back(cx: &App) -> bool
pub fn can_go_back(cx: &App) -> bool
Alias for can_pop() - check if can go back (kept for compatibility)
Sourcepub fn push_named(
cx: &mut impl BorrowAppContext,
name: &str,
params: &RouteParams,
)
pub fn push_named( cx: &mut impl BorrowAppContext, name: &str, params: &RouteParams, )
Sourcepub fn can_go_forward(cx: &App) -> bool
pub fn can_go_forward(cx: &App) -> bool
Check if can go forward
Sourcepub fn set_next_transition(
cx: &mut impl BorrowAppContext,
transition: Transition,
)
Available on crate feature transition only.
pub fn set_next_transition( cx: &mut impl BorrowAppContext, transition: Transition, )
transition only.Sourcepub fn push_with_transition(
cx: &mut impl BorrowAppContext,
route: impl IntoRoute,
transition: Transition,
)
Available on crate feature transition only.
pub fn push_with_transition( cx: &mut impl BorrowAppContext, route: impl IntoRoute, transition: Transition, )
transition only.Sourcepub fn replace_with_transition(
cx: &mut impl BorrowAppContext,
route: impl IntoRoute,
transition: Transition,
)
Available on crate feature transition only.
pub fn replace_with_transition( cx: &mut impl BorrowAppContext, route: impl IntoRoute, transition: Transition, )
transition only.Sourcepub fn push_named_with_transition(
cx: &mut impl BorrowAppContext,
name: &str,
params: &RouteParams,
transition: Transition,
)
Available on crate feature transition only.
pub fn push_named_with_transition( cx: &mut impl BorrowAppContext, name: &str, params: &RouteParams, transition: Transition, )
transition only.Auto Trait Implementations§
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more