From e7dcb857f6a90879f66e24fbb68f6d26751edb67 Mon Sep 17 00:00:00 2001 From: Antoine Robiez Date: Tue, 16 Apr 2024 12:48:24 +0200 Subject: [PATCH] Changed animation to match the iOS default one --- .../kotlin/com/androidmakers/ui/MainLayout.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/MainLayout.kt b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/MainLayout.kt index 653f605a..0a778f76 100644 --- a/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/MainLayout.kt +++ b/shared/ui/src/commonMain/kotlin/com/androidmakers/ui/MainLayout.kt @@ -1,5 +1,7 @@ package com.androidmakers.ui +import androidx.compose.animation.slideInHorizontally +import androidx.compose.animation.slideOutHorizontally import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.staticCompositionLocalOf @@ -17,6 +19,7 @@ import moe.tlaster.precompose.navigation.Navigator import moe.tlaster.precompose.navigation.SwipeProperties import moe.tlaster.precompose.navigation.path import moe.tlaster.precompose.navigation.rememberNavigator +import moe.tlaster.precompose.navigation.transition.NavTransition import org.koin.core.parameter.parametersOf /** @@ -80,7 +83,8 @@ private fun MainNavHost( scene( route = "${MainNavigationRoute.SESSION_DETAIL.name}/{sessionId}", swipeProperties = SwipeProperties(), - deepLinks = listOf("https://androidmakers.fr/session/{sessionId}") + deepLinks = listOf("https://androidmakers.fr/session/{sessionId}"), + navTransition = defaultTransition ) { val sessionId = it.path("sessionId") @@ -96,6 +100,7 @@ private fun MainNavHost( route = "${MainNavigationRoute.SPEAKER_DETAIL.name}/{speakerId}", deepLinks = listOf("https://androidmakers.fr/speaker/{speakerId}"), swipeProperties = SwipeProperties(), + navTransition = defaultTransition ) { backstackEntry -> val speakerId = backstackEntry.path("speakerId") @@ -109,6 +114,14 @@ private fun MainNavHost( } } +private val defaultTransition = NavTransition( + createTransition = slideInHorizontally { it }, + pauseTransition = slideOutHorizontally { -it / 4 }, + destroyTransition = slideOutHorizontally { it }, + resumeTransition = slideInHorizontally { -it / 4 }, + exitTargetContentZIndex = 1f +) + expect class PlatformContext val LocalPlatformContext = staticCompositionLocalOf { null }