Add ListWithData tutorial #54
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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() |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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.
No description provided.