preview.mp4
This repo provides implementation of a Drawer that slides your menu from the left edge on top of a given content. Also, Example app provides a fully fledge side menu build on top of a Drawer. You can follow series of articles on our blog to get a hands-on experience of how it was build.
Platform | Min Deployment Target |
---|---|
iOS | 15.0 |
You can add Drawer to an Xcode project by adding it as a package dependency.
- From the File menu, select Add Packages...
- Enter "https://github.com/lanarsinc/swiftui-drawer" into the package repository URL text field.
- Then add
Drawer
directly to your application.
You can uses Drawer as a part of your hierarchy like that:
struct ContentView: View {
@State private var isOpened = true
var body: some View {
Drawer(
isOpened: $isOpened,
menu: {
ZStack {
Color.gray
Button("Hide") {
isOpened = false
}
}
.frame(width: 100)
},
content: {
ZStack {
Color.yellow
Button("Open") {
withAnimation {
isOpened = true
}
}
}
.ignoresSafeArea()
}
)
}
}
Also, you may want to control whether menu is being opened and to close it from the menu itself. For this, use an @Environment(.isDrawerOpened) wrapper to control status of a drawer.
- Interactive presentation and dismissal via drag.