ui

package module
v0.0.0-...-9b3d5df Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 15 Imported by: 0

README

README

This README would normally document whatever steps are necessary to get your application up and running.

What is this repository for?
How do I get set up?
  • Summary of set up
  • Configuration
  • Dependencies
  • Database configuration
  • How to run tests
  • Deployment instructions
Contribution guidelines
  • Writing tests
  • Code review
  • Other guidelines
Who do I talk to?
  • Repo owner or admin
  • Other community or team contact

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogWindowError

func LogWindowError(
	view View, evt WindowEventName,
	err error,
)

func LogWindowEvent

func LogWindowEvent(view View, evt WindowEventName)

func LogWindowEventMessage

func LogWindowEventMessage(
	view View,
	evt WindowEventName,
	msg string,
	args ...any,
)

func RegisterDialog

func RegisterDialog(name DialogName, kind DialogKind, fn NewDialogFn)

Types

type BaseDialog

type BaseDialog struct {
	CanvasObj fyne.CanvasObject
	Data      binding.DataItem

	ViewModel DialogViewModel
	*ScreenHandler
	// contains filtered or unexported fields
}

func NewBaseDialog

func NewBaseDialog(
	concreteDialog Dialog,
	name DialogName,
	kind DialogKind,
	viewModel DialogViewModel,
	parent fyne.Window,
	confirm OnConfirmFn,
) *BaseDialog

func NewBaseDialogWithData

func NewBaseDialogWithData(
	concreteDialog Dialog,
	name DialogName,
	kind DialogKind,
	viewModel DialogViewModel,
	parent fyne.Window,
	confirm OnConfirmFn,
	data binding.DataItem,
) *BaseDialog

func NewBaseDialogWithDataAndScreen

func NewBaseDialogWithDataAndScreen(
	concreteDialog Dialog,
	name DialogName,
	kind DialogKind,
	viewModel DialogViewModel,
	parent fyne.Window,
	confirm OnConfirmFn,
	data binding.DataItem,
	filesystem embed.FS,
	screenName string,
	localizer *i18n.Localizer,
) *BaseDialog

func NewBaseDialogWithScreen

func NewBaseDialogWithScreen(
	concreteDialog Dialog,
	name DialogName,
	kind DialogKind,
	viewModel DialogViewModel,
	parent fyne.Window,
	confirm OnConfirmFn,
	filesystem embed.FS,
	screenName string,
	localizer *i18n.Localizer,
) *BaseDialog

func (BaseDialog) DialogKind

func (d BaseDialog) DialogKind() DialogKind

func (BaseDialog) DialogName

func (d BaseDialog) DialogName() DialogName

func (BaseDialog) Equals

func (d BaseDialog) Equals(other View) bool

func (BaseDialog) ID

func (d BaseDialog) ID() string

func (*BaseDialog) Initialize

func (d *BaseDialog) Initialize() fyne.CanvasObject

func (*BaseDialog) OnClose

func (d *BaseDialog) OnClose(confirmed bool)

func (BaseDialog) OnConfirmFn

func (d BaseDialog) OnConfirmFn() OnConfirmFn

func (*BaseDialog) OnHide

func (d *BaseDialog) OnHide()

func (*BaseDialog) OnShow

func (d *BaseDialog) OnShow()

func (*BaseDialog) Refresh

func (d *BaseDialog) Refresh()

func (*BaseDialog) SetID

func (d *BaseDialog) SetID(id string)

func (*BaseDialog) SetInitialFocusItem

func (d *BaseDialog) SetInitialFocusItem(focusItem fyne.Focusable)

func (*BaseDialog) Show

func (d *BaseDialog) Show(parent ...fyne.Window)

func (BaseDialog) Title

func (d BaseDialog) Title() string

func (*BaseDialog) View

func (d *BaseDialog) View() View

func (BaseDialog) Window

func (d BaseDialog) Window() fyne.Window

type BaseView

type BaseView struct {

	// The controller
	ViewModel ViewModel

	// Root CanvasObject of the view
	CanvasObject fyne.CanvasObject

	// ----------- ScreenHandler -------------//
	*ScreenHandler
	// contains filtered or unexported fields
}

BaseView represents the base implementation of a view You can create new view types by composing a type around BaseView

func NewBaseView

func NewBaseView(
	concreteView View,
	viewModel ViewModel,
) *BaseView

