Last active
May 28, 2024 09:45
-
-
Save mohanmanu484/b2ad7f7091528279987675b3047994aa to your computer and use it in GitHub Desktop.
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
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 | |
} | |
BuySellScreenArg::class -> { | |
BuySellScreenArg( | |
ppRefId = get<String>("ppRefId")!!, | |
isModifyFlow = get<Boolean>("isModifyFlow")!!, | |
orderId = get<String>("orderId") | |
) as T | |
} | |
else -> throw IllegalArgumentException("Invalid type requested") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment