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 ¶
- func New(t theme.Theme) screen.Screen
- type Screen
- func (s *Screen) Help() []key.Binding
- func (s *Screen) Init() tea.Cmd
- func (s *Screen) IsCapturingKeys() bool
- func (s *Screen) Layout() layout.Node
- func (s *Screen) OnEnter(result any) tea.Cmd
- func (s *Screen) SetTheme(t theme.Theme)
- func (s *Screen) Title() string
- func (s *Screen) Update(msg tea.Msg) (screen.Screen, tea.Cmd)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Screen ¶
type Screen struct {
// contains filtered or unexported fields
}