Skip to content

Repository files navigation

NavigationExtensions

navex is extension for AndroidX Navigation.

This repository is not published to Maven. It may be released if there are many requests.

Summary

navex provides some extensions

packagedescriptiontested
navext-activity-requestlaunching activity navigator, call Activity.startActivityForResult
navext-activity-resultpop activity navigator, call Activity.setResult & Activity.finish
navext-fragment-stylednavigation graph based style navigator, extension for FragmentNavigator
navext-fragmenthosting some navigator Fragment

Usage

navext-fragment-styled

FragmentStyledNavigatior is extension for define different resource and transition on navigation graph.

  1. add attributes, res/values
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleablename="Screen">
<attrformat="string"name="title"/>
<attrformat="string"name="description"/>
</declare-styleable>
</resources>
  1. add style, res/values
<?xml version="1.0" encoding="utf-8"?>
<resources>
<stylename="Screen">
<itemname="title"/>
<itemname="description"/>
</style>
<stylename="Screen.Route1.First"parent="Screen">
<itemname="title">Route1 First</item>
<itemname="description">Rout1 First Description</item>
</style>
<stylename="Screen.Route1.Second"parent="Screen">
<itemname="title">Route1 Second</item>
<itemname="description">Rout1 Second Description</item>
</style>
</resources>
  1. add fragment
    styledNavNextId() and styledNavArg() value is injected on NavigationGraph
classScreenFragment : Fragment() {
privateval nextId by styledNavNextId()
privateval argumentTitle by styledNavArg(R.attr.title) { getString() }
privateval argumentDescription by styledNavArg(R.attr.description) { getString() }
}
  1. add navigation graph, res/navigation
<?xml version="1.0" encoding="utf-8"?>
<navigationandroid:id="@+id/navigation_main"app:startDestination="@id/startFragment"xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto">
<fragmentandroid:id="@+id/startFragment"android:name="navext.app.StartFragment">
<actionandroid:id="@+id/transitionToRoute1First"app:destination="@+id/route1First"/>
<actionandroid:id="@+id/transitionToRoute2First"app:destination="@id/route2First"/>
</fragment>
<fragment-styledandroid:id="@+id/route1First"android:name="navext.app.ScreenFragment"app:nextId="@id/transitionToRoute1Second"app:style="@style/Screen.Route1.First">
<actionandroid:id="@+id/transitionToRoute1Second"app:destination="@+id/route1Second"/>
</fragment-styled>
<fragment-styledandroid:id="@+id/route1Second"android:name="navext.app.ScreenFragment"app:nextId="@id/transitionToRoute1Third"app:style="@style/Screen.Route1.Second">
<actionandroid:id="@+id/transitionToRoute1Third"app:destination="@id/route1Third"/>
</fragment-styled>
<!-- etc... -->
</navigation>

License

This library is under MIT License

Extension

Sample

Other

Author: @MeilCli

About

navex is extension for AndroidX Navigation.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages