edudnyk / SheeKit

Customize and resize sheets in SwiftUI with SheeKit. Utilise the power of `UISheetPresentationController` and other UIKit features.
MIT License
91 stars 7 forks source link

Popover presented from a button in nav bar messes with geometry of content view (iPad) #8

Closed markkrenek closed 2 years ago

markkrenek commented 2 years ago

I'm using a popover presented from a button in a nav bar. It works fine, but there's an issue on iPad. After the popover is presented, if you resize the app, the content view no longer resizes accordingly. I made a few simple changes to the example app that demonstrates this. Here is a screenshot and movie that shows the issue. Also attached is a modified RootView.swift with my changes. They are marked with "// MAK".

Simulator Screen Shot - iPad

https://user-images.githubusercontent.com/73647/153730364-536b29b3-bd94-444a-bbff-1038a29b80f5.mov

RootView.txt

edudnyk commented 2 years ago

Hey @markkrenek, thanks for well-described bug report.

I was able to reproduce the issue, however, I believe this is the system SwiftUI issue. You can see on the screenshot below that it's not just ContentView that is incorrectly resized, it's the whole UIHostingView and its view controller. Which makes me think that SwiftUI.NavigationView somehow incorrectly handles window scene resizing in this case. You can submit bug report to apple and let's see what they answer.

Screenshot 2022-02-13 at 09 42 41
edudnyk commented 2 years ago

After further investigation, it appears that the issue is with the view controller being added as a child of the navigation controller.

Please find a fix in version 2.0.1.

markkrenek commented 2 years ago

Excellent! This indeed solves the issue. I've tried multiple libs like this but all get it wrong when presenting from a nav bar. Detached view controller complaints from the runtime. My main goal was to use a popover and have it convert to a half size sheet in compact environments - the standard popover always uses a fullscreen sheet in this case. Being able to set adaptiveSheetProperties for the popover is perfect. Thanks for the solution.