Skip to content

Commit a62b2b8

Browse files
committed
[fix] sheet height ์ˆ˜์ •
1 parent c42cd62 commit a62b2b8

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

โ€ŽProjects/DSKit/Sources/Components/PokitBottomSheet.swiftโ€Ž

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
import SwiftUI
99

1010
public 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+
}

0 commit comments

Comments
ย (0)