Skip to content

Instantly share code, notes, and snippets.

@dilrajsingh1997
Created Nov 20, 2021
Embed
What would you like to do?
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