nathantannar4/Transmission

Nested presentation does not ignore safe area

PhilipDukhov opened this issue · 1 comments

I need to fill background, including safe area - I'm doing it manually because we use material in real world, so it cannot be passed with options.

This bug reproduces only with some strict layout conditions - removing title, spacing or minHeight "solves" the problem

ZStack {}
    .presentation(
        transition: .sheet(
            options: .init(
                detents: [.ideal],
                options: .init()
            )
        ),
        isPresented: .constant(true)
    ) {
        ZStack {
            
        }
        .presentation(
            transition: .sheet(
                options: .init(
                    detents: [.ideal],
                    options: .init()
                )
            ),
            isPresented: .constant(true)
        ) {
            VStack(spacing: 12) {
                Text("title")
                Button {
                    
                } label: {
                    Text("buttonText")
                }
                .frame(minHeight: 30)
            }
            .background(Color.red.ignoresSafeArea(edges: .all))
        }
    }

You're missing making the content flexible. So the background modifier never proposes a view frame that would overlap with the safe area.

Add .frame(maxWidth: .infinity, maxHeight: .infinity) before the background modifier.

Or even better, use the preferredPresentationBackgroundColor option for the presentation transition and the color will be applied to the background of the presented UIViewController, guaranteeing it spans the entire background without needing to fuss with SwiftUI layout

options: .init(preferredPresentationBackgroundColor: .red)