nathantannar4 / Transmission

Bridges UIKit presentation APIs to a SwiftUI API so you can use presentation controllers, interactive transitions and more.
BSD 2-Clause "Simplified" License
378 stars 13 forks source link

GeometryReader in slide presentation doesn't ignore safe area #41

Closed PhilipDukhov closed 3 months ago

PhilipDukhov commented 3 months ago

In 1.1.5, the code below works as expected - geometry.size.height is equal to screen height, even when keyboard is presented.

But after updating to 1.2.0, when the keyboard is shown, geometry.size.height has a reduced value, as if there was no ignoresSafeArea modifier.

VStack {

}
.presentation(
    transition: .slide,
    isPresented: .constant(true)
) {
    GeometryReader { geometry in
        TextField("\(geometry.size.height)", text: .constant(""))
    }
    .ignoresSafeArea(.all, edges: .bottom)
}
nathantannar4 commented 3 months ago

hmm, it shouldn't spand the full height. .ignoresSafeArea(.all, edges: .bottom) is only ignoring the bottom safe area, so the height will be the screen height less the top safe area

struct Issue41: View {
    var body: some View {
        VStack {

        }
        .presentation(
            transition: .slide,
            isPresented: .constant(true)
        ) {
            GeometryReader { geometry in
                ZStack {
                    Color.red
                        .frame(height: geometry.size.height)

                    VStack {
                        Text(geometry.size.height.description)

                        Text(UIScreen.main.bounds.height.description)
                    }
                }
            }
            .ignoresSafeArea(.all, edges: .vertical) // note edges is .vertical
        }
    }
}

image

PhilipDukhov commented 3 months ago

hmm, it shouldn't spand the full height. .ignoresSafeArea(.all, edges: .bottom) is only ignoring the bottom safe area, so the height will be the screen height less the top safe area

I need to ignore keyboard height - it's part of bottom safe area, that's why I ignoring only .bottom. You need a text field to reproduce the issue.

In real life it's used by FB11502077_Fix_GeometryReader, but the code I provided is a minimal reproducible example of the issue.

nathantannar4 commented 3 months ago

Not able to repo on 1.1.5

https://github.com/nathantannar4/Transmission/assets/15272998/7975422e-a2cd-4ab9-8b71-33eaa80d615d

I am able to repo on 1.2.0 and 1.1.5 when using FB11502077_Fix_GeometryReader, but this is b/c FB11502077_Fix_GeometryReader always adds safe area equal to the keyboard height

PhilipDukhov commented 3 months ago

Not able to repo on 1.1.5

Yes, it works fine in 1.1.5 but not in 1.2.0

When keyboard appears the value stays 873 on 1.1.5 and updates to 527 on 1.2.0, am I missing something?

https://github.com/nathantannar4/Transmission/assets/6103621/3e3ad982-f7e1-48d4-b248-07468fbdee49

nathantannar4 commented 3 months ago

Ah sorry. My confusion was that I already seemed to have fixed this in 1.2.1 which I just hadn't released yet, so I wasn't seeing it. Fixed in 1.2.1!

PhilipDukhov commented 3 months ago

Ah sorry. My confusion was that I already seemed to have fixed this in 1.2.1 which I just hadn't released yet, so I wasn't seeing it. Fixed in 1.2.1!

Thank you!