CoolONEOfficial / NativePartialSheet

🔥 Native partial customizable SwiftUI sheets from iOS 15.0
MIT License
119 stars 7 forks source link

Using the sheet moves my views #3

Closed lchamp closed 1 year ago

lchamp commented 1 year ago

Hi there, thanks for your NativePartielSheet however I'm facing a little issue... Thankfully it can be reproduced easily as shown below.

import NativePartialSheet

struct ContentView: View {
    @State private var showMore: Bool = false

    var body: some View {
        ZStack {
            // More views & co

            // Top layer below

            VStack(spacing: 16) {
                Spacer()

                Text("Little toast for the issue demo")
                    .padding(16)
                    .background {
                        Color.primary.opacity(0.2)
                            .clipShape(Capsule())
                    }

                Button {
                    showMore = true
                } label: {
                    Image(systemName: "ellipsis.circle")
                }
                .foregroundColor(.accentColor)
                .font(.largeTitle)
                .padding(16)
                .sheet(isPresented: $showMore) {
                    Text("Cupcake ipsum dolor sit amet chupa chups croissant. Bonbon sugar plum powder chocolate cake lollipop muffin chupa chups soufflé apple pie. Croissant cheesecake cake liquorice candy canes lemon drops gingerbread gingerbread.\n\nJujubes toffee topping soufflé brownie wafer marshmallow cheesecake. Caramels wafer ice cream gummies jelly chocolate cake. Sesame snaps topping chocolate cake wafer macaroon cookie. Cookie cake shortbread tootsie roll tootsie roll jelly-o danish.")
                        .fixedSize(horizontal: false, vertical: true)
                        .font(.body)
                        .padding(.horizontal, 16)
                        .padding(.vertical, 32)
                }
                .presentationDetents([.medium])
                .presentationDragIndicator(.visible)
            }
        }
    }
}

With the .sheet commented heres is the result (as expected): IMG_0834_1000

However as soon as the sheet is being used, it moves everything to fill the screen and doesn't respect the Spacer() used. Resulting in this: IMG_0835_1000

Not sure what causes the issue. I though it was related to the ZStack but doesn't seems so... I'll update if I find anything else. Let me know in case you look into it!

lchamp commented 1 year ago

A shorter code, same issue, if needed

struct ContentView: View {
    @State private var showMore: Bool = false

    var body: some View {
        VStack {
            Spacer()
            Text("ABCDEFG")
            Text("HIJKLMNOP")
            Text("Show sheet")
                .onTapGesture {
                    showMore = true
                }
                .sheet(isPresented: $showMore) {
                    Text("Sheet content")
                }
                .presentationDetents([ .large, .medium ])
        }
    }
}
CoolONEOfficial commented 1 year ago

Thanks for explained description, I just fixed it in 2.0.4 release 👍