NewBaseView creates a new baseview Any wrapper view should call this function in it's own initialization function an pass itself.

example:

func NewWrapperView(...) *WrapperView {
	v := new(WrapperView)
	v.BaseView = NewBaseView(v)
	..
	return v
}

func NewBaseViewWithScreen

func NewBaseViewWithScreen(
	concreteView View,
	viewModel ViewModel,
	filesystem embed.FS,
	screenName string,
	localizer *i18n.Localizer,
) *BaseView

func (BaseView) Equals

func (v BaseView) Equals(other View) bool

Equals checks equality of two views by comparing their id

func (*BaseView) GetBinding

func (v *BaseView) GetBinding(bindingName string) binding.DataItem

func (BaseView) ID

func (v BaseView) ID() string

ID returns tie id of the view

func (*BaseView) Initialize

func (v *BaseView) Initialize() fyne.CanvasObject

Initialize initializes the view

func (*BaseView) OnHide

func (v *BaseView) OnHide()

func (*BaseView) OnShow

func (v *BaseView) OnShow()

OnShow is called when the view becomes visible on the screen

func (*BaseView) Refresh

func (v *BaseView) Refresh()

Refresh is called when the view needs a full update

func (*BaseView) SetID

func (v *BaseView) SetID(id string)

SetID allows the user to specify the ID of the view

func (BaseView) Title

func (v BaseView) Title() string

Title returns the title of the view

type BaseViewModel

type BaseViewModel interface {
	GetBinding(string) binding.DataItem
	GetValidator(string) fyne.StringValidator
}

type Dialog

type Dialog interface {
	View

	Window() fyne.Window
	View() View

	SetInitialFocusItem(focusItem fyne.Focusable)

	Show(parent ...fyne.Window)
	OnClose(bool)

	DialogName() DialogName
	DialogKind() DialogKind
	OnConfirmFn() OnConfirmFn
}

func NewDialog

func NewDialog(
	name DialogName,
	kind DialogKind,
	parent fyne.Window,
	confirm OnConfirmFn,
) Dialog

func NewDialogWithData

func NewDialogWithData(
	name DialogName,
	kind DialogKind,
	parent fyne.Window,
	confirm OnConfirmFn,
	data binding.DataItem,
) Dialog

func NewDialogWithDataAndScreen

func NewDialogWithDataAndScreen(
	name DialogName,
	kind DialogKind,
	parent fyne.Window,
	confirm OnConfirmFn,
	data binding.DataItem,
	filesystem embed.FS,
	screenName string,
	localizer *i18n.Localizer,
) Dialog

func NewDialogWithScreen

func NewDialogWithScreen(
	name DialogName,
	kind DialogKind,
	parent fyne.Window,
	confirm OnConfirmFn,
	filesystem embed.FS,
	screenName string,
	localizer *i18n.Localizer,
) Dialog

type DialogKind

type DialogKind string
const (
	DlgGeneric DialogKind = "Generic"
)

type DialogName

type DialogName string

type DialogViewModel

type DialogViewModel interface {
	BaseViewModel

	Initialize(data binding.DataItem) error
	RefreshData() error
}

type FormDialog

type FormDialog struct {
	*BaseDialog
	// contains filtered or unexported fields
}

func NewFormDialog

func NewFormDialog(
	concreteDialog Dialog,
	name DialogName,
	kind DialogKind,
	viewModel DialogViewModel,
	parent fyne.Window,
	confirm OnConfirmFn,
	itemsFn FormDialogItemsFn,
) *FormDialog

func NewFormDialogWithDataAndScreen

func NewFormDialogWithDataAndScreen(
	concreteDialog Dialog,
	name DialogName,
	kind DialogKind,
	viewModel DialogViewModel,
	parent fyne.Window,
	confirm OnConfirmFn,
	data binding.DataItem,
	filesystem embed.FS,
	screenName string,
	localizer *i18n.Localizer,
) *FormDialog

func NewFormDialogWithScreen

func NewFormDialogWithScreen(
	concreteDialog Dialog,
	name DialogName,
	kind DialogKind,
	viewModel DialogViewModel,
	parent fyne.Window,
	confirm OnConfirmFn,
	filesystem embed.FS,
	screenName string,
	localizer *i18n.Localizer,
) *FormDialog

func NewformDialogWithData

func NewformDialogWithData(
	concreteDialog Dialog,
	name DialogName,
	kind DialogKind,
	viewModel DialogViewModel,
	parent fyne.Window,
	confirm OnConfirmFn,
	itemsFn FormDialogItemsFn,
	data binding.DataItem,
) *FormDialog

func (*FormDialog) Initialize

func (d *FormDialog) Initialize() fyne.CanvasObject

func (*FormDialog) Refresh

func (d *FormDialog) Refresh()

func (*FormDialog) SetButtonLabels

func (d *FormDialog) SetButtonLabels(
	confirm string,
	dismiss string,
)

func (*FormDialog) Show

func (d *FormDialog) Show(parent ...fyne.Window)

type FormDialogItemsFn

type FormDialogItemsFn func() []*widget.FormItem

type NewDialogFn

type NewDialogFn func(
	DialogName,
	DialogKind,
	fyne.Window,
	OnConfirmFn,
	binding.DataItem,
	*embed.FS,
	string,
	*i18n.Localizer) Dialog

type OnConfirmFn

type OnConfirmFn func(bool, error, ...interface{})

type ScreenHandler

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

ScreenHandler represents the handler for a screen.

It provides:

  • The screen definition
  • The localizer
  • The screen controller
  • Exported elements
  • List item templates and renderers
  • User interaction handlers

func NewScreenHandler

func NewScreenHandler(
	filesystem embed.FS,
	screenName string,
	viewModel BaseViewModel,
	localizer *i18n.Localizer,
) (h *ScreenHandler, err error)

NewScreenHandler initializes a new ScreenHandler with the provided filesystem, screen name, ScreenController, and localizer.

Arguments:

  • filesystem: the embedded filesystem to access screen resources.
  • screenName: the name of the screen to load.
  • ctrl: the ScreenController for the screen.
  • localizer: the i18n.Localizer for localization.

Returns:

  • h: the initialized ScreenHandler.
  • err: an error if loading the screen fails.

func (*ScreenHandler) GetBinding

func (h *ScreenHandler) GetBinding(name string) binding.DataItem

GetBinding returns the binding with the given name.

This function forwards the call to the controller. In the controller the required bindings should be mapped to the screen elements.

func (*ScreenHandler) GetElement

func (h *ScreenHandler) GetElement(id string) *screen.UIElement

GetElement returns the UIElement with the given ID.

This function allows you to retrieve the exported elements (given an ID in the screen definition). The UIElement contains the object and the decorator. Should no decorator be present, both point to the same widget. If a decorator is present it's advices to do hide and show operations on the decorator, and all other operators on the object.

func (*ScreenHandler) GetIcon

func (h *ScreenHandler) GetIcon(iconName string) fyne.Resource

GetIcon returns the icon with the given name.

This handler only implements the default theme icons. If you wish to support other items, wrap this ScreenHandler and implement the loading of the icons yourself.

func (*ScreenHandler) GetListDataItemRenderer

func (h *ScreenHandler) GetListDataItemRenderer(name string) screen.ListDataItemRendererFn

GetListDataItemRenderer returns the ListDataItemRenderer with the given name.

func (*ScreenHandler) GetListItemRenderer

func (h *ScreenHandler) GetListItemRenderer(name string) screen.ListItemRendererFn

GetListItemRenderer returns the ListItemRenderer with the given name.

func (*ScreenHandler) GetListItemTemplate

func (h *ScreenHandler) GetListItemTemplate(name string) screen.ListItemTemplateFn

GetListItemTemplate returns the ListItemTemplate with the given name.

func (*ScreenHandler) GetListLength

func (h *ScreenHandler) GetListLength(name string) screen.ListLengthFn

GetListLength returns the ListLength with the given name.

func (*ScreenHandler) GetLocalizer

func (h *ScreenHandler) GetLocalizer() *i18n.Localizer

GetLocalizer returns the i18n.Localizer used for localization.

func (*ScreenHandler) GetOnCheckChangedHandler

func (h *ScreenHandler) GetOnCheckChangedHandler(name string) screen.CheckHandlerFn

GetOnCheckChangedHandler returns the OnCheckChangedHandler with the given name.

func (*ScreenHandler) GetOnClickedHandler

func (h *ScreenHandler) GetOnClickedHandler(name string) screen.ClickHandlerFn

