|
|
|
@ -1,4 +1,7 @@
@@ -1,4 +1,7 @@
|
|
|
|
|
@file:OptIn(ExperimentalMaterial3Api::class) |
|
|
|
|
@file:OptIn( |
|
|
|
|
ExperimentalAnimationApi::class, |
|
|
|
|
ExperimentalMaterialNavigationApi::class |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
package io.element.android.x |
|
|
|
|
|
|
|
|
@ -6,14 +9,18 @@ import android.os.Bundle
@@ -6,14 +9,18 @@ import android.os.Bundle
|
|
|
|
|
import androidx.activity.ComponentActivity |
|
|
|
|
import androidx.activity.compose.setContent |
|
|
|
|
import androidx.activity.viewModels |
|
|
|
|
import androidx.compose.animation.AnimatedContentScope |
|
|
|
|
import androidx.compose.animation.ExperimentalAnimationApi |
|
|
|
|
import androidx.compose.animation.core.tween |
|
|
|
|
import androidx.compose.foundation.background |
|
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api |
|
|
|
|
import androidx.compose.material3.MaterialTheme |
|
|
|
|
import androidx.compose.runtime.Composable |
|
|
|
|
import androidx.compose.ui.Modifier |
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview |
|
|
|
|
import com.google.accompanist.navigation.material.ExperimentalMaterialNavigationApi |
|
|
|
|
import com.ramcosta.composedestinations.DestinationsNavHost |
|
|
|
|
import com.ramcosta.composedestinations.rememberNavHostEngine |
|
|
|
|
import com.ramcosta.composedestinations.animations.defaults.RootNavGraphDefaultAnimations |
|
|
|
|
import com.ramcosta.composedestinations.animations.rememberAnimatedNavHostEngine |
|
|
|
|
import com.ramcosta.composedestinations.spec.Route |
|
|
|
|
import io.element.android.x.core.compose.OnLifecycleEvent |
|
|
|
|
import io.element.android.x.designsystem.ElementXTheme |
|
|
|
@ -55,9 +62,37 @@ private fun MainScreen(viewModel: MainViewModel) {
@@ -55,9 +62,37 @@ private fun MainScreen(viewModel: MainViewModel) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private const val transitionAnimationDuration = 500 |
|
|
|
|
@Composable |
|
|
|
|
private fun MainContent(startRoute: Route) { |
|
|
|
|
val engine = rememberNavHostEngine() |
|
|
|
|
val engine = rememberAnimatedNavHostEngine( |
|
|
|
|
rootDefaultAnimations = RootNavGraphDefaultAnimations( |
|
|
|
|
enterTransition = { |
|
|
|
|
slideIntoContainer( |
|
|
|
|
AnimatedContentScope.SlideDirection.Left, |
|
|
|
|
animationSpec = tween(transitionAnimationDuration) |
|
|
|
|
) |
|
|
|
|
}, |
|
|
|
|
exitTransition = { |
|
|
|
|
slideOutOfContainer( |
|
|
|
|
AnimatedContentScope.SlideDirection.Left, |
|
|
|
|
animationSpec = tween(transitionAnimationDuration) |
|
|
|
|
) |
|
|
|
|
}, |
|
|
|
|
popEnterTransition = { |
|
|
|
|
slideIntoContainer( |
|
|
|
|
AnimatedContentScope.SlideDirection.Right, |
|
|
|
|
animationSpec = tween(transitionAnimationDuration) |
|
|
|
|
) |
|
|
|
|
}, |
|
|
|
|
popExitTransition = { |
|
|
|
|
slideOutOfContainer( |
|
|
|
|
AnimatedContentScope.SlideDirection.Right, |
|
|
|
|
animationSpec = tween(transitionAnimationDuration) |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
val navController = engine.rememberNavController() |
|
|
|
|
|
|
|
|
|
DestinationsNavHost( |
|
|
|
|