-
-
Notifications
You must be signed in to change notification settings - Fork 160
dynamic height in horizontally scrollable section #186
Comments
Apple's |
I think I've solved this, only be mere chance and with a lot of extra additional help. There's a lot of things that I've done to make this work, and I don't know which of them will help you. This is how I'm using ASCollectionView to create a horizontally scrollable list of cards. The .dynamicHorizontalList function is similar to what you've used for layout, in that it allows you to set values for height as well, instead of .fractional(1) value offered with the .list() method
Another thing to note is that I've used a custom HorizontalGeometryReader to compute the height of the cell, which only takes the width value of the parent and does not scale on the y-axis like the usual GeometryReader.
The final sauce that made this work, which is something that I've discovered by accident, was adding the Spacer() in the VStack that I've used for the card in the code above. Without this, the card will not grow to fit its content, but will instead collapse along its y-axis. I don't understand why, but oh well. Also, here's the code for the HorizontalGeometryReader class.
|
Hey guys,
I'm basically trying to implement the AppStore example (vertical scroll view with horizontally scrollable sections) but with dynamic type support. In order for this to work I've modified the
var layout: ASCollectionLayout<Int>
extension to deliver the following code:However, the
.estimated(350)
for the item's and group's height don't seem to work. The resulting section always has a height of 350 and doesn't adopt to the actual content's height. The actual cell content has a blue background for debugging purposes - when you scroll sideways you get the next item...in the next release these cells should only be 1/3 of the screen's width. The white area underneath the blue cell however should actually shrink.Cheers,
Sebastian
The text was updated successfully, but these errors were encountered: