SkillAgentSearch skills...

DriftDrawer

Easy and Unique implementation for Android Navigation Drawer

Install / Use

/learn @arihant-001/DriftDrawer
About this skill

Quality Score

0/100

Category

Design

Supported Platforms

Universal

README

DriftDrawer

It is a library for custom Naviagation Drawer

Sample

Usage

Gradle

compile 'com.sdsmdg.aridj:driftdrawer:1.0.0'

Builder

  1. Create a list of icons for navigation items
  val icons = ArrayList<Int>()
  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)

  1. Build the drawer programmatically using DriftDrawerBuilder.
  DriftDrawerBuilder(context, toolbar)
    .withMenus(icons)
    .build()

ItemClickListener

  • Using lamdas
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
  DriftDrawerBuilder(context, toolbar)
    .withMenus(icons)
    .withItemClickListener(navItemListener)
    .build()

Builder Extras

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

View on GitHub
GitHub Stars16
CategoryDesign
Updated2y ago
Forks2

Languages

Kotlin

Security Score

80/100

Audited on Jul 8, 2023

No findings