@@ -7,7 +7,6 @@ extension UIKitBackend {
77 public func createSheet( ) -> CustomSheet {
88 let sheet = CustomSheet ( )
99 sheet. modalPresentationStyle = . formSheet
10- //sheet.transitioningDelegate = CustomSheetTransitioningDelegate()
1110
1211 return sheet
1312 }
@@ -29,6 +28,59 @@ extension UIKitBackend {
2928 public func dismissSheet( _ sheet: CustomSheet , window: UIWindow ? ) {
3029 sheet. dismiss ( animated: true )
3130 }
31+
32+ public func setPresentationDetents( of sheet: CustomSheet , to detents: [ PresentationDetent ] ) {
33+ if #available( iOS 15 . 0 , * ) {
34+ if let sheetPresentation = sheet. sheetPresentationController {
35+ sheetPresentation. detents = detents. map {
36+ switch $0 {
37+ case . medium: return . medium( )
38+ case . large: return . large( )
39+ case . fraction( let fraction) :
40+ if #available( iOS 16 . 0 , * ) {
41+ return . custom(
42+ identifier: . init( " Fraction: \( fraction) " ) ,
43+ resolver: { context in
44+ context. maximumDetentValue * fraction
45+ } )
46+ } else {
47+ return . medium( )
48+ }
49+ case . height( let height) :
50+ if #available( iOS 16 . 0 , * ) {
51+ return . custom(
52+ identifier: . init( " Height: \( height) " ) ,
53+ resolver: { context in
54+ height
55+ } )
56+ } else {
57+ return . medium( )
58+ }
59+ }
60+ }
61+ }
62+ } else {
63+ #if DEBUG
64+ print (
65+ " your current OS Version doesn't support variable sheet heights. \n Setting presentationDetents is only available from iOS 15.0 "
66+ )
67+ #endif
68+ }
69+ }
70+
71+ public func setPresentationCornerRadius( of sheet: CustomSheet , to radius: Double ) {
72+ if #available( iOS 15 . 0 , * ) {
73+ if let sheetController = sheet. sheetPresentationController {
74+ sheetController. preferredCornerRadius = radius
75+ }
76+ } else {
77+ #if DEBUG
78+ print (
79+ " your current OS Version doesn't support variable sheet corner radii. \n Setting them is only available from iOS 15.0 "
80+ )
81+ #endif
82+ }
83+ }
3284}
3385
3486public final class CustomSheet : UIViewController {
0 commit comments