Lists of unlimited height in a viewport #540
-
|
Hi there. I want to make a ui that basically looks like this: ... (with many days, the user can scroll down to see them) This is a list of items fetched from the web, grouped by date. I want to be able to scroll through this list, select multiple, then perform bulk operations on them. My idea was to have a brick list per day, and then try to figure out some movement event handling logic that jumps to the start of the subsequent day's list when you're at the end of the previous list. Something like this: viewport ItemsView Vertical (vBox (map viewDay days))
...
viewDay :: (Day, Brick.GenericList N Seq Item) -> Widget N
viewDay (day, items) =
(txt . Interactive.boxed $ show day)
<=> Brick.renderList viewItem False itemsThis crashes with viewDay :: (Day, Brick.GenericList N Seq Item) -> Widget N
viewDay (day, items) =
(txt . Interactive.boxed $ show day)
<=> vLimit 20 (Brick.renderList viewItem False items)but this either cuts off items or leaves large gaps between days. What I really want is for each day's list to take up exactly as much vertical space as it needs to, rather than some fixed amount. I could also do something like this: viewDay :: (Day, [Item]) -> Widget N
viewDay (day, items) =
(txt . Interactive.boxed $ show day)
<=> vBox (map viewItem items)This gives me what I want visually, but then of course I don't get the free selection and movement logic that comes with brick lists. What's the best way to do this? Is there some way to do it using brick lists, or will I just need to implement the selection management myself on top of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
Hi @sullyj3 - it will likely work better to take an approach as follows:
But this comes with a slight restriction that I can explain if needed: if you're going to use a built-in brick The list item type would need to be something like data ListItem = Header Date | Item YourItemTypeso that you can draw headers with As for the multiple selection, that can be managed independently of the list (and probably should be) in an application state field that tracks which items are selected. Then your list item rendering function can consult that state to see whether an item is selected and render it accordingly. Does that make sense? |
Beta Was this translation helpful? Give feedback.
Hi @sullyj3 - it will likely work better to take an approach as follows:
But this comes with a slight restriction that I can explain if needed: if you're going to use a built-in brick
Listfor that -- and I recommend doing so -- then all of the list items must have the same height. That means that your day headers can't be boxed like they are, since that makes them three rows high, and your selectable e…