GetOnClickedHandler returns the OnClickedHandler with the given name.

func (*ScreenHandler) GetOnDateSelectedHandler

func (h *ScreenHandler) GetOnDateSelectedHandler(name string) screen.DateSelectedHandlerFn

GetOnDateSelectedHandler returns the OnDateSelectedHandler with the given name.

func (*ScreenHandler) GetOnListItemSelectedHandler

func (h *ScreenHandler) GetOnListItemSelectedHandler(name string) screen.ListItemHandlerFn

GetOnListItemSelectedHandler returns the OnListItemSelectedHandler with the given name.

func (*ScreenHandler) GetOnListItemUnselectedHandler

func (h *ScreenHandler) GetOnListItemUnselectedHandler(name string) screen.ListItemHandlerFn

GetOnListItemUnselectedHandler returns the OnListItemUnselectedHandler with the given name.

func (*ScreenHandler) GetOnValidationChangedHandler

func (h *ScreenHandler) GetOnValidationChangedHandler(name string) screen.ValidationChangedHandlerFn

GetOnValidationChangedHandler returns the OnValidationChangedHandler with the given name.

func (*ScreenHandler) GetValidator

func (h *ScreenHandler) GetValidator(name string) fyne.StringValidator

GetValidator returns the validator with the given name.

This function forwards the call to the controller. In the controller the required validators should be mapped to the screen elements.

func (*ScreenHandler) RegisterElement

func (h *ScreenHandler) RegisterElement(
	id string,
	elem fyne.CanvasObject,
	decorator fyne.CanvasObject,
)

RegisterElement registers an element with the ScreenHandler.

This function is called for every element in the screen definition fow which an ID is defined.

func (*ScreenHandler) RegisterListDataItemRenderer

func (h *ScreenHandler) RegisterListDataItemRenderer(
	name string,
	fn screen.ListDataItemRendererFn,
)

RegisterListDataItemRenderer registers a ListDataItemRenderer with the ScreenHandler.

Use this function to register the renderers for the lists used in the screen definition.

func (*ScreenHandler) RegisterListItemRenderer

func (h *ScreenHandler) RegisterListItemRenderer(
	name string,
	fn screen.ListItemRendererFn,
)

RegisterListItemRenderer registers a ListItemRenderer with the ScreenHandler.

Use this function to register the renderers for the lists used in the screen definition.

func (*ScreenHandler) RegisterListItemTemplate

func (h *ScreenHandler) RegisterListItemTemplate(
	name string,
	fn screen.ListItemTemplateFn,
)

RegisterListItemTemplate registers a ListItemTemplate with the ScreenHandler.

Use this function to register the templates for the lists used in the screen definition.

func (*ScreenHandler) RegisterListLength

func (h *ScreenHandler) RegisterListLength(
	name string,
	fn screen.ListLengthFn,
)

RegisterListLength registers a ListLength with the ScreenHandler.

Use this function to register the lengths for the lists used in the screen definition.

func (*ScreenHandler) RegisterOnCheckChangedHandler

func (h *ScreenHandler) RegisterOnCheckChangedHandler(
	name string,
	fn screen.CheckHandlerFn,
)

RegisterOnCheckChangedHandler registers a OnCheckChangedHandler with the ScreenHandler.

Use this function to register the handler functions used in the screen definition.

func (*ScreenHandler) RegisterOnClickHandler

func (h *ScreenHandler) RegisterOnClickHandler(
	name string,
	fn screen.ClickHandlerFn,
)

RegisterOnClickHandler registers a OnClickHandler with the ScreenHandler.

Use this function to register the handler functions used in the screen definition.

func (*ScreenHandler) RegisterOnDateSelectedHandler

func (h *ScreenHandler) RegisterOnDateSelectedHandler(
	name string,
	fn screen.DateSelectedHandlerFn,
)

RegisterOnDateSelectedHandler registers a OnDateSelectedHandler with the ScreenHandler.

Use this function to register the handler functions used in the screen definition.

func (*ScreenHandler) RegisterOnListItemSelectedHandler

func (h *ScreenHandler) RegisterOnListItemSelectedHandler(
	name string,
	fn screen.ListItemHandlerFn,
)

RegisterOnListItemSelectedHandler registers a OnListItemSelectedHandler with the ScreenHandler.

Use this function to register the handler functions used in the screen definition.

