Documentation
¶
Overview ¶
Package Navstack manages a stack of NavigationItems which can be pushed or popped from the stack. The top most stack navigation item is used by [BubbleTea] to Update and renders it's View. When pushing and popping items from the stack, the new view to be presented is sent a tea.WindowSizeMsg to ensure it's view can be presented correctly. When the last item is popped from the stack the application will quit. NavigationItem models which implement the Closable interface will have their Close method called when they are popped from the stack. This is useful for cleaning up resources that may not be garbage collected when a view a no longer needed. [BubbleTea]: https://github.com/charmbracelet/bubbletea
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PopNavigationCmd ¶ added in v0.1.2
func PushNavigationCmd ¶ added in v0.1.2
func PushNavigationCmd(item NavigationItem) tea.Cmd
Types ¶
type Closable ¶
type Closable interface {
Close() error
}
Closable is an interface for models that have resources that need to be cleaned up when they are no longer needed. The navigation stack checks for this interface when popping items.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new navigation stack model. The window is used to constrain the view within the container of the navigation stack.
func (*Model) Pop ¶
Pop removes the top most navigation item from the stack. If the item implements the Closable interface the Close method is called. The new top most item on the stack is given a tea.WindowSizeMsg to ensure it's view can be presented correctly. If there are no more items on the stack the application will quit.
func (*Model) Push ¶
func (m *Model) Push(item NavigationItem) tea.Cmd
Push pushes a new navigation item onto the stack. The new navigation item is given a tea.WindowSizeMsg to ensure it's view can be presented correctly. The item's Init method is called and resulting command is processed by [BubbleTea]. If top item's model implements the Closable interface the Close method is called. This new item will be the top most item on the stack and thus will be rendered.
func (Model) StackSummary ¶
StackSummary returns a list of titles for each item on the stack. This is currently used by the breadcrumb component to render the breadcrumb trail.
func (Model) Top ¶
func (m Model) Top() *NavigationItem
Top returns the top most navigation item on the stack.
type NavigationItem ¶
type NavigationItem struct {}
NavigationItem is a component that represents an item in the navigation stack. The top most item on the stack is rendered.
func (NavigationItem) Init ¶
func (n NavigationItem) Init() tea.Cmd
Init is called when the item is pushed onto the stack.
func (NavigationItem) View ¶
func (n NavigationItem) View() string
View is calledn when the item is on top of the stack.
type PopNavigation ¶
type PopNavigation struct{}
PopNavigation is a message that can be sent to the menu model to de-select the currently selected menu choice
type PushNavigation ¶
type PushNavigation struct {
}type ReloadCurrent ¶
type ReloadCurrent struct{}
ReloadCurrent is a message that can be sent to the menu model to reload the currently selected menu choice