-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
46 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 25 additions & 1 deletion
26
compose-destinations/src/main/java/com/ramcosta/composedestinations/spec/NavHostGraphSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,40 @@ | ||
package com.ramcosta.composedestinations.spec | ||
|
||
import android.os.Bundle | ||
import androidx.lifecycle.SavedStateHandle | ||
import com.ramcosta.composedestinations.animations.NavHostAnimatedDestinationStyle | ||
|
||
typealias NavHostGraphSpec = TypedNavHostGraphSpec<*> | ||
|
||
/** | ||
* Like [DirectionNavGraphSpec] but used specifically for top level navigation graphs (i.e they | ||
* have no parent graph) that are meant to pass to [com.ramcosta.composedestinations.DestinationsNavHost] call. | ||
*/ | ||
interface NavHostGraphSpec : DirectionNavGraphSpec { | ||
interface TypedNavHostGraphSpec<START_ROUTE_NAV_ARGS>: TypedNavGraphSpec<START_ROUTE_NAV_ARGS, START_ROUTE_NAV_ARGS> { | ||
|
||
override val baseRoute: String get() = route | ||
|
||
override fun invoke(navArgs: START_ROUTE_NAV_ARGS): Direction { | ||
//args cannot have mandatory args on start routes of NavHostGraphs, so this is ok | ||
return Direction(route) | ||
} | ||
|
||
/** | ||
* Like [TypedNavGraphSpec.defaultTransitions] but not nullable since NavHost level | ||
* graphs must have animations defined (even if they are defined as "No animations") | ||
*/ | ||
override val defaultTransitions: NavHostAnimatedDestinationStyle | ||
} | ||
|
||
interface DirectionNavHostGraphSpec : TypedNavHostGraphSpec<Unit>, Direction { | ||
|
||
override val baseRoute: String get() = route | ||
|
||
override fun invoke(navArgs: Unit): Direction = this | ||
|
||
operator fun invoke(): Direction = this | ||
|
||
override fun argsFrom(bundle: Bundle?) = Unit | ||
|
||
override fun argsFrom(savedStateHandle: SavedStateHandle) = Unit | ||
} |