Skip to content

Instantly share code, notes, and snippets.

@dilrajsingh1997
Created November 20, 2021 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dilrajsingh1997/66f95dcfef546e729a9b461eea670c37 to your computer and use it in GitHub Desktop.
Save dilrajsingh1997/66f95dcfef546e729a9b461eea670c37 to your computer and use it in GitHub Desktop.
class UserPageDestination {
data class UserPageArgs (
val userId: kotlin.String,
val isLoggedIn: kotlin.Boolean,
)
companion object {
fun parseArguments(backStackEntry: NavBackStackEntry): UserPageArgs {
return UserPageArgs(
userId = backStackEntry.arguments?.getString("userId") ?: "",
isLoggedIn = backStackEntry.arguments?.getBoolean("isLoggedIn") ?: false,
)
}
val argumentList: MutableList<NamedNavArgument>
get() = mutableListOf(
navArgument("userId") {
type = NavType.StringType
},
navArgument("isLoggedIn") {
type = NavType.BoolType
},
)
fun getDestination(userId: kotlin.String, isLoggedIn: kotlin.Boolean, ): String {
return "userPage?" +
"userId=$userId," +
"isLoggedIn=$isLoggedIn" +
""
}
val route = "userPage?userId={userId},isLoggedIn={isLoggedIn}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment