Drawer

0.1.0

A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize.
maustinstar/swiftui-drawer

What's New

Landscape

2020-08-21T16:16:48Z

Landscape!

Check out the new .onLayoutForSizeClass modifier!

With .onLayoutForSizeClass you can update your state variables to layout your drawer for landscape.

Resting heights are now binding!

This means you can keep a state variable to contain your view heights. Instead of using the old .locked modifier, just change the resting heights parameter to a single height.

New Documentation Layout

The Readme is more concise, but it now contains links to other markdown files for Examples and Reference.

SwiftUI Drawer

A SwiftUI bottom-up controller, like in the Maps app. Drag to expand or minimize.

Contents

Package

For Xcode Projects

File > Swift Packages > Add Package Dependency: https://github.com/maustinstar/swiftui-drawer

For Swift Packages

Add a dependency in your your Package.swift

.package(url: "https://github.com/maustinstar/swiftui-drawer.git", from: "0.1.0"),

Basic Usage

Embed your view content in a ZStack with the Drawer as the last element. The heights parameter defines a list of resting heights for the drawer.

ZStack {

    ScrollView {
        //...
    }
    
    Drawer(heights: [100, 340]) {
        Color.blue
    }
}

See the full Reference Guide.

Examples

A multi-height drawer with haptic impact.

Drawer {
    ZStack {
        
        RoundedRectangle(cornerRadius: 12)
            .foregroundColor(.white)
            .shadow(radius: 100)
        
        VStack(alignment: .center) {
            Spacer().frame(height: 4.0)
            RoundedRectangle(cornerRadius: 3.0)
                .foregroundColor(.gray)
                .frame(width: 30.0, height: 6.0)
            Spacer()
        }
    }
}
.rest(at: .constant([100, 340, UIScreen.main.bounds.height - 40]))
.impact(.light)

See more Examples

🚀 Looking for more fun SwiftUI Packages?

Take your SwiftUI apps to the next level with these Packages!

Credits

Description

  • Swift Tools 5.2.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Dec 20 2024 02:19:42 GMT-1000 (Hawaii-Aleutian Standard Time)