Skip to content

NavigatorState

Namespace: Hex1b.Widgets

Assembly: Hex1b.dll

State object for Navigator that manages the navigation stack. Use this to push new screens, pop back, or reset to root.

csharp
[Experimental("HEX1B001")]
public class NavigatorState

Inheritance

ObjectNavigatorState

Constructors

Creates a new NavigatorState with the specified root route.

Parameters:

  • rootRoute (NavigatorRoute): The initial/home route that can be returned to via PopToRoot.
csharp
public NavigatorState(NavigatorRoute rootRoute)

Properties

CanGoBack

Returns true if there are routes to pop (more than just the root).

Returns: Boolean

csharp
public bool CanGoBack { get; }

CurrentRoute

Gets the current route at the top of the navigation stack.

Returns: NavigatorRoute

csharp
public NavigatorRoute CurrentRoute { get; }

Depth

Gets the number of routes in the navigation stack.

Returns: Int32

csharp
public int Depth { get; }

Methods

Pop()

Pops the current route and returns to the previous screen. Does nothing if already at the root.

Returns: Boolean

True if a route was popped, false if already at root.

csharp
public bool Pop()

PopToRoot()

Pops all routes and returns to the root route. Useful for completing a wizard flow.

csharp
public void PopToRoot()

Push(NavigatorRoute)

Pushes a new route onto the navigation stack (drill down).

Parameters:

csharp
public void Push(NavigatorRoute route)

Push(string, Func<NavigatorState, Hex1bWidget>)

Pushes a new route using a simple builder function.

Parameters:

csharp
public void Push(string id, Func<NavigatorState, Hex1bWidget> builder)

Replace(NavigatorRoute)

Replaces the current route with a new one (useful for redirects).

Parameters:

csharp
public void Replace(NavigatorRoute route)

Replace(string, Func<NavigatorState, Hex1bWidget>)

Replaces the current route using a simple builder function.

Parameters:

csharp
public void Replace(string id, Func<NavigatorState, Hex1bWidget> builder)

Reset(NavigatorRoute)

Resets the navigator to a new root route, clearing all history.

Parameters:

csharp
public void Reset(NavigatorRoute newRoot)

Events

OnNavigated

Event raised when navigation occurs.

Returns: Action

csharp
public event Action? OnNavigated

Released under the MIT License.