Skip to content

Commit 7187734

Browse files
authored
feat(nav): slide in-tab pushes, keep crossfade on tab switches (#1217)
The v2 tab nav host crossfaded every transition. Now a forward move that lands on a tab home (Scanner/Wallet, via asNavBarTab) crossfades — a tab switch — while any other forward move slides in (a push into a detail screen) and pops slide back out. Overlays/sheets keep their no-transition. Also switch the wallet's OpenScreen navigation from openAsSheet to push so detail screens (e.g. Token Info) get the slide.
1 parent 692c704 commit 7187734

2 files changed

Lines changed: 29 additions & 15 deletions

File tree

  • apps/flipcash
    • app/src/main/kotlin/com/flipcash/app/internal/ui/navigation
    • features/balance/src/main/kotlin/com/flipcash/app/balance

‎apps/flipcash/app/src/main/kotlin/com/flipcash/app/internal/ui/navigation/AppContent.kt‎

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ import androidx.compose.animation.slideOutHorizontally
1010
import androidx.compose.animation.togetherWith
1111
import androidx.compose.runtime.Composable
1212
import androidx.compose.runtime.CompositionLocalProvider
13+
import androidx.navigation3.runtime.NavKey
1314
import androidx.navigation3.scene.OverlayScene
15+
import androidx.navigation3.scene.Scene
1416
import androidx.navigation3.scene.SinglePaneSceneStrategy
1517
import com.flipcash.app.core.AppRoute
1618
import com.flipcash.app.core.navigation.DeeplinkAction
19+
import com.flipcash.app.core.navigation.asNavBarTab
1720
import com.flipcash.app.core.navigation.LocalTabBarPadding
1821
import com.flipcash.app.internal.ui.AppNavigationBar
1922
import com.flipcash.app.internal.ui.navigation.decorators.rememberNavBlockingOverlayEntryDecorator
@@ -153,27 +156,38 @@ internal fun NewAppContent(
153156
},
154157
SinglePaneSceneStrategy(),
155158
),
156-
// v2 is tab-centric: switching tabs (replaceAll) crossfades. Sheets/overlays keep
157-
// their own (no) transition; everything else fades too.
159+
// v2 is tab-centric: a forward move that LANDS on a tab home is a tab switch
160+
// (replaceAll between tab homes) and crossfades; any other forward move is a push
161+
// into a detail screen and slides in. Pops always slide back out (a pop is always
162+
// leaving a detail). Sheets/overlays keep their own (no) transition.
158163
transitionSpec = {
159-
if (targetState is OverlayScene<*> || initialState is OverlayScene<*>) {
160-
EnterTransition.None togetherWith ExitTransition.None
161-
} else {
162-
fadeIn(tween(300)) togetherWith fadeOut(tween(300))
164+
val landsOnTab = (codeNavigator.currentRouteKey as? AppRoute)?.asNavBarTab() != null
165+
when {
166+
targetState is OverlayScene<*> || initialState is OverlayScene<*> ->
167+
EnterTransition.None togetherWith ExitTransition.None
168+
landsOnTab ->
169+
fadeIn(tween(300)) togetherWith fadeOut(tween(300))
170+
else ->
171+
slideInHorizontally(initialOffsetX = { it }) togetherWith
172+
slideOutHorizontally(targetOffsetX = { -it })
163173
}
164174
},
165175
popTransitionSpec = {
166-
if (targetState is OverlayScene<*> || initialState is OverlayScene<*>) {
167-
EnterTransition.None togetherWith ExitTransition.None
168-
} else {
169-
fadeIn(tween(300)) togetherWith fadeOut(tween(300))
176+
when {
177+
targetState is OverlayScene<*> || initialState is OverlayScene<*> ->
178+
EnterTransition.None togetherWith ExitTransition.None
179+
else ->
180+
slideInHorizontally(initialOffsetX = { -it }) togetherWith
181+
slideOutHorizontally(targetOffsetX = { it })
170182
}
171183
},
172184
predictivePopTransitionSpec = {
173-
if (targetState is OverlayScene<*> || initialState is OverlayScene<*>) {
174-
EnterTransition.None togetherWith ExitTransition.None
175-
} else {
176-
fadeIn(tween(300)) togetherWith fadeOut(tween(300))
185+
when {
186+
targetState is OverlayScene<*> || initialState is OverlayScene<*> ->
187+
EnterTransition.None togetherWith ExitTransition.None
188+
else ->
189+
slideInHorizontally(initialOffsetX = { -it }) togetherWith
190+
slideOutHorizontally(targetOffsetX = { it })
177191
}
178192
},
179193
onBack = { codeNavigator.navigateBack() },

‎apps/flipcash/features/balance/src/main/kotlin/com/flipcash/app/balance/WalletScreen.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fun WalletScreen() {
5050
viewModel.eventFlow
5151
.filterIsInstance<WalletViewModel.Event.OpenScreen>()
5252
.map { it.screen }
53-
.onEach { navigator.openAsSheet(it) }
53+
.onEach { navigator.push(it) }
5454
.launchIn(this)
5555
}
5656
}

0 commit comments

Comments
 (0)