Casey Brooks
11/16/2023, 3:49 PMjoney
11/16/2023, 5:53 PMMap<String, List<String>>
) between multiple platforms (ios/jvmAndroid).Casey Brooks
11/16/2023, 6:16 PMenum class AppScreens(
routeFormat: String,
override val annotations: Set<RouteAnnotation> = emptySet(),
) : Route {
Home("/app/home"),
PostList("/app/posts?sort={?}"),
PostDetails("/app/posts/{postId}"),
;
override val matcher: RouteMatcher = RouteMatcher.create(routeFormat)
companion object {
fun handleDeepLink(deepLinkUrl: String) {
val routingTable = RoutingTable.fromEnum(AppScreens.values())
val destination: Destination<AppScreens> = routingTable.findMatch(
UnmatchedDestination.parse(deepLinkUrl),
)
if (destination is Destination.Match<AppScreens>) {
when (destination.originalRoute) {
Home -> {
}
PostList -> {
val sort: String? by destination.optionalStringQuery()
// do something with the sort parameter in the PostList route query string, if it was provided
}
PostDetails -> {
val postId: Int by destination.intPath()
// do something with the postId in the PostDetails route path
}
}
}
}
}
}