pub struct Navigator { /* private fields */ }Expand description
A navigation stack that manages screen transitions.
The navigator is generic over the app state type and can be integrated into any GPUI application.
§Example
use gpui_nav::Navigator;
pub struct AppState {
navigator: Navigator,
// ... other state
}Implementations§
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty navigator.
§Example
use gpui_nav::Navigator;
let navigator = Navigator::new();
assert!(navigator.is_empty());Sourcepub fn push<S: Screen, T: 'static>(
&mut self,
screen: S,
cx: &mut Context<'_, T>,
)
pub fn push<S: Screen, T: 'static>( &mut self, screen: S, cx: &mut Context<'_, T>, )
Pushes a new screen onto the navigation stack.
The screen’s on_enter method will be called if implemented.
This method is generic over the context type, allowing it to work
with any app state.
§Example
ⓘ
// In your app state method:
pub fn navigator_push<S: Screen>(&mut self, screen: S, cx: &mut Context<Self>) {
self.navigator.push(screen, cx);
}Sourcepub fn replace<S: Screen, T: 'static>(
&mut self,
screen: S,
cx: &mut Context<'_, T>,
) -> bool
pub fn replace<S: Screen, T: 'static>( &mut self, screen: S, cx: &mut Context<'_, T>, ) -> bool
Sourcepub fn clear_and_push<S: Screen, T: 'static>(
&mut self,
screen: S,
cx: &mut Context<'_, T>,
)
pub fn clear_and_push<S: Screen, T: 'static>( &mut self, screen: S, cx: &mut Context<'_, T>, )
Clears the entire stack and pushes a new root screen.
Useful for logout flows or resetting the app state.
Sourcepub fn can_go_back(&self) -> bool
pub fn can_go_back(&self) -> bool
Returns whether the navigator can go back.
Trait Implementations§
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().