navex is extension for AndroidX Navigation.
This repository is not published to Maven. It may be released if there are many requests.
navex provides some extensions
| package | description | tested |
|---|---|---|
| navext-activity-request | launching activity navigator, call Activity.startActivityForResult | |
| navext-activity-result | pop activity navigator, call Activity.setResult & Activity.finish | |
| navext-fragment-styled | navigation graph based style navigator, extension for FragmentNavigator | ✅ |
| navext-fragment | hosting some navigator Fragment |
FragmentStyledNavigatior is extension for define different resource and transition on navigation graph.
- 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>- 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>- add fragment
styledNavNextId()andstyledNavArg()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() }
}- 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>This library is under MIT License
- using Kotlin Standard Library, published by Apache License 2.0
- using AndroidX, published by Apache License 2.0
- using AndroidX Test, published by Apache License 2.0
- using JUnit4, published by Eclipse Public License 1.0
- using Kotlin Standard Library, published by Apache License 2.0
- using AndroidX, published by Apache License 2.0
- using AndroidX Test, published by Apache License 2.0
- using JUnit4, published by Eclipse Public License 1.0
Author: @MeilCli