func (*ScreenHandler) RegisterOnListItemUnselectedHandler

func (h *ScreenHandler) RegisterOnListItemUnselectedHandler(
	name string,
	fn screen.ListItemHandlerFn,
)

RegisterOnListItemUnselectedHandler registers a OnListItemUnselectedHandler with the ScreenHandler.

Use this function to register the handler functions used in the screen definition.

func (*ScreenHandler) RegisterOnValidationChangedHandler

func (h *ScreenHandler) RegisterOnValidationChangedHandler(
	name string,
	fn screen.ValidationChangedHandlerFn,
)

RegisterOnValidationChangedHandler registers a OnValidationChangedHandler with the ScreenHandler.

Use this function to register the handler functions used in the screen definition.

func (*ScreenHandler) ScreenDefinition

func (h *ScreenHandler) ScreenDefinition() *screen.Screen

ScreenDefinition returns the screen definition for the ScreenHandler.

type Shortcut

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

Shortcut represents a shortcut composed of a modifier + key combination Implements: fyne.Shortcut

func NewShortcut

func NewShortcut(
	name string,
	key fyne.KeyName,
	modifier ...fyne.KeyModifier,
) *Shortcut

Create a new shortcut

func (*Shortcut) Key

func (s *Shortcut) Key() fyne.KeyName

Key returns the shortcut key

func (*Shortcut) Mod

func (s *Shortcut) Mod() fyne.KeyModifier

Mod returns the shortcut modifier combination

func (*Shortcut) ShortcutName

func (s *Shortcut) ShortcutName() string

ShortcutName returs the modifier shortcut combination

type TabbedView

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

func NewTabbedView

func NewTabbedView(
	controller ViewModel,
	tabLocation container.TabLocation,
	tabview ...View,
) *TabbedView

NewTabbedView creates a new tabbed view

func (*TabbedView) Append

func (v *TabbedView) Append(tabview ...View)

func (*TabbedView) Initialize

func (v *TabbedView) Initialize() fyne.CanvasObject

func (*TabbedView) NumTabs

func (v *TabbedView) NumTabs() int

func (*TabbedView) OnHide

func (v *TabbedView) OnHide()

func (*TabbedView) OnShow

func (v *TabbedView) OnShow()

func (*TabbedView) Refresh

func (v *TabbedView) Refresh()

func (*TabbedView) Remove

func (v *TabbedView) Remove(idx int)

func (*TabbedView) RemoveActive

func (v *TabbedView) RemoveActive()

func (*TabbedView) SelectTab

func (v *TabbedView) SelectTab(view View)

func (*TabbedView) SelectTabIndex

func (v *TabbedView) SelectTabIndex(index int)

func (*TabbedView) TabIndex

func (v *TabbedView) TabIndex(view View) int

type View

type View interface {
	// ID of the view
	// Each view implementation should create a unique ID automatically
	ID() string

	// SetID allows the user to specify the ID of the view
	SetID(string)

	// Checs equality of two views by comparing their id.
	Equals(View) bool

	// Title returns the title of the view
	// The title is displayed in the main bar for root views, or in the tabs of
	// views that are childeren of a tabview
	Title() string

	// Initializes the view
	// An implementation should completely configure the view including the UI,
	// controller state etc.
	Initialize() fyne.CanvasObject

	// Refresh is called when the view needs a full update
	// The implementation should decide what to refresh on the view and wether
	// it nees to refresh the controller or not
	Refresh()

	// OnShow is called when the view becomes visible on the screen
	OnShow()

	// OnHide is called when the view is removed from the screen
	OnHide()
}

View interface represents a generic gui view. This can be:

  • A full main view
  • A subview of another view
  • A dialog

type ViewModel

type ViewModel interface {
	BaseViewModel

	Initialize() error
	RefreshData() error
}

type WindowEventName

type WindowEventName string

WindowEventName defines common names for event occurring in the gui system

const (
	LoadScreen      WindowEventName = "LoadScreen"
	Initialize      WindowEventName = "Initialize"
	Refresh         WindowEventName = "Refresh"
	OnShow          WindowEventName = "OnShow"
	OnHide          WindowEventName = "OnHide"
	OnClose         WindowEventName = "OnClose"
	OnTabSelected   WindowEventName = "OnTabSelected"
	OnTabUnselected WindowEventName = "OnTabUnselected"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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