mirror of
https://github.com/pawelorzech/Swoosh.git
synced 2026-03-31 20:15:41 +00:00
feat: add navigation transitions for all 8 routes
This commit is contained in:
parent
59238ff572
commit
4d78029f9d
1 changed files with 61 additions and 8 deletions
|
|
@ -16,6 +16,13 @@ import com.swoosh.microblog.ui.settings.SettingsScreen
|
|||
import com.swoosh.microblog.ui.setup.SetupScreen
|
||||
import com.swoosh.microblog.ui.stats.StatsScreen
|
||||
import com.swoosh.microblog.ui.theme.ThemeViewModel
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.slideInHorizontally
|
||||
import androidx.compose.animation.slideInVertically
|
||||
import androidx.compose.animation.slideOutHorizontally
|
||||
import androidx.compose.animation.slideOutVertically
|
||||
import androidx.compose.animation.core.tween
|
||||
|
||||
object Routes {
|
||||
const val SETUP = "setup"
|
||||
|
|
@ -42,7 +49,11 @@ fun SwooshNavGraph(
|
|||
val feedViewModel: FeedViewModel = viewModel()
|
||||
|
||||
NavHost(navController = navController, startDestination = startDestination) {
|
||||
composable(Routes.SETUP) {
|
||||
composable(
|
||||
Routes.SETUP,
|
||||
enterTransition = { fadeIn(tween(500)) },
|
||||
exitTransition = { fadeOut(tween(500)) }
|
||||
) {
|
||||
SetupScreen(
|
||||
onSetupComplete = {
|
||||
feedViewModel.refresh()
|
||||
|
|
@ -53,7 +64,13 @@ fun SwooshNavGraph(
|
|||
)
|
||||
}
|
||||
|
||||
composable(Routes.FEED) {
|
||||
composable(
|
||||
Routes.FEED,
|
||||
enterTransition = { fadeIn(tween(300)) },
|
||||
exitTransition = { fadeOut(tween(200)) },
|
||||
popEnterTransition = { fadeIn(tween(300)) },
|
||||
popExitTransition = { fadeOut(tween(200)) }
|
||||
) {
|
||||
FeedScreen(
|
||||
viewModel = feedViewModel,
|
||||
onSettingsClick = { navController.navigate(Routes.SETTINGS) },
|
||||
|
|
@ -75,7 +92,13 @@ fun SwooshNavGraph(
|
|||
)
|
||||
}
|
||||
|
||||
composable(Routes.COMPOSER) {
|
||||
composable(
|
||||
Routes.COMPOSER,
|
||||
enterTransition = { slideInVertically(initialOffsetY = { it }) + fadeIn() },
|
||||
exitTransition = { fadeOut(tween(200)) },
|
||||
popEnterTransition = { fadeIn(tween(300)) },
|
||||
popExitTransition = { slideOutVertically(targetOffsetY = { it }) + fadeOut() }
|
||||
) {
|
||||
val composerViewModel: ComposerViewModel = viewModel()
|
||||
ComposerScreen(
|
||||
editPost = editPost,
|
||||
|
|
@ -91,7 +114,13 @@ fun SwooshNavGraph(
|
|||
)
|
||||
}
|
||||
|
||||
composable(Routes.DETAIL) {
|
||||
composable(
|
||||
Routes.DETAIL,
|
||||
enterTransition = { slideInHorizontally(initialOffsetX = { it }) + fadeIn() },
|
||||
exitTransition = { fadeOut(tween(200)) },
|
||||
popEnterTransition = { fadeIn(tween(300)) },
|
||||
popExitTransition = { slideOutHorizontally(targetOffsetX = { it }) + fadeOut() }
|
||||
) {
|
||||
val post = selectedPost
|
||||
if (post != null) {
|
||||
DetailScreen(
|
||||
|
|
@ -118,7 +147,13 @@ fun SwooshNavGraph(
|
|||
}
|
||||
}
|
||||
|
||||
composable(Routes.SETTINGS) {
|
||||
composable(
|
||||
Routes.SETTINGS,
|
||||
enterTransition = { slideInHorizontally(initialOffsetX = { it }) },
|
||||
exitTransition = { fadeOut(tween(200)) },
|
||||
popEnterTransition = { fadeIn(tween(300)) },
|
||||
popExitTransition = { slideOutHorizontally(targetOffsetX = { it }) }
|
||||
) {
|
||||
SettingsScreen(
|
||||
themeViewModel = themeViewModel,
|
||||
onBack = {
|
||||
|
|
@ -137,20 +172,38 @@ fun SwooshNavGraph(
|
|||
)
|
||||
}
|
||||
|
||||
composable(Routes.STATS) {
|
||||
composable(
|
||||
Routes.STATS,
|
||||
enterTransition = { slideInHorizontally(initialOffsetX = { it }) },
|
||||
exitTransition = { fadeOut(tween(200)) },
|
||||
popEnterTransition = { fadeIn(tween(300)) },
|
||||
popExitTransition = { slideOutHorizontally(targetOffsetX = { it }) }
|
||||
) {
|
||||
StatsScreen(
|
||||
onBack = { navController.popBackStack() }
|
||||
)
|
||||
}
|
||||
|
||||
composable(Routes.PREVIEW) {
|
||||
composable(
|
||||
Routes.PREVIEW,
|
||||
enterTransition = { slideInVertically(initialOffsetY = { it }) + fadeIn() },
|
||||
exitTransition = { fadeOut(tween(200)) },
|
||||
popEnterTransition = { fadeIn(tween(300)) },
|
||||
popExitTransition = { slideOutVertically(targetOffsetY = { it }) + fadeOut() }
|
||||
) {
|
||||
PreviewScreen(
|
||||
html = previewHtml,
|
||||
onBack = { navController.popBackStack() }
|
||||
)
|
||||
}
|
||||
|
||||
composable(Routes.ADD_ACCOUNT) {
|
||||
composable(
|
||||
Routes.ADD_ACCOUNT,
|
||||
enterTransition = { slideInVertically(initialOffsetY = { it }) + fadeIn() },
|
||||
exitTransition = { fadeOut(tween(200)) },
|
||||
popEnterTransition = { fadeIn(tween(300)) },
|
||||
popExitTransition = { slideOutVertically(targetOffsetY = { it }) + fadeOut() }
|
||||
) {
|
||||
SetupScreen(
|
||||
onSetupComplete = {
|
||||
feedViewModel.refreshAccountsList()
|
||||
|
|
|
|||
Loading…
Reference in a new issue