feat: animate between screens
This commit is contained in:
parent
b2e0001636
commit
f0a5446848
|
|
@ -68,6 +68,7 @@ dependencies {
|
|||
// Accompanist - Jetpack Compose Extensions
|
||||
implementation "com.google.accompanist:accompanist-systemuicontroller:$accompanist_version"
|
||||
implementation "com.google.accompanist:accompanist-permissions:$accompanist_version"
|
||||
implementation "com.google.accompanist:accompanist-navigation-animation:$accompanist_version"
|
||||
|
||||
// KTOR - HTTP+WebSocket Library
|
||||
implementation "io.ktor:ktor-client-core:$ktor_version"
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@ package chat.revolt
|
|||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import chat.revolt.screens.about.AboutScreen
|
||||
import chat.revolt.screens.about.AttributionScreen
|
||||
import chat.revolt.screens.about.PlaceholderScreen
|
||||
|
|
@ -18,6 +17,9 @@ import chat.revolt.screens.login.GreeterScreen
|
|||
import chat.revolt.screens.login.LoginScreen
|
||||
import chat.revolt.screens.login.MfaScreen
|
||||
import chat.revolt.ui.theme.RevoltTheme
|
||||
import com.google.accompanist.navigation.animation.AnimatedNavHost
|
||||
import com.google.accompanist.navigation.animation.rememberAnimatedNavController
|
||||
import com.google.accompanist.navigation.animation.composable
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
|
|
@ -35,13 +37,38 @@ class MainActivity : ComponentActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalAnimationApi::class)
|
||||
@Composable
|
||||
fun AppEntrypoint() {
|
||||
val navController = rememberNavController()
|
||||
val navController = rememberAnimatedNavController()
|
||||
|
||||
NavHost(
|
||||
AnimatedNavHost(
|
||||
navController = navController,
|
||||
startDestination = "setup/greeting"
|
||||
startDestination = "setup/greeting",
|
||||
enterTransition = {
|
||||
slideIntoContainer(
|
||||
AnimatedContentScope.SlideDirection.Left,
|
||||
animationSpec = tween(400)
|
||||
) + fadeIn(animationSpec = tween(400))
|
||||
},
|
||||
exitTransition = {
|
||||
slideOutOfContainer(
|
||||
AnimatedContentScope.SlideDirection.Left,
|
||||
animationSpec = tween(400)
|
||||
) + fadeOut(animationSpec = tween(400))
|
||||
},
|
||||
popEnterTransition = {
|
||||
slideIntoContainer(
|
||||
AnimatedContentScope.SlideDirection.Right,
|
||||
animationSpec = tween(400)
|
||||
) + fadeIn(animationSpec = tween(400))
|
||||
},
|
||||
popExitTransition = {
|
||||
slideOutOfContainer(
|
||||
AnimatedContentScope.SlideDirection.Right,
|
||||
animationSpec = tween(400)
|
||||
) + fadeOut(animationSpec = tween(400))
|
||||
}
|
||||
) {
|
||||
composable("setup/greeting") { GreeterScreen(navController) }
|
||||
composable("setup/login") { LoginScreen(navController) }
|
||||
|
|
|
|||
Loading…
Reference in New Issue