diff --git a/app/src/main/java/com/paulrybitskyi/gamedge/AppNavigation.kt b/app/src/main/java/com/paulrybitskyi/gamedge/AppNavigation.kt index c729798d5..62759abb3 100644 --- a/app/src/main/java/com/paulrybitskyi/gamedge/AppNavigation.kt +++ b/app/src/main/java/com/paulrybitskyi/gamedge/AppNavigation.kt @@ -38,7 +38,6 @@ import com.paulrybitskyi.gamedge.feature.info.presentation.GameInfoRoute import com.paulrybitskyi.gamedge.feature.info.presentation.widgets.main.GameInfo import com.paulrybitskyi.gamedge.feature.likes.presentation.LikedGames import com.paulrybitskyi.gamedge.feature.likes.presentation.LikedGamesRoute -import com.paulrybitskyi.gamedge.feature.news.presentation.GamingNewsRoute import com.paulrybitskyi.gamedge.feature.news.presentation.widgets.GamingNews import com.paulrybitskyi.gamedge.feature.search.presentation.GamesSearch import com.paulrybitskyi.gamedge.feature.search.presentation.GamesSearchRoute @@ -63,10 +62,7 @@ internal fun AppNavigation( navController = navController, modifier = modifier, ) - newsScreen( - navController = navController, - modifier = modifier, - ) + newsScreen(modifier = modifier) settingsScreen(modifier = modifier) gamesSearchScreen(navController = navController) gamesCategoryScreen(navController = navController) @@ -152,34 +148,11 @@ private fun NavGraphBuilder.likesScreen( } } -private fun NavGraphBuilder.newsScreen( - navController: NavHostController, - modifier: Modifier, -) { +private fun NavGraphBuilder.newsScreen(modifier: Modifier) { composable( route = Screen.News.route, - enterTransition = { null }, - exitTransition = { - when (Screen.forRoute(targetState.destination.requireRoute())) { - Screen.GamesSearch -> OvershootScaling.exit() - else -> null - } - }, - popEnterTransition = { - when (Screen.forRoute(initialState.destination.requireRoute())) { - Screen.GamesSearch -> OvershootScaling.popEnter() - else -> null - } - }, - popExitTransition = { null }, ) { - GamingNews(modifier) { route -> - when (route) { - is GamingNewsRoute.Search -> { - navController.navigate(Screen.GamesSearch.route) - } - } - } + GamingNews(modifier) } } diff --git a/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsEffects.kt b/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsEffects.kt index 36c70c8ce..4c77c3c57 100644 --- a/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsEffects.kt +++ b/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsEffects.kt @@ -19,12 +19,7 @@ package com.paulrybitskyi.gamedge.feature.news.presentation import com.paulrybitskyi.gamedge.common.ui.base.events.Command -import com.paulrybitskyi.gamedge.common.ui.base.events.Route internal sealed class GamingNewsCommand : Command { data class OpenUrl(val url: String) : GamingNewsCommand() } - -sealed class GamingNewsRoute : Route { - object Search : GamingNewsRoute() -} diff --git a/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsViewModel.kt b/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsViewModel.kt index 5cfc01d8b..41c76cbaa 100644 --- a/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsViewModel.kt +++ b/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsViewModel.kt @@ -110,10 +110,6 @@ internal class GamingNewsViewModel @Inject constructor( .launchIn(viewModelScope) } - fun onSearchButtonClicked() { - route(GamingNewsRoute.Search) - } - fun onNewsItemClicked(model: GamingNewsItemUiModel) { dispatchCommand(GamingNewsCommand.OpenUrl(model.siteDetailUrl)) } diff --git a/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/widgets/GamingNews.kt b/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/widgets/GamingNews.kt index 2df7d5640..303c213d5 100644 --- a/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/widgets/GamingNews.kt +++ b/feature-news/src/main/java/com/paulrybitskyi/gamedge/feature/news/presentation/widgets/GamingNews.kt @@ -41,10 +41,8 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.hilt.navigation.compose.hiltViewModel import com.paulrybitskyi.commons.ktx.showShortToast import com.paulrybitskyi.gamedge.common.ui.CommandsHandler -import com.paulrybitskyi.gamedge.common.ui.RoutesHandler import com.paulrybitskyi.gamedge.common.ui.LocalUrlOpener import com.paulrybitskyi.gamedge.common.ui.NavBarColorHandler -import com.paulrybitskyi.gamedge.common.ui.base.events.Route import com.paulrybitskyi.gamedge.common.ui.theme.GamedgeTheme import com.paulrybitskyi.gamedge.common.ui.widgets.AnimatedContentContainer import com.paulrybitskyi.gamedge.common.ui.widgets.FiniteUiState @@ -57,14 +55,10 @@ import com.paulrybitskyi.gamedge.feature.news.R import com.paulrybitskyi.gamedge.feature.news.presentation.GamingNewsViewModel @Composable -fun GamingNews( - modifier: Modifier, - onRoute: (Route) -> Unit, -) { +fun GamingNews(modifier: Modifier) { GamingNews( viewModel = hiltViewModel(), modifier = modifier, - onRoute = onRoute, ) } @@ -72,7 +66,6 @@ fun GamingNews( private fun GamingNews( viewModel: GamingNewsViewModel, modifier: Modifier, - onRoute: (Route) -> Unit, ) { val urlOpener = LocalUrlOpener.current val context = LocalContext.current @@ -87,10 +80,8 @@ private fun GamingNews( } } } - RoutesHandler(viewModel = viewModel, onRoute = onRoute) GamingNews( uiState = viewModel.uiState.collectAsState().value, - onSearchButtonClicked = viewModel::onSearchButtonClicked, onNewsItemClicked = viewModel::onNewsItemClicked, onRefreshRequested = viewModel::onRefreshRequested, modifier = modifier, @@ -100,7 +91,6 @@ private fun GamingNews( @Composable private fun GamingNews( uiState: GamingNewsUiState, - onSearchButtonClicked: () -> Unit, onNewsItemClicked: (GamingNewsItemUiModel) -> Unit, onRefreshRequested: () -> Unit, modifier: Modifier = Modifier, @@ -113,8 +103,6 @@ private fun GamingNews( contentPadding = WindowInsets.statusBars .only(WindowInsetsSides.Vertical + WindowInsetsSides.Horizontal) .asPaddingValues(), - rightButtonIcon = painterResource(R.drawable.magnify), - onRightButtonClick = onSearchButtonClicked, ) }, ) { paddingValues -> @@ -227,7 +215,6 @@ private fun GamingNewsSuccessStatePreview() { uiState = GamingNewsUiState( news = news, ), - onSearchButtonClicked = {}, onNewsItemClicked = {}, onRefreshRequested = {}, ) @@ -241,7 +228,6 @@ private fun GamingNewsEmptyStatePreview() { GamedgeTheme { GamingNews( uiState = GamingNewsUiState(), - onSearchButtonClicked = {}, onNewsItemClicked = {}, onRefreshRequested = {}, ) @@ -255,7 +241,6 @@ private fun GamingNewsLoadingStatePreview() { GamedgeTheme { GamingNews( uiState = GamingNewsUiState(isLoading = true), - onSearchButtonClicked = {}, onNewsItemClicked = {}, onRefreshRequested = {}, ) diff --git a/feature-news/src/test/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsViewModelTest.kt b/feature-news/src/test/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsViewModelTest.kt index fdbae337d..d1f7544d0 100644 --- a/feature-news/src/test/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsViewModelTest.kt +++ b/feature-news/src/test/java/com/paulrybitskyi/gamedge/feature/news/presentation/GamingNewsViewModelTest.kt @@ -102,17 +102,6 @@ internal class GamingNewsViewModelTest { } } - @Test - fun `Routes to search screen when search button is clicked`() { - runTest { - SUT.routeFlow.test { - SUT.onSearchButtonClicked() - - assertThat(awaitItem()).isInstanceOf(GamingNewsRoute.Search::class.java) - } - } - } - @Test fun `Dispatches url opening command when clicking on news item`() { runTest {