Skip to content

Commit

Permalink
Add navigation transitions on Android
Browse files Browse the repository at this point in the history
  • Loading branch information
prof18 committed Sep 1, 2023
1 parent 40e76ed commit fbda070
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
12 changes: 11 additions & 1 deletion androidApp/src/main/kotlin/com/prof18/feedflow/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import FeedFlowTheme
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.animation.AnimatedContentTransitionScope.SlideDirection
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
Expand Down Expand Up @@ -57,7 +60,14 @@ class MainActivity : ComponentActivity() {
@Suppress("LongMethod")
@Composable
private fun FeedFlowNavigation(navController: NavHostController) {
NavHost(navController = navController, startDestination = Screen.Home.name) {
NavHost(
navController = navController,
startDestination = Screen.Home.name,
enterTransition = { fadeIn() + slideIntoContainer(SlideDirection.Start) },
exitTransition = { fadeOut() + slideOutOfContainer(SlideDirection.Start) },
popEnterTransition = { fadeIn() + slideIntoContainer(SlideDirection.End) },
popExitTransition = { fadeOut() + slideOutOfContainer(SlideDirection.End) },
) {
composable(Screen.Home.name) {
HomeScreen(
onSettingsButtonClicked = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ internal fun HomeAppBar(
},
onMarkAllReadClicked = onMarkAllReadClicked,
onClearOldArticlesClicked = onClearOldArticlesClicked,
onSettingsButtonClicked = onSettingsButtonClicked,
onSettingsButtonClicked = {
showMenu = false
onSettingsButtonClicked()
},
onForceRefreshClick = onForceRefreshClick,
)
},
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ koin = "3.4.2"
koin-android = "3.4.2"
koin-compose = "3.4.5"
kotlin = "1.9.0"
nav-compose = "2.6.0"
nav-compose = "2.7.1"
turbine = "1.0.0"
versions-ben-manes = "0.44.0"
viewModel-ktx = "2.6.1"
Expand Down

0 comments on commit fbda070

Please sign in to comment.