view

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildURL

func BuildURL(target ViewID, params map[string]interface{}) url.URL

Types

type BaseView

type BaseView struct {
	// contains filtered or unexported fields
}

func (*BaseView) Actions

func (base *BaseView) Actions() []ViewAction

func (*BaseView) Finished

func (base *BaseView) Finished() bool

func (*BaseView) ID

func (base *BaseView) ID() ViewID

func (*BaseView) Layout

func (base *BaseView) Layout(gtx C, th *theme.Theme) D

func (*BaseView) Location

func (base *BaseView) Location() url.URL

func (*BaseView) OnFinish

func (base *BaseView) OnFinish()

func (*BaseView) OnNavTo

func (base *BaseView) OnNavTo(intent Intent) error

func (*BaseView) Title

func (base *BaseView) Title() string

type C

type C = layout.Context

type D

type D = layout.Dimensions

type EmptyView

type EmptyView struct {
}

func (EmptyView) Actions

func (v EmptyView) Actions() []ViewAction

func (EmptyView) ID

func (v EmptyView) ID() ViewID

func (EmptyView) Layout

func (v EmptyView) Layout(gtx layout.Context, th *theme.Theme) layout.Dimensions

func (EmptyView) Location

func (v EmptyView) Location() url.URL

func (EmptyView) OnNavTo

func (v EmptyView) OnNavTo(intent Intent) error

func (EmptyView) Title

func (v EmptyView) Title() string

type Intent

type Intent struct {
	Target      ViewID
	Params      map[string]interface{}
	Referer     url.URL
	ShowAsModal bool
	// indicates the provider to create a new view instance and show up
	// in a new tab
	RequireNew bool
}

func (Intent) Location

func (i Intent) Location() url.URL

type ModalView

type ModalView struct {
	View
	// padding between the modal border and inner widget. If it is not set
	// A default value will be used.
	Padding layout.Inset
	// The background color of the modal area.
	Background color.NRGBA
	// Maximum width of the modal area.
	MaxWidth unit.Dp
	// Maximum height of the modal in ratio relateive to the window.
	// The max value is restricted to 0.9 to prevent it overflow.
	MaxHeight float32
	Radius    unit.Dp
	// contains filtered or unexported fields
}

func (*ModalView) IsClosed

func (m *ModalView) IsClosed(gtx layout.Context) bool

func (*ModalView) Layout

func (m *ModalView) Layout(gtx layout.Context, th *theme.Theme) layout.Dimensions

func (*ModalView) ShowUp

func (m *ModalView) ShowUp(gtx layout.Context)

type SimpleView

type SimpleView struct {
	BaseView
	// contains filtered or unexported fields
}

A helper view which implements the View interface.

func (*SimpleView) ID

func (sv *SimpleView) ID() ViewID

func (*SimpleView) Layout

func (sv *SimpleView) Layout(gtx C, th *theme.Theme) D

func (*SimpleView) Location

func (sv *SimpleView) Location() url.URL

func (*SimpleView) OnNavTo

func (sv *SimpleView) OnNavTo(intent Intent) error

func (*SimpleView) Title

func (sv *SimpleView) Title() string

type View

type View interface {
	Actions() []ViewAction
	Layout(gtx layout.Context, th *theme.Theme) layout.Dimensions
	OnNavTo(intent Intent) error
	ID() ViewID
	Location() url.URL
	Title() string
	// set the view to finished state and do some cleanup ops.
	OnFinish()
	Finished() bool
}

func Simple

func Simple(id ViewID, title string, w Widget, intentHandler func(intent Intent) error) View

type ViewAction

type ViewAction struct {
	Name      string
	Icon      *widget.Icon
	OnClicked func(gtx C)
}

type ViewID

type ViewID struct {
	// contains filtered or unexported fields
}

func NewViewID added in v0.1.0

func NewViewID(name string) ViewID

func (ViewID) Name added in v0.1.0

func (id ViewID) Name() string

func (ViewID) Path added in v0.1.0

func (id ViewID) Path() url.URL

func (ViewID) String added in v0.1.0

func (id ViewID) String() string

type ViewManager

type ViewManager interface {
	// Register is used to register views before the view rendering happens.
	// Use provider to enable us to use dynamically constructed views.
	Register(ID ViewID, provider ViewProvider) error

	// Try to swith the current view to the requested view. If referer of the intent equals to
	// the current viewID of the current tab, the requested view should be routed and pushed to
	// to the existing viewstack(current tab). Otherwise a new viewstack for the intent is created(a new tab)
	// if there's no duplicate active view (first views of the stacks).
	RequestSwitch(intent Intent) error

	// OpenedViews return the views on top of the stack of each tab.
	OpenedViews() []View
	// Close the current tab and move backwards to the previous one if there's any.
	CloseTab(idx int)
	SwitchTab(idx int)
	// CurrentView returns the top most view of the current tab.
	CurrentView() View
	// current tab index
	CurrentViewIndex() int
	// Navigate back to the last view if there's any and pop out the current view.
	// It returns the view that is to be rendered.
	NavBack() View
	// Check is there are any naviBack-able views in the current stack or not. This should not
	// count for the current view.
	HasPrev() bool
	// return the next view that is intened to be shown in the modal layer. It returns nil if
	// there's no shownAsModal intent request.
	NextModalView() *ModalView
	// finish the last modal view handling.
	FinishModalView()
	// refresh the window
	Invalidate()

	//Reset resets internal states of the VM
	Reset()
}

View manager is the core of gio-view. It can be used to:

  1. manages views and modals;
  2. dispatch view/modal requests via the Intent object.
  3. views navigation.

Views can have a bounded history stack depending its intent request. The history stack is bounded to a tab widget which is part of a tab bar. Most the the API of the view manager handles navigating between views.

func DefaultViewManager

func DefaultViewManager(window *app.Window) ViewManager

type ViewProvider

type ViewProvider func() View

ViewProvider is used to construct new View instance. Each view should provide its own provider. Usually this is the constructor of the view.

type ViewStack

type ViewStack struct {
	// contains filtered or unexported fields
}

ViewStack is for view navigation history

func NewViewStack

func NewViewStack() *ViewStack

func (*ViewStack) Clear

func (vs *ViewStack) Clear()

func (*ViewStack) Depth

func (vs *ViewStack) Depth() int

func (*ViewStack) IsEmpty

func (vs *ViewStack) IsEmpty() bool

func (*ViewStack) Peek

func (vs *ViewStack) Peek() View

func (*ViewStack) Pop

func (vs *ViewStack) Pop() View

func (*ViewStack) Push

func (vs *ViewStack) Push(vw View) error

push a new view to the stack and removes duplicates instance of the same view.

type Widget

type Widget func(gtx layout.Context, th *theme.Theme) layout.Dimensions

Jump to

Keyboard shortcuts

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