From 8c1b9cf1916826e54cca28970663961a3507b6a2 Mon Sep 17 00:00:00 2001 From: Abe White Date: Tue, 24 Jun 2025 22:55:08 -0500 Subject: [PATCH 1/2] Change navigation transitions --- Sources/SkipUI/SkipUI/Containers/Navigation.swift | 14 ++++++++------ Sources/SkipUI/SkipUI/Containers/TabView.swift | 8 ++++---- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Sources/SkipUI/SkipUI/Containers/Navigation.swift b/Sources/SkipUI/SkipUI/Containers/Navigation.swift index cceea4c..f02c536 100644 --- a/Sources/SkipUI/SkipUI/Containers/Navigation.swift +++ b/Sources/SkipUI/SkipUI/Containers/Navigation.swift @@ -4,6 +4,8 @@ import Foundation #if SKIP import androidx.activity.compose.BackHandler +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut import androidx.compose.animation.slideInHorizontally import androidx.compose.animation.slideOutHorizontally import androidx.compose.foundation.background @@ -151,8 +153,8 @@ public struct NavigationStack : View { let isRTL = EnvironmentValues.shared.layoutDirection == LayoutDirection.rightToLeft NavHost(navController: navController, startDestination: Navigator.rootRoute, modifier: modifier) { composable(route: Navigator.rootRoute, - exitTransition: { slideOutHorizontally(targetOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }, - popEnterTransition: { slideInHorizontally(initialOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }) { entry in + exitTransition: { fadeOut() + slideOutHorizontally(targetOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }, + popEnterTransition: { fadeIn() + slideInHorizontally(initialOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }) { entry in guard let state = navigator.value.state(for: entry) else { return } @@ -174,10 +176,10 @@ public struct NavigationStack : View { for destinationIndex in 0.. Date: Wed, 25 Jun 2025 13:30:25 -0500 Subject: [PATCH 2/2] Make exit fade-out faster --- Sources/SkipUI/SkipUI/Containers/Navigation.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/SkipUI/SkipUI/Containers/Navigation.swift b/Sources/SkipUI/SkipUI/Containers/Navigation.swift index f02c536..01fab7c 100644 --- a/Sources/SkipUI/SkipUI/Containers/Navigation.swift +++ b/Sources/SkipUI/SkipUI/Containers/Navigation.swift @@ -8,6 +8,7 @@ import androidx.compose.animation.fadeIn import androidx.compose.animation.fadeOut import androidx.compose.animation.slideInHorizontally import androidx.compose.animation.slideOutHorizontally +import androidx.compose.animation.core.tween import androidx.compose.foundation.background import androidx.compose.foundation.clickable import androidx.compose.foundation.interaction.MutableInteractionSource @@ -153,7 +154,7 @@ public struct NavigationStack : View { let isRTL = EnvironmentValues.shared.layoutDirection == LayoutDirection.rightToLeft NavHost(navController: navController, startDestination: Navigator.rootRoute, modifier: modifier) { composable(route: Navigator.rootRoute, - exitTransition: { fadeOut() + slideOutHorizontally(targetOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }, + exitTransition: { fadeOut(animationSpec: tween(durationMillis: 200)) + slideOutHorizontally(targetOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }, popEnterTransition: { fadeIn() + slideInHorizontally(initialOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }) { entry in guard let state = navigator.value.state(for: entry) else { return @@ -177,9 +178,9 @@ public struct NavigationStack : View { composable(route: Navigator.route(for: destinationIndex, valueString: "{identifier}"), arguments: listOf(navArgument("identifier") { type = NavType.StringType }), enterTransition: { fadeIn() + slideInHorizontally(initialOffsetX: { $0 * (isRTL ? -1 : 1) / 3 }) }, - exitTransition: { fadeOut() + slideOutHorizontally(targetOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }, + exitTransition: { fadeOut(animationSpec: tween(durationMillis: 200)) + slideOutHorizontally(targetOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }, popEnterTransition: { fadeIn() + slideInHorizontally(initialOffsetX: { $0 * (isRTL ? 1 : -1) / 3 }) }, - popExitTransition: { fadeOut() + slideOutHorizontally(targetOffsetX: { $0 * (isRTL ? -1 : 1) / 3 }) }) { entry in + popExitTransition: { fadeOut(animationSpec: tween(durationMillis: 200)) + slideOutHorizontally(targetOffsetX: { $0 * (isRTL ? -1 : 1) / 3 }) }) { entry in guard let state = navigator.value.state(for: entry), let targetValue = state.targetValue else { return }