-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fyne List Proposal
A new List widget implementation is now in progress and you can see the status of the implementation here: https://github.com/fyne-io/fyne/pull/1253
The List widget embeds a ScrollContainer, creates a listLayout internally that is the content of the ScrollContainer and manages items by keeping a pool of recycled canvas objects that are reused as the ScrollContainer scrolls.
The current implementation of List requires that all objects be the same, aka homogeneous, and the sizing that List uses to determine it's recycling and layout are all based off the minimum size of a list item.
List does not need any access to data as it is able to manage the List content by making use of CreateItem and UpdateItem fields providing only the index of the appropriate list item to the developer. List is able to do this by knowing that all list items are the same size, and knowing the total count of list items.
The List widget provides the following fields:
- Length func() int - A function that the developer will set that List uses to ask for the total number of list items
- CreateItem func() fyne.CanvasObject - A function that the developer will set that List uses to ask for a new list item. This function will also be used to determine the minimum width and height of a list item which List will use to perform it's layout and recycling calculations. A CanvasObject must be returned to list.
- UpdateItem func(index int, item fyne.CanvasObject) - A function that the developer will set that List calls to allow the developer to update the contents of a list item. The List will prove the index of the list item and visible canvas object containing the list item.
- OnItemSelected func(index int, item fyne.CanvasObject) - A function that the developer will set that List calls to alert the developer that an item has been selected. List provides the index of the list item and visible canvas object containing the list item.
The list widget provides the following api:
- func NewList(length func() int, createItem func() fyne.CanvasObject, updateItem func(index int, item fyne.CanvasObject)) *List NewList is a constructor that takes the Length, CreateItem, and UpdateItem functions described above as arguments and returns a new List object.