adamfootdev/BottomSheet

add background color when BottomSheet open

Opened this issue · 0 comments

X901 commented

Hi,
I think it's important to have background color on BottomSheet

I tried to add it like this

 func body(content: Content) -> some View {
        ZStack {
        content
            .onChange(of: isPresented, perform: updatePresentation)
            .onChange(of: selectedDetentIdentifier, perform: updateSelectedDetentIdentifier)
            
            if isPresented {
             Color.black.opacity(0.5).ignoresSafeArea()
                    .animation(.easeIn, value: isPresented)
            }
        }
    }

But I notice it take awhile until the background disappeared after bottomSheet closed
is there a better way to do it ?