shaps80 / SwiftUIBackports

A collection of SwiftUI backports for iOS, macOS, tvOS and watchOS
MIT License
960 stars 60 forks source link

PresentationDetents and DragIndicatorVisibility are not applied after rotating the device #36

Closed mwocu closed 1 year ago

mwocu commented 1 year ago

Have you read the Contributing Guidelines?

Yes

General Information

Describe the bug

After rotating the device from portrait to landscape and back, the PresentationDetents and the visibility of the DragIndicator are not applied correctly anymore.

Minimal reproduction

struct SheetView: View {
    @State private var showSheet = false

    var body: some View {
        Button("Show Sheet") {
            showSheet = true
        }
        .sheet(isPresented: $showSheet) {
            Color.red.edgesIgnoringSafeArea(.all)
                .backport.presentationDetents([.medium])
                .backport.presentationDragIndicator(.visible)
        }
    }
}

Steps to reproduce

  1. Use the example code from above
  2. Start app in portrait mode
  3. Rotate to landscape and back to portrait
  4. The sheet is now showing in .large mode and the drag indicator is hidden

Expected behavior

The sheet should still show up in .medium mode and the drag indicator should still be visible

Bugfix branch

I already fixed the bug in this branch https://github.com/mwocu/SwiftUIBackports/tree/fix_sheet_presentation_after_device_rotation and could submit a PR, if wanted https://github.com/shaps80/SwiftUIBackports/compare/main...mwocu:SwiftUIBackports:fix_sheet_presentation_after_device_rotation

shaps80 commented 1 year ago

would love this in a PR 👍🏻

shaps80 commented 1 year ago

@mwocu this has now been released in 1.9.1