Skip to content

Commit

Permalink
Merge pull request #22 from joncottrell/master
Browse files Browse the repository at this point in the history
🐛 Use EmptyView when geometry reader is still sized at 0
  • Loading branch information
weitieda authored Jul 29, 2022
2 parents 4e074d4 + 52e6c51 commit de09fed
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions Sources/BottomSheet/BottomSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,25 @@ public struct BottomSheet<Content: View>: View {

public var body: some View {
GeometryReader { geometry in
ZStack {
self.fullScreenLightGrayOverlay()
VStack(spacing: 0) {
self.topBar(geometry: geometry)
VStack(spacing: -8) {
Spacer()
self.content.padding(.bottom, geometry.safeAreaInsets.bottom)
Spacer()
if geometry.size != .zero {
ZStack {
self.fullScreenLightGrayOverlay()
VStack(spacing: 0) {
self.topBar(geometry: geometry)
VStack(spacing: -8) {
Spacer()
self.content.padding(.bottom, geometry.safeAreaInsets.bottom)
Spacer()
}
}
.frame(height: sheetHeight(in: geometry) - min(self.draggedOffset*2, 0))
.background(self.contentBackgroundColor)
.cornerRadius(self.topBarCornerRadius, corners: [.topLeft, .topRight])
.animation(.interactiveSpring())
.offset(y: self.isPresented ? (geometry.size.height/2 - sheetHeight(in: geometry)/2 + geometry.safeAreaInsets.bottom + self.draggedOffset) : (geometry.size.height/2 + sheetHeight(in: geometry)/2 + geometry.safeAreaInsets.bottom))
}
.frame(height: sheetHeight(in: geometry) - min(self.draggedOffset*2, 0))
.background(self.contentBackgroundColor)
.cornerRadius(self.topBarCornerRadius, corners: [.topLeft, .topRight])
.animation(.interactiveSpring())
.offset(y: self.isPresented ? (geometry.size.height/2 - sheetHeight(in: geometry)/2 + geometry.safeAreaInsets.bottom + self.draggedOffset) : (geometry.size.height/2 + sheetHeight(in: geometry)/2 + geometry.safeAreaInsets.bottom))
} else {
EmptyView()
}
}
}
Expand Down

0 comments on commit de09fed

Please sign in to comment.