项目作者: fernandodelafuente

项目描述 :
A bottom sheet modal with SwiftUI
高级语言: Swift
项目地址: git://github.com/fernandodelafuente/BottomSheetModal.git
创建时间: 2019-10-31T13:18:22Z
项目社区:https://github.com/fernandodelafuente/BottomSheetModal

开源协议:MIT License

下载


BottomSheetModal

I’ve seen a lot of popular apps that are using this common UI pattern named Bottom Sheet: a card that slides up from the bottom and that is commonly used to show context related information or to perform actions (e.g. payment checkout process) making sure the user maintains the focus on the task at hand but still has some context.

This is a fully customizable and reusable Bottom Sheet Modal using SwiftUI. Demo:

Bottom sheet modal Demo

Usage

Use a state variable to show or hide modal

  1. struct ContentView: View {
  2. @State private var showBottomSheet = false
  3. var body: some View {
  4. ZStack {
  5. Button(action: {
  6. withAnimation {
  7. self.showBottomSheet.toggle()
  8. }
  9. }) {
  10. Text("Show modal")
  11. .font(.title)
  12. .bold()
  13. .foregroundColor(.black)
  14. }
  15. BottomSheetModal(display: $showBottomSheet) {
  16. Text("Show your content")
  17. .font(Font.system(.headline))
  18. .foregroundColor(Color.black)
  19. }
  20. }
  21. }
  22. }