Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions SwiftUIBottomSheet/Classes/BottomSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public struct BottomSheetConfig {
handleColor: Color = .init(.lightGray),
handlePosition: HandlePosition = .inside,
topBarCornerRadius: CGFloat? = nil,
sizeChangeRequest: Binding<CGFloat> = .constant(0)) {
sizeChangeRequest: Binding<CGFloat> = .constant(0),
animation: Animation = .interactiveSpring()) {
self.maxHeight = maxHeight
self.kind = kind
self.overlayColor = overlayColor
Expand All @@ -39,6 +40,7 @@ public struct BottomSheetConfig {
self.handlePosition = handlePosition
self.topBarCornerRadius = topBarCornerRadius
self.sizeChangeRequest = sizeChangeRequest
self.animation = animation
}

public enum Kind: Int, CaseIterable, Equatable {
Expand All @@ -63,6 +65,7 @@ public struct BottomSheetConfig {
public var handlePosition: HandlePosition
public var topBarCornerRadius: CGFloat?
public var sizeChangeRequest: Binding<CGFloat>
public var animation: Animation
}

public extension BottomSheetConfig {
Expand Down Expand Up @@ -245,12 +248,12 @@ private struct BottomSheetContainer<Content: View>: View {
}
}
.offset(y: offset)
.animation(shown ? .interactiveSpring() : nil, value: height)
.animation(.interactiveSpring(), value: dragEnded)
.animation(.interactiveSpring(), value: config.handlePosition)
.animation(shown ? config.animation : nil, value: height)
.animation(config.animation, value: dragEnded)
.animation(config.animation, value: config.handlePosition)
.transaction {
if dragStart != nil {
$0.animation = .interactiveSpring()
$0.animation = config.animation
}
}
}
Expand Down