             guard parent.isPresented else { return }
             parent.isPresented = false
             parent.onDismiss?()
+        }
+    }
+}
+
+/// A type that represents a height where a sheet naturally rests.
+public enum BottomSheetDetents {
+    case medium
+    case large
+
+    var iOS15: UISheetPresentationController.Detent {
+        switch self {
+        case .medium:
+            return .medium()
+        case .large:
+            return .large()
+        }
+    }
+
+    @available(iOS 16, *)
+    var iOS16: PresentationDetent {
+        switch self {
+        case .medium:
+            return .medium
+        case .large:
+            return .large
         }
     }
 }

    ///   - isPresented: A binding to a `Boolean` value that determines whether to present
    ///                  the sheet that you create in the modifier's `content` closure.
    ///   - detents: An object that represents a height where a sheet naturally rests.
    ///   - prefersGrabberVisible: A Boolean value that determines whether the sheet shows a grabber at the top.
    ///   - preferredCornerRadius: The corner radius that the sheet attempts to present with.
    ///   - onDismiss: The closure to execute when dismissing the sheet.
    ///   - content: A closure that returns the content of the sheet.
    @ViewBuilder
    func bottomSheet<Content: View>(
        isPresented: Binding<Bool>,
        detents: [UISheetPresentationController.Detent] = [.medium(), .large()],
        prefersGrabberVisible: Bool = true,
        preferredCornerRadius: CGFloat? = nil,
        onDismiss: (() -> Void)? = nil,
        @ViewBuilder content: @escaping () -> Content
    ) -> some View {
        background(
            BottomSheet(
                isPresented: isPresented,
                detents: detents,
                prefersGrabberVisible: prefersGrabberVisible,
                preferredCornerRadius: preferredCornerRadius,
                content: content,
                onDismiss: onDismiss
            )
        )
    }
}


                }
            ),
            detents: detents,
            prefersDragIndicator: prefersDragIndicator,
            onDismiss: onDismiss,
            content: { item.wrappedValue.map(content) }
        )
