splitview

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package splitview shows a list beside what's open from it when there's room, as on a tablet, and one at a time on a phone: picking from the list pushes the detail onto the screen's Stack. On a foldable that's half open with a vertical fold, the panes meet at the fold. It's plain Go, so it needs no plugin add; add hinge for the fold.

split := splitview.Use(c)
return splitview.View{
	Split:  split,
	List:   ordersList(split.Open), // its rows call split.Open(id)
	Detail: func(id string) ui.Component { return OrderScreen{ID: id} },
	Title:  func(id string) string { return "Order " + id },
	Empty:  ui.Text("Pick an order", ui.Style{}),
	Style:  ui.Style{Grow: 1},
}

Put it inside a ui.Stack, which a phone needs for the detail to push onto.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Split

type Split struct {
	Selected string // the ID open in the detail pane; "" for none
	// contains filtered or unexported fields
}

Split is what's open, and the way to open something.

func Use

func Use(c *ui.Ctx) Split

Use keeps what's open for a View in this component.

func (Split) Open

func (s Split) Open(id string)

Open shows id: in the detail pane side by side, or pushed onto the Stack on a phone.

type View

type View struct {
	Split     Split                        // from Use
	List      ui.Component                 // its rows call Split.Open
	Detail    func(id string) ui.Component // what's open
	Title     func(id string) string       // the pushed detail's title on a phone; nil for none
	Empty     ui.Component                 // the detail pane with nothing open; nil for blank
	ListWidth float32                      // the list's width side by side; 0 means 320
	MinWidth  float32                      // the window width from which they go side by side; 0 means 700
	Style     ui.Style                     // its size and place; usually Grow: 1
}

View is the list and the detail.

func (View) Render

func (v View) Render(c *ui.Ctx) ui.Component

Render lays them out.

Jump to

Keyboard shortcuts

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