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

Cannot define dynamic height for my drawer #17

Open
oronbz opened this issue Aug 2, 2022 · 1 comment
Open

Cannot define dynamic height for my drawer #17

oronbz opened this issue Aug 2, 2022 · 1 comment

Comments

@oronbz
Copy link

oronbz commented Aug 2, 2022

I want my drawer heights (resting points) to be, [100, vStackHeight], so instead of giving it a constant number, i want the second resting height to be the height of the VStack, but I couldn't achieve it even when wrapping the VStack with GeometryReader, since the GeometryReader takes the the size of its parent (the ZStack), any idea how to achieve this behaviour?

    @State var drawerHeights: [CGFloat] = [100, 200]

    var body: some View {
        Drawer(heights: $drawerHeights) {
            ZStack(alignment: .top) {
                RoundedRectangle(cornerRadius: 24)
                    .foregroundColor(.white100)
                    .shadow(radius: 10)
                
                VStack(spacing: 0) {
                    Spacer().frame(height: 40)
                        .background(Color.yellow)
                    Text("How it works")
                        .textStyle(.headlinePrimaryCenter)
                    Spacer().frame(height: 40)
                    Text("How it works")
                        .textStyle(.headlinePrimaryCenter)
                    Text("How it works")
                        .textStyle(.headlinePrimaryCenter)
                    Text("How it works")
                        .textStyle(.headlinePrimaryCenter)
                    Text("How it works")
                        .textStyle(.headlinePrimaryCenter)
                    Text("How it works3")
                        .textStyle(.headlinePrimaryCenter)
                    Text("How it works4")
                        .textStyle(.headlinePrimaryCenter)
                }
            }
        }
        .edgesIgnoringSafeArea(.vertical)
    }

Basically I want the drawer second height (rest) to be dynamic and computed based on its children's height.

@oronbz
Copy link
Author

oronbz commented Aug 2, 2022

image

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