presenter

package
v0.14.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package presenter implements the Presenter System. CRC: crc-Presenter.md, crc-AppPresenter.md, crc-ListPresenter.md Spec: main.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppPresenter

type AppPresenter struct {
	*Presenter
	URL          string          `json:"url"`
	HistoryIndex int             `json:"historyIndex"`
	History      []PageReference `json:"history"`
}

AppPresenter is the root presenter for a session.

func NewAppPresenter

func NewAppPresenter() *AppPresenter

NewAppPresenter creates a new app presenter.

func (*AppPresenter) Back

func (ap *AppPresenter) Back() bool

Back navigates to the previous page.

func (*AppPresenter) CurrentPage

func (ap *AppPresenter) CurrentPage() *PageReference

CurrentPage returns the current page from history.

func (*AppPresenter) Forward

func (ap *AppPresenter) Forward() bool

Forward navigates to the next page.

func (*AppPresenter) Go

func (ap *AppPresenter) Go(index int) bool

Go navigates to a specific history index.

func (*AppPresenter) Navigate

func (ap *AppPresenter) Navigate(url string, variableID int64)

Navigate pushes a new page to history.

func (*AppPresenter) ReplaceCurrentPage

func (ap *AppPresenter) ReplaceCurrentPage(url string, variableID int64)

ReplaceCurrentPage replaces the current page without adding to history.

func (*AppPresenter) ToData

func (ap *AppPresenter) ToData() (json.RawMessage, error)

ToData serializes the app presenter state.

type ListPresenter

type ListPresenter struct {
	*Presenter
	Items      []int64 `json:"items"` // Variable IDs of list items
	SelectedID int64   `json:"selectedId,omitempty"`
}

ListPresenter manages a list of items.

func NewListPresenter

func NewListPresenter() *ListPresenter

NewListPresenter creates a new list presenter.

func (*ListPresenter) AddItem

func (lp *ListPresenter) AddItem(variableID int64)

AddItem adds an item to the list.

func (*ListPresenter) GetItems

func (lp *ListPresenter) GetItems() []int64

GetItems returns all item IDs.

func (*ListPresenter) GetSelected

func (lp *ListPresenter) GetSelected() int64

GetSelected returns the selected item ID.

func (*ListPresenter) RemoveItem

func (lp *ListPresenter) RemoveItem(variableID int64) bool

RemoveItem removes an item from the list.

func (*ListPresenter) SelectItem

func (lp *ListPresenter) SelectItem(variableID int64)

SelectItem selects an item.

func (*ListPresenter) ToData

func (lp *ListPresenter) ToData() (json.RawMessage, error)

ToData serializes the list presenter state.

type PageReference

type PageReference struct {
	VariableID int64  `json:"variableId"`
	URL        string `json:"url"`
}

PageReference refers to a page presenter.

type Presenter

type Presenter struct {
	Type       string          `json:"type"`
	Data       json.RawMessage `json:"data,omitempty"`
	ViewName   string          `json:"view,omitempty"`
	VariableID int64           `json:"-"`
}

Presenter represents a UI presenter.

func NewPresenter

func NewPresenter(presenterType string) *Presenter

NewPresenter creates a new presenter.

func (*Presenter) GetData

func (p *Presenter) GetData() json.RawMessage

GetData returns the presenter state.

func (*Presenter) GetType

func (p *Presenter) GetType() string

GetType returns the presenter type.

func (*Presenter) GetViewName

func (p *Presenter) GetViewName() string

GetViewName returns the active view name.

func (*Presenter) SetData

func (p *Presenter) SetData(data json.RawMessage)

SetData updates the presenter state.

func (*Presenter) SetViewName

func (p *Presenter) SetViewName(name string)

SetViewName switches to a different view.

Jump to

Keyboard shortcuts

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