Changed naming from controller to viewmodel
This commit is contained in:
parent
c848c2332f
commit
17bec4ede5
24
baseview.go
24
baseview.go
@ -19,7 +19,7 @@ type BaseView struct {
|
|||||||
id string
|
id string
|
||||||
|
|
||||||
// The controller
|
// The controller
|
||||||
Ctrl Controller
|
ViewModel ViewModel
|
||||||
|
|
||||||
// Root CanvasObject of the view
|
// Root CanvasObject of the view
|
||||||
CanvasObject fyne.CanvasObject
|
CanvasObject fyne.CanvasObject
|
||||||
@ -42,29 +42,29 @@ type BaseView struct {
|
|||||||
// }
|
// }
|
||||||
func NewBaseView(
|
func NewBaseView(
|
||||||
concreteView View,
|
concreteView View,
|
||||||
controller Controller,
|
viewModel ViewModel,
|
||||||
) *BaseView {
|
) *BaseView {
|
||||||
v := new(BaseView)
|
v := new(BaseView)
|
||||||
v.id = uuid.NewString()
|
v.id = uuid.NewString()
|
||||||
v.concreteView = concreteView
|
v.concreteView = concreteView
|
||||||
v.Ctrl = controller
|
v.ViewModel = viewModel
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBaseViewWithScreen(
|
func NewBaseViewWithScreen(
|
||||||
concreteView View,
|
concreteView View,
|
||||||
controller Controller,
|
viewModel ViewModel,
|
||||||
filesystem embed.FS,
|
filesystem embed.FS,
|
||||||
screenName string,
|
screenName string,
|
||||||
localizer *i18n.Localizer,
|
localizer *i18n.Localizer,
|
||||||
) *BaseView {
|
) *BaseView {
|
||||||
v := NewBaseView(concreteView, controller)
|
v := NewBaseView(concreteView, viewModel)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
v.ScreenHandler, err = NewScreenHandler(
|
v.ScreenHandler, err = NewScreenHandler(
|
||||||
filesystem,
|
filesystem,
|
||||||
screenName,
|
screenName,
|
||||||
controller,
|
viewModel,
|
||||||
localizer)
|
localizer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogWindowError(v, LoadScreen, err)
|
LogWindowError(v, LoadScreen, err)
|
||||||
@ -95,8 +95,8 @@ func (v BaseView) Title() string {
|
|||||||
|
|
||||||
// Initialize initializes the view
|
// Initialize initializes the view
|
||||||
func (v *BaseView) Initialize() fyne.CanvasObject {
|
func (v *BaseView) Initialize() fyne.CanvasObject {
|
||||||
LogWindowEvent(v, Initialize)
|
//LogWindowEvent(v, Initialize)
|
||||||
if err := v.Ctrl.Initialize(); err != nil {
|
if err := v.ViewModel.Initialize(); err != nil {
|
||||||
LogWindowError(v, Initialize, err)
|
LogWindowError(v, Initialize, err)
|
||||||
}
|
}
|
||||||
if v.ScreenHandler != nil && v.ScreenDefinition() != nil {
|
if v.ScreenHandler != nil && v.ScreenDefinition() != nil {
|
||||||
@ -112,7 +112,7 @@ func (v *BaseView) Initialize() fyne.CanvasObject {
|
|||||||
|
|
||||||
// Refresh is called when the view needs a full update
|
// Refresh is called when the view needs a full update
|
||||||
func (v *BaseView) Refresh() {
|
func (v *BaseView) Refresh() {
|
||||||
LogWindowEvent(v, Refresh)
|
//LogWindowEvent(v, Refresh)
|
||||||
if v.CanvasObject != nil {
|
if v.CanvasObject != nil {
|
||||||
v.CanvasObject.Refresh()
|
v.CanvasObject.Refresh()
|
||||||
}
|
}
|
||||||
@ -120,13 +120,13 @@ func (v *BaseView) Refresh() {
|
|||||||
|
|
||||||
// OnShow is called when the view becomes visible on the screen
|
// OnShow is called when the view becomes visible on the screen
|
||||||
func (v *BaseView) OnShow() {
|
func (v *BaseView) OnShow() {
|
||||||
LogWindowEvent(v, OnShow)
|
//LogWindowEvent(v, OnShow)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *BaseView) OnHide() {
|
func (v *BaseView) OnHide() {
|
||||||
LogWindowEvent(v, OnHide)
|
//LogWindowEvent(v, OnHide)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *BaseView) GetBinding(bindingName string) binding.DataItem {
|
func (v *BaseView) GetBinding(bindingName string) binding.DataItem {
|
||||||
return v.Ctrl.GetBinding(bindingName)
|
return v.ViewModel.GetBinding(bindingName)
|
||||||
}
|
}
|
||||||
|
44
dialog.go
44
dialog.go
@ -58,7 +58,7 @@ type BaseDialog struct {
|
|||||||
Data binding.DataItem
|
Data binding.DataItem
|
||||||
focusItem fyne.Focusable
|
focusItem fyne.Focusable
|
||||||
|
|
||||||
Ctrl DialogController
|
ViewModel DialogViewModel
|
||||||
*ScreenHandler
|
*ScreenHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ func NewBaseDialog(
|
|||||||
concreteDialog Dialog,
|
concreteDialog Dialog,
|
||||||
name DialogName,
|
name DialogName,
|
||||||
kind DialogKind,
|
kind DialogKind,
|
||||||
controller DialogController,
|
viewModel DialogViewModel,
|
||||||
parent fyne.Window,
|
parent fyne.Window,
|
||||||
confirm OnConfirmFn,
|
confirm OnConfirmFn,
|
||||||
) *BaseDialog {
|
) *BaseDialog {
|
||||||
@ -77,7 +77,7 @@ func NewBaseDialog(
|
|||||||
dlgKind: kind,
|
dlgKind: kind,
|
||||||
window: parent,
|
window: parent,
|
||||||
onConfirm: confirm,
|
onConfirm: confirm,
|
||||||
Ctrl: controller,
|
ViewModel: viewModel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ func NewBaseDialogWithScreen(
|
|||||||
concreteDialog Dialog,
|
concreteDialog Dialog,
|
||||||
name DialogName,
|
name DialogName,
|
||||||
kind DialogKind,
|
kind DialogKind,
|
||||||
controller DialogController,
|
viewModel DialogViewModel,
|
||||||
parent fyne.Window,
|
parent fyne.Window,
|
||||||
confirm OnConfirmFn,
|
confirm OnConfirmFn,
|
||||||
filesystem embed.FS,
|
filesystem embed.FS,
|
||||||
@ -93,12 +93,12 @@ func NewBaseDialogWithScreen(
|
|||||||
localizer *i18n.Localizer,
|
localizer *i18n.Localizer,
|
||||||
) *BaseDialog {
|
) *BaseDialog {
|
||||||
d := NewBaseDialog(
|
d := NewBaseDialog(
|
||||||
concreteDialog, name, kind, controller,
|
concreteDialog, name, kind, viewModel,
|
||||||
parent, confirm)
|
parent, confirm)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
d.ScreenHandler, err = NewScreenHandler(
|
d.ScreenHandler, err = NewScreenHandler(
|
||||||
filesystem, screenName, controller, localizer)
|
filesystem, screenName, viewModel, localizer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogWindowError(d, LoadScreen, err)
|
LogWindowError(d, LoadScreen, err)
|
||||||
return nil
|
return nil
|
||||||
@ -110,7 +110,7 @@ func NewBaseDialogWithData(
|
|||||||
concreteDialog Dialog,
|
concreteDialog Dialog,
|
||||||
name DialogName,
|
name DialogName,
|
||||||
kind DialogKind,
|
kind DialogKind,
|
||||||
controller DialogController,
|
viewModel DialogViewModel,
|
||||||
parent fyne.Window,
|
parent fyne.Window,
|
||||||
confirm OnConfirmFn,
|
confirm OnConfirmFn,
|
||||||
data binding.DataItem,
|
data binding.DataItem,
|
||||||
@ -123,7 +123,7 @@ func NewBaseDialogWithData(
|
|||||||
window: parent,
|
window: parent,
|
||||||
onConfirm: confirm,
|
onConfirm: confirm,
|
||||||
Data: data,
|
Data: data,
|
||||||
Ctrl: controller,
|
ViewModel: viewModel,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ func NewBaseDialogWithDataAndScreen(
|
|||||||
concreteDialog Dialog,
|
concreteDialog Dialog,
|
||||||
name DialogName,
|
name DialogName,
|
||||||
kind DialogKind,
|
kind DialogKind,
|
||||||
controller DialogController,
|
viewModel DialogViewModel,
|
||||||
parent fyne.Window,
|
parent fyne.Window,
|
||||||
confirm OnConfirmFn,
|
confirm OnConfirmFn,
|
||||||
data binding.DataItem,
|
data binding.DataItem,
|
||||||
@ -140,12 +140,12 @@ func NewBaseDialogWithDataAndScreen(
|
|||||||
localizer *i18n.Localizer,
|
localizer *i18n.Localizer,
|
||||||
) *BaseDialog {
|
) *BaseDialog {
|
||||||
d := NewBaseDialogWithData(
|
d := NewBaseDialogWithData(
|
||||||
concreteDialog, name, kind, controller,
|
concreteDialog, name, kind, viewModel,
|
||||||
parent, confirm, data)
|
parent, confirm, data)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
d.ScreenHandler, err = NewScreenHandler(
|
d.ScreenHandler, err = NewScreenHandler(
|
||||||
filesystem, screenName, controller, localizer)
|
filesystem, screenName, viewModel, localizer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
LogWindowError(d, LoadScreen, err)
|
LogWindowError(d, LoadScreen, err)
|
||||||
return nil
|
return nil
|
||||||
@ -215,7 +215,7 @@ func (d BaseDialog) Title() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *BaseDialog) Initialize() fyne.CanvasObject {
|
func (d *BaseDialog) Initialize() fyne.CanvasObject {
|
||||||
if err := d.Ctrl.Initialize(d.Data); err != nil {
|
if err := d.ViewModel.Initialize(d.Data); err != nil {
|
||||||
LogWindowError(d, Initialize, err)
|
LogWindowError(d, Initialize, err)
|
||||||
}
|
}
|
||||||
if d.ScreenHandler != nil && d.ScreenDefinition() != nil {
|
if d.ScreenHandler != nil && d.ScreenDefinition() != nil {
|
||||||
@ -236,11 +236,11 @@ func (d *BaseDialog) Refresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *BaseDialog) OnShow() {
|
func (d *BaseDialog) OnShow() {
|
||||||
LogWindowEvent(d, OnShow)
|
//LogWindowEvent(d, OnShow)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BaseDialog) OnHide() {
|
func (d *BaseDialog) OnHide() {
|
||||||
LogWindowEvent(d, OnHide)
|
//LogWindowEvent(d, OnHide)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *BaseDialog) OnClose(confirmed bool) {
|
func (d *BaseDialog) OnClose(confirmed bool) {
|
||||||
@ -264,14 +264,14 @@ func NewFormDialog(
|
|||||||
concreteDialog Dialog,
|
concreteDialog Dialog,
|
||||||
name DialogName,
|
name DialogName,
|
||||||
kind DialogKind,
|
kind DialogKind,
|
||||||
controller DialogController,
|
viewModel DialogViewModel,
|
||||||
parent fyne.Window,
|
parent fyne.Window,
|
||||||
confirm OnConfirmFn,
|
confirm OnConfirmFn,
|
||||||
itemsFn FormDialogItemsFn,
|
itemsFn FormDialogItemsFn,
|
||||||
) *FormDialog {
|
) *FormDialog {
|
||||||
return &FormDialog{
|
return &FormDialog{
|
||||||
BaseDialog: NewBaseDialog(
|
BaseDialog: NewBaseDialog(
|
||||||
concreteDialog, name, kind, controller, parent, confirm),
|
concreteDialog, name, kind, viewModel, parent, confirm),
|
||||||
itemsFn: itemsFn,
|
itemsFn: itemsFn,
|
||||||
confirmLabel: "OK",
|
confirmLabel: "OK",
|
||||||
dismissLabel: "Cancel",
|
dismissLabel: "Cancel",
|
||||||
@ -282,7 +282,7 @@ func NewFormDialogWithScreen(
|
|||||||
concreteDialog Dialog,
|
concreteDialog Dialog,
|
||||||
name DialogName,
|
name DialogName,
|
||||||
kind DialogKind,
|
kind DialogKind,
|
||||||
controller DialogController,
|
viewModel DialogViewModel,
|
||||||
parent fyne.Window,
|
parent fyne.Window,
|
||||||
confirm OnConfirmFn,
|
confirm OnConfirmFn,
|
||||||
filesystem embed.FS,
|
filesystem embed.FS,
|
||||||
@ -291,7 +291,7 @@ func NewFormDialogWithScreen(
|
|||||||
) *FormDialog {
|
) *FormDialog {
|
||||||
return &FormDialog{
|
return &FormDialog{
|
||||||
BaseDialog: NewBaseDialogWithScreen(
|
BaseDialog: NewBaseDialogWithScreen(
|
||||||
concreteDialog, name, kind, controller, parent, confirm,
|
concreteDialog, name, kind, viewModel, parent, confirm,
|
||||||
filesystem, screenName, localizer),
|
filesystem, screenName, localizer),
|
||||||
confirmLabel: "OK",
|
confirmLabel: "OK",
|
||||||
dismissLabel: "Cancel",
|
dismissLabel: "Cancel",
|
||||||
@ -302,7 +302,7 @@ func NewformDialogWithData(
|
|||||||
concreteDialog Dialog,
|
concreteDialog Dialog,
|
||||||
name DialogName,
|
name DialogName,
|
||||||
kind DialogKind,
|
kind DialogKind,
|
||||||
controller DialogController,
|
viewModel DialogViewModel,
|
||||||
parent fyne.Window,
|
parent fyne.Window,
|
||||||
confirm OnConfirmFn,
|
confirm OnConfirmFn,
|
||||||
itemsFn FormDialogItemsFn,
|
itemsFn FormDialogItemsFn,
|
||||||
@ -310,7 +310,7 @@ func NewformDialogWithData(
|
|||||||
) *FormDialog {
|
) *FormDialog {
|
||||||
return &FormDialog{
|
return &FormDialog{
|
||||||
BaseDialog: NewBaseDialogWithData(
|
BaseDialog: NewBaseDialogWithData(
|
||||||
concreteDialog, name, kind, controller, parent, confirm, data),
|
concreteDialog, name, kind, viewModel, parent, confirm, data),
|
||||||
itemsFn: itemsFn,
|
itemsFn: itemsFn,
|
||||||
confirmLabel: "OK",
|
confirmLabel: "OK",
|
||||||
dismissLabel: "Cancel",
|
dismissLabel: "Cancel",
|
||||||
@ -321,7 +321,7 @@ func NewFormDialogWithDataAndScreen(
|
|||||||
concreteDialog Dialog,
|
concreteDialog Dialog,
|
||||||
name DialogName,
|
name DialogName,
|
||||||
kind DialogKind,
|
kind DialogKind,
|
||||||
controller DialogController,
|
viewModel DialogViewModel,
|
||||||
parent fyne.Window,
|
parent fyne.Window,
|
||||||
confirm OnConfirmFn,
|
confirm OnConfirmFn,
|
||||||
data binding.DataItem,
|
data binding.DataItem,
|
||||||
@ -331,7 +331,7 @@ func NewFormDialogWithDataAndScreen(
|
|||||||
) *FormDialog {
|
) *FormDialog {
|
||||||
return &FormDialog{
|
return &FormDialog{
|
||||||
BaseDialog: NewBaseDialogWithDataAndScreen(
|
BaseDialog: NewBaseDialogWithDataAndScreen(
|
||||||
concreteDialog, name, kind, controller, parent, confirm, data,
|
concreteDialog, name, kind, viewModel, parent, confirm, data,
|
||||||
filesystem, screenName, localizer),
|
filesystem, screenName, localizer),
|
||||||
confirmLabel: "OK",
|
confirmLabel: "OK",
|
||||||
dismissLabel: "Cancel",
|
dismissLabel: "Cancel",
|
||||||
|
@ -3,6 +3,7 @@ package ui
|
|||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"bitbucket.org/hevanto/ui/screen"
|
"bitbucket.org/hevanto/ui/screen"
|
||||||
@ -24,7 +25,7 @@ import (
|
|||||||
type ScreenHandler struct {
|
type ScreenHandler struct {
|
||||||
screenDefinition *screen.Screen
|
screenDefinition *screen.Screen
|
||||||
localizer *i18n.Localizer
|
localizer *i18n.Localizer
|
||||||
ctrl ScreenController
|
viewModel BaseViewModel
|
||||||
|
|
||||||
// Map of screen elements that got an id assigned
|
// Map of screen elements that got an id assigned
|
||||||
exportedElements map[string]*screen.UIElement
|
exportedElements map[string]*screen.UIElement
|
||||||
@ -56,12 +57,12 @@ type ScreenHandler struct {
|
|||||||
func NewScreenHandler(
|
func NewScreenHandler(
|
||||||
filesystem embed.FS,
|
filesystem embed.FS,
|
||||||
screenName string,
|
screenName string,
|
||||||
ctrl ScreenController,
|
viewModel BaseViewModel,
|
||||||
localizer *i18n.Localizer,
|
localizer *i18n.Localizer,
|
||||||
) (h *ScreenHandler, err error) {
|
) (h *ScreenHandler, err error) {
|
||||||
h = new(ScreenHandler)
|
h = new(ScreenHandler)
|
||||||
|
|
||||||
h.ctrl = ctrl
|
h.viewModel = viewModel
|
||||||
h.localizer = localizer
|
h.localizer = localizer
|
||||||
|
|
||||||
def, err := screen.New(filesystem, screenName, h)
|
def, err := screen.New(filesystem, screenName, h)
|
||||||
@ -217,7 +218,7 @@ func (h *ScreenHandler) RegisterOnValidationChangedHandler(
|
|||||||
// This function forwards the call to the controller. In the controller the
|
// This function forwards the call to the controller. In the controller the
|
||||||
// required bindings should be mapped to the screen elements.
|
// required bindings should be mapped to the screen elements.
|
||||||
func (h *ScreenHandler) GetBinding(name string) binding.DataItem {
|
func (h *ScreenHandler) GetBinding(name string) binding.DataItem {
|
||||||
return h.ctrl.GetBinding(name)
|
return h.viewModel.GetBinding(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetValidator returns the validator with the given name.
|
// GetValidator returns the validator with the given name.
|
||||||
@ -225,7 +226,7 @@ func (h *ScreenHandler) GetBinding(name string) binding.DataItem {
|
|||||||
// This function forwards the call to the controller. In the controller the
|
// This function forwards the call to the controller. In the controller the
|
||||||
// required validators should be mapped to the screen elements.
|
// required validators should be mapped to the screen elements.
|
||||||
func (h *ScreenHandler) GetValidator(name string) fyne.StringValidator {
|
func (h *ScreenHandler) GetValidator(name string) fyne.StringValidator {
|
||||||
return h.ctrl.GetValidator(name)
|
return h.viewModel.GetValidator(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetElement returns the UIElement with the given ID.
|
// GetElement returns the UIElement with the given ID.
|
||||||
@ -236,10 +237,12 @@ func (h *ScreenHandler) GetValidator(name string) fyne.StringValidator {
|
|||||||
// is present it's advices to do hide and show operations on the decorator, and
|
// is present it's advices to do hide and show operations on the decorator, and
|
||||||
// all other operators on the object.
|
// all other operators on the object.
|
||||||
func (h *ScreenHandler) GetElement(id string) *screen.UIElement {
|
func (h *ScreenHandler) GetElement(id string) *screen.UIElement {
|
||||||
if elem, ok := h.exportedElements[id]; ok {
|
elem, ok := h.exportedElements[id]
|
||||||
return elem
|
if !ok {
|
||||||
|
log.Printf("element %s not found", id)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
return nil
|
return elem
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetLocalizer returns the i18n.Localizer used for localization.
|
// GetLocalizer returns the i18n.Localizer used for localization.
|
||||||
@ -257,6 +260,7 @@ func (h *ScreenHandler) GetIcon(iconName string) fyne.Resource {
|
|||||||
iconName := strings.SplitN(iconName, ".", 2)[1]
|
iconName := strings.SplitN(iconName, ".", 2)[1]
|
||||||
return theme.DefaultTheme().Icon(fyne.ThemeIconName(iconName))
|
return theme.DefaultTheme().Icon(fyne.ThemeIconName(iconName))
|
||||||
}
|
}
|
||||||
|
log.Printf("icon %s not found", iconName)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,6 +268,7 @@ func (h *ScreenHandler) GetIcon(iconName string) fyne.Resource {
|
|||||||
func (h *ScreenHandler) GetListItemTemplate(name string) screen.ListItemTemplateFn {
|
func (h *ScreenHandler) GetListItemTemplate(name string) screen.ListItemTemplateFn {
|
||||||
fn, ok := h.listItemTemplates[name]
|
fn, ok := h.listItemTemplates[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("list template %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
@ -273,6 +278,7 @@ func (h *ScreenHandler) GetListItemTemplate(name string) screen.ListItemTemplate
|
|||||||
func (h *ScreenHandler) GetListDataItemRenderer(name string) screen.ListDataItemRendererFn {
|
func (h *ScreenHandler) GetListDataItemRenderer(name string) screen.ListDataItemRendererFn {
|
||||||
fn, ok := h.listDataItemRenderers[name]
|
fn, ok := h.listDataItemRenderers[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("list renderer %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
@ -282,6 +288,7 @@ func (h *ScreenHandler) GetListDataItemRenderer(name string) screen.ListDataItem
|
|||||||
func (h *ScreenHandler) GetListItemRenderer(name string) screen.ListItemRendererFn {
|
func (h *ScreenHandler) GetListItemRenderer(name string) screen.ListItemRendererFn {
|
||||||
fn, ok := h.listItemRenderers[name]
|
fn, ok := h.listItemRenderers[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("list renderer %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
@ -291,6 +298,7 @@ func (h *ScreenHandler) GetListItemRenderer(name string) screen.ListItemRenderer
|
|||||||
func (h *ScreenHandler) GetListLength(name string) screen.ListLengthFn {
|
func (h *ScreenHandler) GetListLength(name string) screen.ListLengthFn {
|
||||||
fn, ok := h.listLengths[name]
|
fn, ok := h.listLengths[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("list length %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
@ -300,6 +308,7 @@ func (h *ScreenHandler) GetListLength(name string) screen.ListLengthFn {
|
|||||||
func (h *ScreenHandler) GetOnListItemSelectedHandler(name string) screen.ListItemHandlerFn {
|
func (h *ScreenHandler) GetOnListItemSelectedHandler(name string) screen.ListItemHandlerFn {
|
||||||
fn, ok := h.onListItemSelectedHandlers[name]
|
fn, ok := h.onListItemSelectedHandlers[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("list item selected handler %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
@ -309,6 +318,7 @@ func (h *ScreenHandler) GetOnListItemSelectedHandler(name string) screen.ListIte
|
|||||||
func (h *ScreenHandler) GetOnListItemUnselectedHandler(name string) screen.ListItemHandlerFn {
|
func (h *ScreenHandler) GetOnListItemUnselectedHandler(name string) screen.ListItemHandlerFn {
|
||||||
fn, ok := h.onListItemUnselectedHandlers[name]
|
fn, ok := h.onListItemUnselectedHandlers[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("list item unselected handler %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
@ -318,6 +328,7 @@ func (h *ScreenHandler) GetOnListItemUnselectedHandler(name string) screen.ListI
|
|||||||
func (h *ScreenHandler) GetOnClickedHandler(name string) screen.ClickHandlerFn {
|
func (h *ScreenHandler) GetOnClickedHandler(name string) screen.ClickHandlerFn {
|
||||||
fn, ok := h.onClickedHandlers[name]
|
fn, ok := h.onClickedHandlers[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("clicked handler %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
@ -327,6 +338,7 @@ func (h *ScreenHandler) GetOnClickedHandler(name string) screen.ClickHandlerFn {
|
|||||||
func (h *ScreenHandler) GetOnCheckChangedHandler(name string) screen.CheckHandlerFn {
|
func (h *ScreenHandler) GetOnCheckChangedHandler(name string) screen.CheckHandlerFn {
|
||||||
fn, ok := h.onCheckChangedHandlers[name]
|
fn, ok := h.onCheckChangedHandlers[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("check changed handler %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
@ -336,6 +348,7 @@ func (h *ScreenHandler) GetOnCheckChangedHandler(name string) screen.CheckHandle
|
|||||||
func (h *ScreenHandler) GetOnDateSelectedHandler(name string) screen.DateSelectedHandlerFn {
|
func (h *ScreenHandler) GetOnDateSelectedHandler(name string) screen.DateSelectedHandlerFn {
|
||||||
fn, ok := h.onDateSelectedHandlers[name]
|
fn, ok := h.onDateSelectedHandlers[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("date selected handler %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
@ -345,6 +358,7 @@ func (h *ScreenHandler) GetOnDateSelectedHandler(name string) screen.DateSelecte
|
|||||||
func (h *ScreenHandler) GetOnValidationChangedHandler(name string) screen.ValidationChangedHandlerFn {
|
func (h *ScreenHandler) GetOnValidationChangedHandler(name string) screen.ValidationChangedHandlerFn {
|
||||||
fn, ok := h.onValidationChangedHandlers[name]
|
fn, ok := h.onValidationChangedHandlers[name]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
log.Printf("validation changed handler %s not found", name)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fn
|
return fn
|
||||||
|
@ -29,7 +29,7 @@ type TabbedView struct {
|
|||||||
|
|
||||||
// NewTabbedView creates a new tabbed view
|
// NewTabbedView creates a new tabbed view
|
||||||
func NewTabbedView(
|
func NewTabbedView(
|
||||||
controller Controller,
|
controller ViewModel,
|
||||||
tabLocation container.TabLocation,
|
tabLocation container.TabLocation,
|
||||||
tabview ...View,
|
tabview ...View,
|
||||||
) *TabbedView {
|
) *TabbedView {
|
||||||
|
@ -5,20 +5,20 @@ import (
|
|||||||
"fyne.io/fyne/v2/data/binding"
|
"fyne.io/fyne/v2/data/binding"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ScreenController interface {
|
type BaseViewModel interface {
|
||||||
GetBinding(string) binding.DataItem
|
GetBinding(string) binding.DataItem
|
||||||
GetValidator(string) fyne.StringValidator
|
GetValidator(string) fyne.StringValidator
|
||||||
}
|
}
|
||||||
|
|
||||||
type Controller interface {
|
type ViewModel interface {
|
||||||
ScreenController
|
BaseViewModel
|
||||||
|
|
||||||
Initialize() error
|
Initialize() error
|
||||||
RefreshData() error
|
RefreshData() error
|
||||||
}
|
}
|
||||||
|
|
||||||
type DialogController interface {
|
type DialogViewModel interface {
|
||||||
ScreenController
|
BaseViewModel
|
||||||
|
|
||||||
Initialize(data binding.DataItem) error
|
Initialize(data binding.DataItem) error
|
||||||
RefreshData() error
|
RefreshData() error
|
Loading…
Reference in New Issue
Block a user