Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/totoroyyb/DrawerView-SwiftUI
A drawer view implemented by SwiftUI
https://github.com/totoroyyb/DrawerView-SwiftUI
drawerview ios ios-animation ios-lib ios-swift swiftui
Last synced: 3 months ago
JSON representation
A drawer view implemented by SwiftUI
- Host: GitHub
- URL: https://github.com/totoroyyb/DrawerView-SwiftUI
- Owner: totoroyyb
- License: mit
- Created: 2019-08-07T17:23:15.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-20T23:22:14.000Z (about 5 years ago)
- Last Synced: 2024-08-03T09:03:09.208Z (6 months ago)
- Topics: drawerview, ios, ios-animation, ios-lib, ios-swift, swiftui
- Language: Swift
- Homepage:
- Size: 3.87 MB
- Stars: 34
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- fucking-about-SwiftUI - DrawerView-SwiftUI
README
# DrawerView-SwiftUI
**A drawer view implemented by SwiftUI. This is not just simply a demo, instead, it can be directly used in project as a module as it has rudimentary customization flexibility.**
## To-Dos
- [ ] Fix the computed property error## Introduction & Demo
### Basic Functionality Demo
*A drawer with some bouncing animation*
### Further Step
#### Click Anywhere of the Background to Dismiss DrawerView
You can click anywhere of the darken background to dismiss the DrawerView
#### Drag to Dismiss DrawerView
* You can drag the draggable area to dismiss the DrawerView
* However, if the translation of drag action is shorter than you want, you can still restore the DrawerView.
* Actually, you can even drag it up if you want. You can modify this behavior in the code.
## Usage
The entire `DrawerView` is coded in the file with the same name as `DrawerView.swift`. The setup code written in `Content.swift` which demonstrates how to use `DrawerView.swift`.
*`DrawerView` takes one required argument `isShow` to open and dismiss itself. You need to create one in your main view and bind it to `DrawerView`*
* Use `DrawerView` as `overlay`
The code provided in the `Content.swift` uses `DrawerView` as a `overlay` of the main view.
``` swift
VStack {
// Create your own main view
}
.overlay(
DrawerView(isShow: $isShow, content: SampleInnerView())
)
```* Use `DrawerView` in `ZStack`
``` swift
ZStack {
VStack {
// Create your own main view
}
DrawerView(isShow: $isShow, content: SampleInnerView())
}
```
*In the above code, `content` is the inner view of `DrawerView`.*
*For example:*``` sw
// file: SampleInnerView.swift
struct SampleInnerView: View {
var body: some View {
Text("This is the inner view of DrawerView")
}
}
```## Customization
*All customizable properties have been provided in the `DrawerView.swift`. You can directly assign the preferred value to these variables when you initialize the `DrawerView`*
* `backLayerColor`
* `backLayerOpacity`
* `backLayerAnimation`
* `drawerOrientation`
* `drawerHeight`
* `drawerWidth`
* `drawerCornerRadius`
* `drawerBackgroundColor`
* `drawerOutAnimation`
* `isDrawerShadowEnable`
* `drawerShadowRadius`
*If you want to customize this property, you need to set `isDrawerShadowEnable` to `true` first. By default, the animation of shadow is suppressed, but you can change it in source file.*
* `content`
*This is property is required in the initializer. You can assign the view you want.*
* **To Be Continued**
## Contribution
This project is for demonstration purpose. Any contribution is welcome!
**Best Luck and Happy Coding!**