https://github.com/arihant-001/driftdrawer
Easy and Unique implementation for Android Navigation Drawer
https://github.com/arihant-001/driftdrawer
android custom design kotlin library navigation navigation-drawer popout
Last synced: 10 months ago
JSON representation
Easy and Unique implementation for Android Navigation Drawer
- Host: GitHub
- URL: https://github.com/arihant-001/driftdrawer
- Owner: arihant-001
- License: mit
- Created: 2018-05-04T16:35:02.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-17T22:36:40.000Z (about 8 years ago)
- Last Synced: 2025-04-07T07:21:16.322Z (about 1 year ago)
- Topics: android, custom, design, kotlin, library, navigation, navigation-drawer, popout
- Language: Kotlin
- Homepage:
- Size: 14.3 MB
- Stars: 16
- Watchers: 0
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DriftDrawer
It is a library for custom Naviagation Drawer

## Usage
### Gradle
```
compile 'com.sdsmdg.aridj:driftdrawer:1.0.0'
```
### Builder
1. Create a list of icons for navigation items
``` kotlin
val icons = ArrayList()
icons.add(R.drawable.ic_archive_black_24dp)
icons.add(R.drawable.ic_apps_black_24dp)
icons.add(R.drawable.ic_border_color_black_24dp)
icons.add(R.drawable.ic_build_black_24dp)
```
2. Build the drawer programmatically using `DriftDrawerBuilder`.
``` kotlin
DriftDrawerBuilder(context, toolbar)
.withMenus(icons)
.build()
```
### ItemClickListener
- Using lamdas
```kotlin
val navItemListener: (Int, View) -> Unit = { pos: Int, view: View ->
Toast.makeText(context, "Position: " + pos, Toast.LENGTH_SHORT).show()
}
```
- This itemClickListener can be easily pass in builder
``` kotlin
DriftDrawerBuilder(context, toolbar)
.withMenus(icons)
.withItemClickListener(navItemListener)
.build()
```
### Builder Extras
``` kotlin
val driftDrawer = DriftDrawerBuilder(this, toolbar)
.withMenus(icons)
.withDrawerClosed(false) // set initial state of drawer
.withSize(60) // set menu size in dp
.withColors(Color.parseColor("#E91E63"), Color.parseColor("#9C27B0")) // sets background and item highlight colors
.withItemClickListener(navItemListener) // sets item click listener
.build()
```
### DriftDrawer
`build` method of `DriftDrawerBuilder` returns `DriftDrawer`. This drawer can be used to control its behaviors.
Methods | Definition
------------ | -------------
isClosed | returns true if drawer is closed otherwise false
closeDrawer | close the drawer with/ without animation control by argument `animated`. Default value for `animated` is `true`
openDrawer | open the drawer with/ without animation control by argument `animated`. Default value for `animated` is `true`
setSelectedPosition | sets the position passed in argument as selected position
getLayout | returns the `DriftNavLayout` for drawer