File tree Expand file tree Collapse file tree 1 file changed +28
-2
lines changed
Projects/DSKit/Sources/Components Expand file tree Collapse file tree 1 file changed +28
-2
lines changed Original file line number Diff line number Diff line change 88import SwiftUI
99
1010public struct PokitBottomSheet : View {
11+ @State
12+ private var height : CGFloat
1113 private let items : [ Item ]
12- private let height : CGFloat
1314 private let delegateSend : ( ( PokitBottomSheet . Delegate ) -> Void ) ?
1415
1516 public init (
1617 items: [ Item ] ,
17- height: CGFloat ,
18+ height: CGFloat = 0 ,
1819 delegateSend: ( ( PokitBottomSheet . Delegate ) -> Void ) ?
1920 ) {
2021 self . items = items
@@ -30,6 +31,16 @@ public struct PokitBottomSheet: View {
3031 . presentationDetents ( [ . height( height) ] )
3132 . pokitPresentationCornerRadius ( )
3233 . pokitPresentationBackground ( )
34+ . readHeight ( )
35+ . onPreferenceChange ( HeightPreferenceKey . self) { height in
36+ if let height {
37+ print ( " height: " , height)
38+ self . height = height
39+ }
40+ }
41+ . ignoresSafeArea ( . all)
42+ . padding ( . top, 12 )
43+ . padding ( . bottom, - 20 )
3344 }
3445
3546 @ViewBuilder
@@ -120,3 +131,18 @@ public extension PokitBottomSheet {
120131 }
121132}
122133
134+ @available ( iOS 18 . 0 , * )
135+ #Preview {
136+ @Previewable
137+ @State var isPresented : Bool = true
138+
139+ ZStack {
140+ Color . green. ignoresSafeArea ( )
141+ }
142+ . sheet ( isPresented: $isPresented) {
143+ PokitBottomSheet (
144+ items: [ . share, . edit, . delete] ,
145+ delegateSend: { _ in }
146+ )
147+ }
148+ }
You canโt perform that action at this time.
0 commit comments