This file contains hidden or 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
@Composable | |
fun SampleNavHost() { | |
val navController = rememberNavController() | |
NavHost( | |
navController = navController, | |
startDestination = Navigation.Login.route | |
) { | |
composable(Navigation.Login) { | |
val id: LoginScreenArg = it.savedStateHandle.getArgs() | |
// Your composable code here |
This file contains hidden or 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
fun NavGraphBuilder.composable( | |
routeProvider: RouteProvider, | |
content: @Composable AnimatedContentScope.(NavBackStackEntry) -> Unit | |
) { | |
composable( | |
route = routeProvider.route, | |
arguments = routeProvider.arguments, | |
deepLinks = routeProvider.deeplink, | |
content = content | |
) |
This file contains hidden or 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
class LoginScreenArg(val id: String) | |
class BuySellScreenArg(val ppRefId: String, | |
val isModifyFlow: Boolean, | |
val orderId: String?) | |
inline fun <reified T> SavedStateHandle.getArgs(): T { | |
return when (T::class) { | |
LoginScreenArg::class -> { | |
LoginScreenArg(id = this.get<String>("id")!!) as T |
This file contains hidden or 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
interface LoginGraph { | |
@Route( | |
screenName = "LoginScreen", | |
route = "login/{id}", | |
deeplinks = [ | |
"share.market://app/login/{id}", | |
"https://example.com/login/{id}" | |
] | |
) | |
fun getLoginRoute( |
This file contains hidden or 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
@Route( | |
screenName = "LoginScreen", | |
route = "login/{id}", | |
deeplinks = [ | |
"share.market://app/login/{id}", | |
"https://example.com/login/{id}" | |
] | |
) | |
fun getLoginRoute(@Path("id") id: Int, @Query("isAdmin") isAdmin: Boolean = false) |
This file contains hidden or 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
@Route( | |
screenName = "BuySellScreen", | |
route = "orders/{pprefId}?isModifyFlow={isModifyFlow}&orderId={orderId}", | |
useRouteAsDefaultDeeplink = true | |
) | |
fun getBuySellRoute( | |
@Path("pprefId") id: String, | |
@Query("isModifyFlow") isModifyFlow: Boolean = false, | |
@Query("orderId") orderId: String? = null | |
) |
This file contains hidden or 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
@Target(AnnotationTarget.FUNCTION) | |
@Retention(AnnotationRetention.SOURCE) | |
annotation class Route( | |
val screenName: String, | |
val route: String, | |
val deeplinks: Array<String> = [], | |
val useRouteAsDefaultDeeplink: Boolean = false | |
) |
NewerOlder