Coder Social home page Coder Social logo

gamedevios / swiftui-bottom-sheet-drawer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from igor11191708/swiftui-bottom-sheet-drawer

0.0 0.0 0.0 25.44 MB

swiftui sheet, sliding sheet, swift botom sheet, ios bottom sheet BottomSheet macos Custom modal popup menu

License: MIT License

Swift 100.00%

swiftui-bottom-sheet-drawer's Introduction

Multiplatform (iOS, macOS) SwiftUI bottom sheet drawer

Features

  • It does not re-render 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 an 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 - Turn 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. Position BottomSheetPosition is passed with height of the sheet. height - is enum associated with value of type CGFloat

    @State private var position: BottomSheetPosition
    
        BottomSheet(
            content: SheetContentView(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

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

swiftui-bottom-sheet-drawer's People

Contributors

igor11191708 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.