Skip to content

Commit

Permalink
Use typesafe bottom sheet route
Browse files Browse the repository at this point in the history
  • Loading branch information
arkon committed Sep 8, 2024
1 parent 5398ef5 commit 35a8057
Showing 1 changed file with 3 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import androidx.navigation.plusAssign
import androidx.navigation.toRoute
import com.livetl.android.ui.screen.about.AboutScreen
Expand Down Expand Up @@ -53,19 +52,15 @@ fun mainNavHost(startRoute: Route): NavHostController {
) {
composable<Route.Home> {
HomeScreen(
navigateToStreamInfo = { navController.navigate("${Route.StreamInfo}?urlOrId=$it") },
navigateToStreamInfo = { navController.navigate(Route.StreamInfo(it)) },
navigateToPlayer = { navController.navigateToPlayer(it) },
navigateToSettings = { navController.navigate(Route.Settings) },
navigateToAbout = { navController.navigate(Route.About) },
)
}

// TODO: use typesafe data class when possible
bottomSheet(
"${Route.StreamInfo}?urlOrId={urlOrId}",
arguments = listOf(navArgument("urlOrId") { defaultValue = "" }),
) { backStackEntry ->
val urlOrId = backStackEntry.arguments?.getString("urlOrId")!!
bottomSheet<Route.StreamInfo> { backStackEntry ->
val urlOrId = backStackEntry.toRoute<Route.StreamInfo>().urlOrId

Surface {
StreamInfo(urlOrId)
Expand Down

0 comments on commit 35a8057

Please sign in to comment.