Skip to content

Instantly share code, notes, and snippets.

@mohanmanu484
Created May 28, 2024 09:35
Show Gist options
  • Save mohanmanu484/15a1ed58a1520c72f99b58918f90cad4 to your computer and use it in GitHub Desktop.
Save mohanmanu484/15a1ed58a1520c72f99b58918f90cad4 to your computer and use it in GitHub Desktop.
sealed interface Navigation {
fun getRoute(): String
class Login(val id: String) : Navigation {
override fun getRoute(): String {
return route.replace("{id}", id)
}
companion object : RouteProvider {
override val route: String
get() = "/login/{id}"
override val arguments: List<NamedNavArgument>
get() = listOf(navArgument("id") {
type = NavType.StringType
nullable = false
})
override val deeplink: List<NavDeepLink>
get() = listOf(navDeepLink {
uriPattern = "share.market://app/login/{id}"
}, navDeepLink {
uriPattern = "https://example.com/login/{id}"
})
}
}
class BuySellScreen(private val pprefId: String) : Navigation {
override fun getRoute(): String {
return route.replace("{pprefId}", pprefId)
}
companion object : RouteProvider {
override val route: String
get() = "orders/{pprefId}?isModifyFlow={isModifyFlow}&orderId={orderId}"
override val arguments: List<NamedNavArgument>
get() = listOf(
navArgument("pprefId") {
type = NavType.StringType
nullable = false
},
navArgument("isModifyFlow") {
type = NavType.BoolType
nullable = true
},
navArgument("orderId") {
type = NavType.StringType
nullable = true
}
)
override val deeplink: List<NavDeepLink>
get() = listOf(navDeepLink {
uriPattern =
"share.market://app/orders/{pprefId}?isModifyFlow={isModifyFlow}&orderId={orderId}"
})
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment