Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GridStack used inside a VStack #15

Open
Khronoss opened this issue Feb 19, 2021 · 0 comments
Open

GridStack used inside a VStack #15

Khronoss opened this issue Feb 19, 2021 · 0 comments

Comments

@Khronoss
Copy link

Hi!

So I'm in a situation where I want a horizontal list of items that also stack verticaly when too much items are sent to it, and your tool is perfect for that job <3

...but! I also want it to be on top of a multiline text view, so I put both in a VStack.

The thing is that by doing that, the GridStack and the text view take each half the VStack's height. I looked into the GridStack's code because I expected it to take as small space as possible but I came accros a GeometryReader surrounding the elements, and this is understandable because you need to know the available width to work.
But I know the GeometryReader doesn't shrink to it compact size but rather always take all the space it can, wether its content takes less or not. And it all made sense then!

I've copied your GridStack locally in my project to work on it, and by removing the GeometryReader and sending the width to the GridStack (and removing the ScrollView too because of the same behavior), it all worked perfectly for my intention!

So here is (finaly) my proposal:

  • making the scroll feature optional
  • removing the GeometryReader and let the "upper" view sending the desired width to the GridStack
  • (optionnaly, for the sake of easing the use of most cases) using an enum as the width with a case like "auto" that will add your current GeometryReader so that the "upper" view won't have to use a GeometryReady if it deosn't need to

Here is the result I targeted, the GridStack is (obviously) the row of circles
Capture d’écran 2021-02-19 à 18 25 01

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

No branches or pull requests

1 participant