gate

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package gate demonstrates a one-shot pre-screen flow: a "gated" root screen that pushes a login form on first activation, receives the credentials when the form pops, and re-pushes the form on logout.

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 gate'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 gate'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 the gate.

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 gate demo's entry 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 gate 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