Skip to content

Instantly share code, notes, and snippets.

@dilrajsingh1997
Created November 20, 2021 13:21
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/fd5d714236df8bbe3b792257dc19cabc to your computer and use it in GitHub Desktop.
Save dilrajsingh1997/fd5d714236df8bbe3b792257dc19cabc to your computer and use it in GitHub Desktop.
class UserPageDestination {
data class UserPageArgs (
val userId: kotlin.String,
val isLoggedIn: kotlin.Boolean,
val userName: kotlin.String,
)
companion object {
fun parseArguments(backStackEntry: NavBackStackEntry): UserPageArgs {
return UserPageArgs(
userId = backStackEntry.arguments?.getString("userId") ?: "",
isLoggedIn = backStackEntry.arguments?.getBoolean("isLoggedIn") ?: false,
userName = backStackEntry.arguments?.getString("userName") ?: "",
)
}
val argumentList: MutableList<NamedNavArgument>
get() = mutableListOf(
navArgument("userId") {
type = NavType.StringType
},
navArgument("isLoggedIn") {
type = NavType.BoolType
},
navArgument("userName") {
type = NavType.StringType
},
)
fun getDestination(userId: kotlin.String, isLoggedIn: kotlin.Boolean, userName: kotlin.String, ): String {
return "userPage?" +
"userId=$userId," +
"isLoggedIn=$isLoggedIn," +
"userName=$userName" +
""
}
val route = "userPage?userId={userId},isLoggedIn={isLoggedIn},userName={userName}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment