diff --git a/app/build.gradle.kts b/app/build.gradle.kts index c61d32fd..ac23d51d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -35,7 +35,6 @@ dependencies { implementation(Dependencies.AndroidX.Compose.foundationLayout) implementation(Dependencies.AndroidX.Compose.lifecycleViewModel) implementation(Dependencies.AndroidX.Compose.material) - implementation(Dependencies.AndroidX.Compose.navigation) implementation(Dependencies.AndroidX.Compose.paging) implementation(Dependencies.AndroidX.Compose.runtime) implementation(Dependencies.AndroidX.Compose.ui) diff --git a/app/src/androidTest/java/dev/msfjarvis/lobsters/BottomNavigationLayoutTest.kt b/app/src/androidTest/java/dev/msfjarvis/lobsters/BottomNavigationLayoutTest.kt deleted file mode 100644 index d5aa53e2..00000000 --- a/app/src/androidTest/java/dev/msfjarvis/lobsters/BottomNavigationLayoutTest.kt +++ /dev/null @@ -1,115 +0,0 @@ -package dev.msfjarvis.lobsters - -import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember -import androidx.compose.runtime.setValue -import androidx.compose.ui.test.assertContentDescriptionEquals -import androidx.compose.ui.test.assertCountEquals -import androidx.compose.ui.test.assertHasClickAction -import androidx.compose.ui.test.assertIsDisplayed -import androidx.compose.ui.test.assertIsNotSelected -import androidx.compose.ui.test.assertIsSelected -import androidx.compose.ui.test.assertTextEquals -import androidx.compose.ui.test.junit4.createComposeRule -import androidx.compose.ui.test.onChildAt -import androidx.compose.ui.test.onChildren -import androidx.compose.ui.test.onNodeWithTag -import androidx.compose.ui.test.performClick -import dev.msfjarvis.lobsters.ui.main.LobstersBottomNav -import dev.msfjarvis.lobsters.ui.navigation.Destination -import dev.msfjarvis.lobsters.ui.theme.LobstersTheme -import org.junit.Before -import org.junit.Rule -import org.junit.Test - - -class BottomNavigationLayoutTest { - - @get:Rule - val composeTestRule = createComposeRule() - - @Before - fun setUp() { - composeTestRule.setContent { - LobstersTheme { - var mutableDestination by remember { mutableStateOf(Destination.startDestination) } - - LobstersBottomNav( - currentDestination = mutableDestination, - navigateToDestination = { mutableDestination = it }, - jumpToIndex = {} - ) - } - } - } - - @Test - fun bottomNavItemCountTest() { - // Test to make sure total items are equal to enum objects present in Destination - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertExists() - .assertIsDisplayed() - .onChildren() - .assertCountEquals(Destination.values().size) - } - - @Test - fun bottomNavItemTest() { - // Check hottest BottomNavItem is rendered correctly - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertExists() - .assertIsDisplayed() - .onChildAt(0) - .assertTextEquals("Hottest") - .assertContentDescriptionEquals("Hottest") - .assertHasClickAction() - - // Check saved BottomNavItem is rendered correctly - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertExists() - .assertIsDisplayed() - .onChildAt(1) - .assertTextEquals("Saved") - .assertContentDescriptionEquals("Saved") - .assertHasClickAction() - } - - @Test - fun bottomNavItemSelectedTest() { - // Check hottest BottomNav item is selected - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertExists() - .assertIsDisplayed() - .onChildAt(0) - .assertIsSelected() - .assertTextEquals("Hottest") - - // Check saved BottomNav item is not selected - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertExists() - .assertIsDisplayed() - .onChildAt(1) - .assertIsNotSelected() - - // Select the saved BottomNav item - composeTestRule.onNodeWithTag("LobstersBottomNav") - .onChildAt(1) - .performClick() - - // Check hottest BottomNav item is not selected - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertExists() - .assertIsDisplayed() - .onChildAt(0) - .assertIsNotSelected() - - // Check saved BottomNav item is selected - composeTestRule.onNodeWithTag("LobstersBottomNav") - .assertExists() - .assertIsDisplayed() - .onChildAt(1) - .assertIsSelected() - .assertTextEquals("Saved") - } -} diff --git a/app/src/main/java/dev/msfjarvis/lobsters/ui/navigation/Destination.kt b/app/src/main/java/dev/msfjarvis/lobsters/ui/navigation/Destination.kt deleted file mode 100644 index 44d5708a..00000000 --- a/app/src/main/java/dev/msfjarvis/lobsters/ui/navigation/Destination.kt +++ /dev/null @@ -1,26 +0,0 @@ -package dev.msfjarvis.lobsters.ui.navigation - -import androidx.annotation.DrawableRes -import androidx.annotation.StringRes -import dev.msfjarvis.lobsters.R - -/** - * Destinations for navigation within the app. - */ -enum class Destination( - val route: String, - @StringRes val labelRes: Int, - @DrawableRes val badgeRes: Int, -) { - Hottest("hottest", R.string.hottest_posts, R.drawable.ic_whatshot_24px), - Saved("saved", R.string.saved_posts, R.drawable.ic_favorite_24px), - ; - - companion object { - val startDestination = Hottest - - fun getDestinationFromRoute(route: String): Destination { - return values().firstOrNull { it.route == route } ?: error("Incorrect route passed") - } - } -} diff --git a/buildSrc/src/main/java/Dependencies.kt b/buildSrc/src/main/java/Dependencies.kt index 39bdca41..129f3365 100644 --- a/buildSrc/src/main/java/Dependencies.kt +++ b/buildSrc/src/main/java/Dependencies.kt @@ -43,7 +43,6 @@ object Dependencies { const val foundationLayout = "androidx.compose.foundation:foundation-layout:$COMPOSE_VERSION" const val lifecycleViewModel = "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha01" const val material = "androidx.compose.material:material:$COMPOSE_VERSION" - const val navigation = "androidx.navigation:navigation-compose:1.0.0-alpha07" const val paging = "androidx.paging:paging-compose:1.0.0-alpha07" const val runtime = "androidx.compose.runtime:runtime:$COMPOSE_VERSION" const val ui = "androidx.compose.ui:ui:$COMPOSE_VERSION"