Skip to content
This repository has been archived by the owner on Jan 27, 2024. It is now read-only.

Add ListWithData tutorial #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

mJehanno
Copy link

@mJehanno mJehanno commented Oct 8, 2021

No description provided.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this. Just some thoughts on how it could be neater/clearer?

Well first thing first, let's start by defining our binding in our app :

```go
var ContactListBinding binding.UntypedList = binding.NewUntypedList()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best not to export variables unless required

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here you should define the struct contact or whatever.
For the rest of the example can you use a local type rather than contact.Contact?

@@ -139,6 +139,9 @@ entries:
- title: Add a Custom Theme
url: /tutorial/custom-theme
output: web, pdf
- title: List of struct and ListWithData widget
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you think of a shorter title?
"ListWIthData using custom struct" perhaps?

return container.NewVBox(widget.NewLabel(""), widget.NewLabel(""), widget.NewLabel(""), widget.NewLabel(""))
},
func(di binding.DataItem, co fyne.CanvasObject) {
v, _ := di.(binding.Untyped).Get()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it is worth using s := binding.BindStruct(v.(*contact)).
Then a label could be bound using Label.Bind(s.GetItem("FirstName").(binding.String)) I think?...
It would remove the code where you set up new strings and then bind them - making a proper connection to the source data.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants