swiftui-bottom-sheet-drawer

main

Multiplatform (iOS, macOS) SwiftUI bottom sheet drawer. Expandable bottomsheet. Slide out bottom menu
The-Igor/swiftui-bottom-sheet-drawer

Multiplatform (iOS, macOS) SwiftUI bottom sheet drawer

Features

  • It does not rerender the background content while manipulating with the sheet
  • iOS and macOS support
  • dark and light scheme support
  • Observing sheet positions on change if you need to react on it
  • Responsive for any size change It's important for macOS while window size changing
  • Customize component with your own specs

Creation

Put the component into a absolute coordinate space like ZStack or GeometryReader and just pass a content that's it to start with sheet drawer.

        ZStack {
            BottomSheet(content: Color.clear.background(.thinMaterial))
        }

Builder

You can use builder methods to change some specs

  • hideDragButton - Hide drag button
  • withoutAnimation - Trun off animation
        ZStack {
            BottomSheet(content: Color.clear.background(.thinMaterial))
            .hideDragButton()
            .withoutAnimation()
        }

Optional

  • shift - Visible height of the sheet drawer

  • topIndentation - Space from the very top to the max height drawer can reach

  • draggerHeight - Space sensitive for dragging

  • dragThresholdToAct - Dragging length after which trigger move to the next level depending on the direction of moving

Observing sheet positions

Observe sheet positions on change if you need to react on it in the external context of the component. For example to update layout of the drawer content according a new size of the height. Possition BottomSheetPosision is passed with height of the sheet. height - is enum associated with value of type CGFloat

    @State private var position: BottomSheetPosision
    
        BottomSheet(
            content: SheetCintentView(position: $position)
        )
        .onPositionChanged{
            position = $0
        }
Position Description
up(CGFloat) At the top
middle(CGFloat) At the middle
down(CGFloat) At the bottom

SwiftUI example of using package

Folow the link to get the example exposed in the video:

click to watch expected UI behavior for the example

click to watch expected UI behavior for the example

Documentation(API)

  • You need to have Xcode 13 installed in order to have access to Documentation Compiler (DocC)
  • Go to Product > Build Documentation or โŒƒโ‡งโŒ˜ D

Description

  • Swift Tools 5.6.0
View More Packages from this Author

Dependencies

  • None
Last updated: Tue Aug 02 2022 13:34:29 GMT-0500 (GMT-05:00)