view

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Overview

Package view provides the component library. See https://gomatcha.io/guide/view/ for more details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alert added in v0.2.0

func Alert(title, message string, buttons ...*AlertButton)

Alert displays an alert with the given title, message and buttons. If no buttons are passed, a default OK button is created.

func CopyFields added in v0.2.0

func CopyFields(dst, src View)

Copy all public fields from src to dst, that aren't 'Embed'.

func EntersStage

func EntersStage(from, to, s Stage) bool

EntersStage returns true if from﹤s and to≥s.

func ExitsStage

func ExitsStage(from, to, s Stage) bool

ExitsStage returns true if from≥s and to﹤s.

Types

type AlertButton added in v0.2.0

type AlertButton struct {
	Title   string
	OnPress func()
}

AlertButton represents an alert button.

type BasicView added in v0.2.0

type BasicView struct {
	Embed
	Painter  paint.Painter
	Layouter layout.Layouter
	Children []View
}

func NewBasicView added in v0.2.0

func NewBasicView() *BasicView

NewBasicView returns a new view.

func (*BasicView) Build added in v0.2.0

func (v *BasicView) Build(ctx Context) Model

Build implements view.View.

type Button added in v0.2.0

type Button struct {
	Embed
	String     string
	Color      color.Color
	OnPress    func()
	Enabled    bool
	PaintStyle *paint.Style
}

Button implements a native button view.

func NewButton added in v0.2.0

func NewButton() *Button

NewButton returns a new view.

func (*Button) Build added in v0.2.0

func (v *Button) Build(ctx Context) Model

Build implements view.View.

type Context

type Context interface {
	Path() []Id
}

type Embed

type Embed struct {
	Key interface{}
	// contains filtered or unexported fields
}

Embed is a convenience struct that provides a default implementation of View. It also wraps a comm.Relay.

func NewEmbed

func NewEmbed(key interface{}) Embed

func (*Embed) Build

func (e *Embed) Build(ctx Context) Model

Build is an empty implementation of View's Build method.

func (*Embed) Lifecycle

func (e *Embed) Lifecycle(from, to Stage)

Lifecycle is an empty implementation of View's Lifecycle method.

func (*Embed) Notify

func (e *Embed) Notify(f func()) comm.Id

Notify calls Notify(id) on the underlying comm.Relay.

func (*Embed) Signal

func (e *Embed) Signal()

Update calls Signal() on the underlying comm.Relay.

func (*Embed) Subscribe

func (e *Embed) Subscribe(n comm.Notifier)

Subscribe calls Subscribe(n) on the underlying comm.Relay.

func (*Embed) Unnotify

func (e *Embed) Unnotify(id comm.Id)

Unnotify calls Unnotify(id) on the underlying comm.Relay.

func (*Embed) Unsubscribe

func (e *Embed) Unsubscribe(n comm.Notifier)

Unsubscribe calls Unsubscribe(n) on the underlying comm.Relay.

func (*Embed) Update added in v0.2.0

func (e *Embed) Update(v View)

Update is an empty implementation of View's Update method.

func (*Embed) ViewKey added in v0.2.0

func (e *Embed) ViewKey() interface{}

type Id added in v0.2.0

type Id int64

type ImageButton added in v0.2.0

type ImageButton struct {
	Embed
	Image      image.Image
	OnPress    func()
	PaintStyle *paint.Style
}

func NewImageButton added in v0.2.0

func NewImageButton() *ImageButton

func (*ImageButton) Build added in v0.2.0

func (v *ImageButton) Build(ctx Context) Model

type ImageResizeMode added in v0.2.0

type ImageResizeMode int
const (
	// The image is resized proportionally such that a single axis is filled.
	ImageResizeModeFit ImageResizeMode = iota
	// The image is resized proportionally such that the entire view is filled.
	ImageResizeModeFill
	// The image is stretched to fill the view.
	ImageResizeModeStretch
	// The image is centered in the view with its natural size.
	ImageResizeModeCenter
)

TODO(KD): ResizeModeFit and ResizeModeFill behave oddly on Android.

func (ImageResizeMode) MarshalProtobuf added in v0.2.0

func (m ImageResizeMode) MarshalProtobuf() pbview.ImageResizeMode

type ImageView added in v0.2.0

type ImageView struct {
	Embed
	Image      image.Image
	ResizeMode ImageResizeMode
	ImageTint  color.Color
	PaintStyle *paint.Style

	URL string
	// contains filtered or unexported fields
}

ImageView implements a view that displays an image.

func NewImageView added in v0.2.0

func NewImageView() *ImageView

NewImageView returns a new view.

func (*ImageView) Build added in v0.2.0

func (v *ImageView) Build(ctx Context) Model

Build implements view.View.

func (*ImageView) Lifecycle added in v0.2.0

func (v *ImageView) Lifecycle(from, to Stage)

Lifecycle implements view.View.

func (*ImageView) Update added in v0.2.0

func (v *ImageView) Update(v2 View)

type Model

type Model struct {
	Children []View
	Layouter layout.Layouter
	Painter  paint.Painter
	Options  []Option

	NativeViewName  string
	NativeViewState []byte
	NativeOptions   map[string][]byte
	NativeFuncs     map[string]interface{}
}

Model describes the view and its children.

type Option

type Option interface {
	OptionKey() string
}

type ScrollPosition added in v0.2.0

type ScrollPosition struct {
	X animate.Value
	Y animate.Value
	// contains filtered or unexported fields
}

func (*ScrollPosition) Notify added in v0.2.0

func (p *ScrollPosition) Notify(f func()) comm.Id

func (*ScrollPosition) SetValue added in v0.2.0

func (p *ScrollPosition) SetValue(val layout.Point)

func (*ScrollPosition) Unnotify added in v0.2.0

func (p *ScrollPosition) Unnotify(id comm.Id)

func (*ScrollPosition) Value added in v0.2.0

func (p *ScrollPosition) Value() layout.Point

type ScrollView added in v0.2.0

type ScrollView struct {
	Embed
	ScrollAxes     layout.Axis
	IndicatorAxes  layout.Axis
	ScrollEnabled  bool
	ScrollPosition *ScrollPosition

	OnScroll func(position layout.Point)

	ContentChildren []View
	ContentPainter  paint.Painter
	ContentLayouter layout.Layouter
	PaintStyle      *paint.Style
	// contains filtered or unexported fields
}

func NewScrollView added in v0.2.0

func NewScrollView() *ScrollView

NewScrollView returns a new view.

func (*ScrollView) Build added in v0.2.0

func (v *ScrollView) Build(ctx Context) Model

Build implements view.View.

type Slider added in v0.2.0

type Slider struct {
	Embed
	PaintStyle    *paint.Style
	Value         float64
	ValueNotifier comm.Float64Notifier

	MaxValue float64
	MinValue float64
	OnChange func(value float64)
	OnSubmit func(value float64)
	Enabled  bool
	// contains filtered or unexported fields
}

func NewSlider added in v0.2.0

func NewSlider() *Slider

New returns a new view.

func (*Slider) Build added in v0.2.0

func (v *Slider) Build(ctx Context) Model

Build implements view.View.

func (*Slider) Lifecycle added in v0.2.0

func (v *Slider) Lifecycle(from, to Stage)

type Stage

type Stage int
const (
	// StageDead marks views that are not attached to the view hierarchy.
	StageDead Stage = iota
	// StageMounted marks views that are in the view hierarchy but not visible.
	StageMounted
	// StageVisible marks views that are in the view hierarchy and visible.
	StageVisible
)

type Switch added in v0.2.0

type Switch struct {
	Embed
	Enabled    bool
	Value      bool
	OnSubmit   func(value bool)
	PaintStyle *paint.Style
}

func NewSwitch added in v0.2.0

func NewSwitch() *Switch

NewSwitch returns a new view.

func (*Switch) Build added in v0.2.0

func (v *Switch) Build(ctx Context) Model

Build implements view.View.

type TextInput added in v0.2.0

type TextInput struct {
	Embed
	PaintStyle *paint.Style
	Text       *text.Text

	Style            *text.Style
	Placeholder      string
	PlaceholderStyle *text.Style
	Password         bool
	KeyboardType     keyboard.Type
	Responder        *keyboard.Responder

	MaxLines int // This is used only for sizing.
	OnChange func(*text.Text)
	OnSubmit func(*text.Text)
	OnFocus  func(*keyboard.Responder)
	// contains filtered or unexported fields
}

TextInput represents a text input view. TextInput mutates the Text and StyledText fields in place.

func NewTextInput added in v0.2.0

func NewTextInput() *TextInput

NewTextInput returns a new view.

func (*TextInput) Build added in v0.2.0

func (v *TextInput) Build(ctx Context) Model

Build implements the view.View interface.

func (*TextInput) Lifecycle added in v0.2.0

func (v *TextInput) Lifecycle(from, to Stage)

Lifecyle implements the view.View interface.

type TextView added in v0.2.0

type TextView struct {
	Embed
	PaintStyle *paint.Style
	String     string
	Text       *text.Text
	Style      *text.Style
	StyledText *text.StyledText // TODO(KD): subscribe to StyledText and Text
	MaxLines   int
}

TextView displays a multiline text region within it bounds.

func NewTextView added in v0.2.0

func NewTextView() *TextView

NewTextView returns a new view.

func (*TextView) Build added in v0.2.0

func (v *TextView) Build(ctx Context) Model

Build implements the view.View interface.

type View

type View interface {
	Build(Context) Model
	Lifecycle(from, to Stage)
	ViewKey() interface{}
	Update(View)
	comm.Notifier
}

func WithOptions

func WithOptions(v View, opts ...Option) View

WithOptions wraps the view v, and adds the given options to its Model.Options.

func WithPainter

func WithPainter(v View, p paint.Painter) View

WithPainter wraps the view v, and replaces its Model.Painter with p.

Directories

Path Synopsis
Package ios implements a native ios views.
Package ios implements a native ios views.

Jump to

Keyboard shortcuts

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