lucaszischka / BottomSheet

A sliding Sheet from the bottom of the Screen with 3 States build with SwiftUI.
MIT License
1.03k stars 138 forks source link

Bottom sheet close does not work at certain conditions #103

Closed MADRAFi closed 1 year ago

MADRAFi commented 2 years ago

Describe the bug When Content View contains Large content ( for the whole view) or Spacer() the displayed Close circle does not dismiss the bottom sheet window

Minimal reproduce-able code

.bottomSheet( bottomSheetPosition: $bottomSheetPosition, switchablePositions: [.dynamic], headerContent: { VStack(alignment: .leading) { Text("chosenlocation") .font(.title) .bold() if bottomSheetPosition == .dynamicBottom { Text("50° 21°") .font(.subheadline) .foregroundColor(.secondary) }

                Divider()
                    .padding(.trailing, -30)
            }
            .padding([.top, .leading])
        },
        mainContent: { WaypointInfo() }

    )
    .onDismiss {
        bottomSheetPosition = .hidden
    }
    .showCloseButton(true)
    .enableTapToDismiss(true)

struct WaypointInfo: View {

var body: some View {
    VStack(alignment: .center) {
        HStack {
            Image("symbol")
                .resizable()
                .frame(width: 48, height: 48, alignment: .center)
                .padding()
            VStack {

                HStack {
                    Text("Longitude")
                    Spacer()
                    Text("50°")
                }
                HStack {
                    Text("Latitude")
                    Spacer()
                    Text("21°")
                }
                HStack {
                    Text("Elevation")
                    Spacer()
                    Text("100m")
                }
            }

        }
        HStack {
            Text("description")
                .multilineTextAlignment(.leading)
                .lineLimit(nil)
                .fixedSize(horizontal: false, vertical: true)

            Spacer()
        }
    }
    .padding()
    .padding(.bottom, 30)

// Bellow code will cause sheet to not be able to dismiss after pressing close button Spacer() } }

Expected behavior I expect that window can be dismissed regardless of the content.

Screenshots If applicable, add screenshots to help explain your problem.

Target version

Additional context Add any other context about the problem here.

lucaszischka commented 2 years ago

I will look into it soon.

lucaszischka commented 1 year ago

Hello @MADRAFi, I just tested it with your exact provided code and can not reproduce it. The sheet is dismissed as expected. Also no-one else seemed to have this issue. Therefore im closing it for now.