navigation

package
v0.1.49 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NavHost(
	navController *NavController,
	startDestination string,
	builder func(*NavGraphBuilder),
) api.Composable

Types

type BackStackEntry

type BackStackEntry struct {
	Route     string
	ID        string
	Arguments maybe.Maybe[NavArguments]
}

func NewBackStackEntry added in v0.1.45

func NewBackStackEntry(route string, opts ...BackStackEntryOption) BackStackEntry

NewBackStackEntry creates a new BackStackEntry with the given route

type BackStackEntryOption added in v0.1.45

type BackStackEntryOption func(*BackStackEntry)

BackStackEntryOption configures a BackStackEntry

func WithArguments added in v0.1.45

func WithArguments(args NavArguments) BackStackEntryOption

WithArguments sets the arguments for a BackStackEntry

type ComposableWithArgs added in v0.1.45

type ComposableWithArgs func(entry *BackStackEntry) api.Composable

ComposableWithArgs is a function that receives the back stack entry (with arguments)

type NavArgumentSpec struct {
	Type                  NavType
	IsNullable            bool
	DefaultValue          maybe.Maybe[any]
	IsDefaultValuePresent bool
}

NavArgumentSpec defines the schema for a navigation argument (like Kotlin's NavArgument) This is the metadata/definition, not the runtime value

func NewNavArgumentSpec added in v0.1.45

func NewNavArgumentSpec(navType NavType, opts ...NavArgumentSpecOption) NavArgumentSpec

NewNavArgumentSpec creates a new argument spec with the given type and options

type NavArgumentSpecOption func(*NavArgumentSpec)

NavArgumentSpecOption configures a NavArgumentSpec

func WithDefaultValue added in v0.1.45

func WithDefaultValue(value any) NavArgumentSpecOption

WithDefaultValue sets the default value for the argument

func WithNullable added in v0.1.45

func WithNullable(nullable bool) NavArgumentSpecOption

WithNullable sets whether the argument is nullable

type NavArguments map[string]any

NavArguments holds the runtime argument values (like Kotlin's SavedState)

func (a NavArguments) GetBool(key string) (bool, bool)

GetBool retrieves a boolean argument

func (a NavArguments) GetInt(key string) (int, bool)

GetInt retrieves an integer argument

func (a NavArguments) GetString(key string) (string, bool)

GetString retrieves a string argument

type NavController struct {
	// contains filtered or unexported fields
}

func NewNavController

func NewNavController(backStack state.TypedMutableValue[[]BackStackEntry]) *NavController

func RememberNavController

func RememberNavController(c api.Composer) *NavController
func (nc *NavController) CurrentEntry() *BackStackEntry
func (nc *NavController) Navigate(route string)

Navigate to a route. Arguments are extracted in NavHost via pattern matching.

func (nc *NavController) PopBackStack() bool
type NavGraphBuilder struct {
	// contains filtered or unexported fields
}

func NewNavGraphBuilder

func NewNavGraphBuilder() *NavGraphBuilder
func (b *NavGraphBuilder) Argument(route, name string, spec NavArgumentSpec)

Argument registers an argument spec for a route pattern Example: b.Argument("details/{itemId}", "itemId", NewNavArgumentSpec(NavTypeString))

func (b *NavGraphBuilder) Composable(route string, content api.Composable)

Composable adds a destination without arguments (backward compatible)

func (b *NavGraphBuilder) ComposableWithArgs(route string, content ComposableWithArgs)

ComposableWithArgs adds a destination that receives the back stack entry

type NavType int

NavType represents the type of a navigation argument

const (
	NavTypeString NavType = iota
	NavTypeInt
	NavTypeBool
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL