An iOS library for SwiftUI to create draggable sheet experiences similar to iOS applications like Maps and Stocks.
The library currently supports;
Currently BottomSheet is only available through the Swift Package Manager or manual install.
Installation through Swift Package Manager can be done by going to File > Add Packages
. Then enter the following URL in the searchbar; github.com/Wouter125/BottomSheet
.
Manual installation can be done by cloning this repository and dragging all assets into your Xcode Project.
Import BottomSheet
Create a state property that contains the presentation state of the bottom sheet and one for the current selection;
@Published var isPresented = false
@Published var selectedDetent: BottomSheet.PresentationDetent = .medium
BottomSheetView
to your SwiftUI view hierachy by using a view modifier;.sheetPlus(
isPresented: $isPresented,
header: { },
main: {
EmptyView()
.presentationDetentsPlus(
[.height(244), .fraction(0.4), .medium, .large],
selection: $selectedDetent
)
}
)
BottomSheetView(
position: $position,
animationCurve: SheetAnimation(
mass: 1,
stiffness: 250,
damping: 25
),
background: (
Color(UIColor.secondarySystemBackground)
),
header: { },
content: {
EmptyView()
.onSheetDrag(translation: $settings.translation)
}
}
Modifier | Type | Default | Description |
---|---|---|---|
animationCurve.mass | Double | 1.2 | The mass of the object attached to the spring. |
animationCurve.stiffness | Double | 200 | The stiffness of the spring. |
animationCurve.damping | Double | 25 | The spring damping value. |
To give you an idea of how to use this library you can use the example that is attached to this repo. Simply clone it and open the BottomSheetExample
folder in Xcode.
link |
Stars: 131 |
Last commit: 6 weeks ago |
Stable release plus minor updates to the readme.
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics