Skip to content

Group of functions that allow you to treat any ViewGroup as a custom navigation menu that works with the Android's Navigation Component

Notifications You must be signed in to change notification settings

mrmitew/ViewGroupNavigationView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

ViewGroupNavigationView

Group of functions that allow you to treat any ViewGroup as a custom navigation menu that works with the Android's Navigation Component.

Introduction

Since NavigationUi class only contains functions that support a small set of UI components in the Navigation, we need to create our own functions for our custom views in order to support navigation.

With the utility functions, provided in this repo, one can setup any ViewGroup to work with Android's Navigation Component. Every children in the given ViewGroup will be treated as a navigation menu item (similarly to NavigationView, with the exception that those items are not MenuItem-s, but regular views).

Ignore certain views

If you want to ignore particular views from being treated as navigation items (say you have a separtor view), you can tag them with "ignore".

How is this working?

We handle the click events for our custom UI component and use a Nav controller to navigate to the desired destination. In addition, we listen to the completion of the Navigation inside the addOnNavigatedListener and do the work required after the navigation is done, namely updating isSelected property of each View.

Note that, similarly to how NavigationView works with the Navigation Component, this library assumes that the View's id matches a valid action/destination id to be navigated to. If there is no match, nothing would happen.

Dependencies

This project is using the ViewGroup extensions provided by the android-ktx library.

Contribution

Yes, please :)

About

Group of functions that allow you to treat any ViewGroup as a custom navigation menu that works with the Android's Navigation Component

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages