INNER CODE UNIT · Go
func
vladimirvivien/ktop · application/navigation.go:35
func (n *NavigationStack) Push(state PageState) {
n.stack = append(n.stack, state)
}
// Pop removes and returns the top page from the stack
// Returns nil if only the root page (overview) remains
func (n *NavigationStack) Pop() *PageState {
if len(n.stack) <= 1 {
return nil // Can't pop the root page
}
// Remove and return the last item
lastIdx := len(n.stack) - 1
popped := n.stack[lastIdx]
n.stack = n.stack[:lastIdx]
return &popped
}
// Current returns the current (top) page state