prescreen

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package prescreen demonstrates pushing a screen *in front of* another one on first activation, and taking a result back when it pops — the shape behind "log in before you can use this", "pick a workspace first", or "re-authenticate, that token expired".

The login form here is set dressing. What the example is actually about is the flow: a root screen that pushes a child from OnEnter, receives the child's result when it pops, and can re-push the same child later without the child ever living permanently on the stack. See pkg/form and the "Form" example for the component itself.

The form lives as a regular screen.Screen — it's only on the stack while the user is interacting with it, and is gone afterward. The trigger lives in the root screen's OnEnter: it fires on initial push (with nil), on every return-from-child, and is the natural hook for "if I'm not authenticated yet, push the login screen now."

State machine, driven from the root screen's OnEnter:

  • First entry, no creds: push the login form.
  • Login pops with creds: record them and rebuild the body.
  • Login pops with nil (cancelled before authenticating): bubble the pop up so the user returns to whatever screen pushed this one.

The same Push call can be re-issued at any point — e.g. on a "logout" keystroke or when a request returns 401 — to bring the form back without permanent stack residency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(t theme.Theme) screen.Screen

New returns the prescreen demo's root screen.

Types

type Screen

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

func (*Screen) Help

func (s *Screen) Help() []key.Binding

func (*Screen) Init

func (s *Screen) Init() tea.Cmd

func (*Screen) IsCapturingKeys

func (s *Screen) IsCapturingKeys() bool

func (*Screen) Layout

func (s *Screen) Layout() layout.Node

func (*Screen) OnEnter

func (s *Screen) OnEnter(result any) tea.Cmd

OnEnter runs each time the root screen becomes the active top of the stack. On the initial push from the launcher, result is nil — we kick the login flow off here. After the login screen pops, this fires again with either credentials (success) or nil (cancelled).

func (*Screen) SetTheme

func (s *Screen) SetTheme(t theme.Theme)

func (*Screen) Title

func (s *Screen) Title() string

func (*Screen) Update

func (s *Screen) Update(msg tea.Msg) (screen.Screen, tea.Cmd)

Jump to

Keyboard shortcuts

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