Skip to content

Latest commit

 

History

History
57 lines (42 loc) · 1.38 KB

Examples.md

File metadata and controls

57 lines (42 loc) · 1.38 KB

Examples

Note: For full screen views, make sure that the surrounding ZStack uses .edgesIgnoringSafeArea(.vertical) to avoid whitespace at the bottom on iOS.

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
    }
}.edgesIgnoringSafeArea(.vertical)

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)

Example 2

A basic two-height drawer.

Drawer {
    Color.blue
}.rest(at: .constant([100, 340]))