Skip to content

Commit

Permalink
Update EunGabiNavHost variable name, content call method
Browse files Browse the repository at this point in the history
  • Loading branch information
easternkite committed Dec 11, 2024
1 parent e214b1e commit 967f847
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ internal fun EunGabiNavHostInternal(
builder: EunGabiGraphBuilder.() -> Unit
) {
val backStack by controller.backStack.collectAsState()
val entity = remember(backStack) { backStack.lastOrNull() }
val entry = remember(backStack) { backStack.lastOrNull() }
val updatedTransitionRunning by rememberUpdatedState(onTransitionRunning)

val currentTransition =
Expand Down Expand Up @@ -131,11 +131,11 @@ internal fun EunGabiNavHostInternal(
.build()
}

if (entity == null) return
if (entry == null) return

val transitionState =
remember {
SeekableTransitionState(entity)
SeekableTransitionState(entry)
}

val transition = rememberTransition(transitionState, label = "entity")
Expand All @@ -161,17 +161,17 @@ internal fun EunGabiNavHostInternal(
}

if (inPredictiveBack) {
LaunchedEffect(entity) {
println("entity changed: ${entity.eunGabiDestination.route}")
previousEntry = controller.findPreviousEntry(entity)
LaunchedEffect(entry) {
println("entity changed: ${entry.eunGabiDestination.route}")
previousEntry = controller.findPreviousEntry(entry)
}
LaunchedEffect(progress) {
previousEntry?.also { transitionState.seekTo(progress, it) }
}
} else {
LaunchedEffect(entity) {
if (transitionState.currentState != entity) {
transitionState.animateTo(entity)
LaunchedEffect(entry) {
if (transitionState.currentState != entry) {
transitionState.animateTo(entry)
} else {
val totalDuration = transition.totalDurationNanos / 1_000_000
animate(
Expand All @@ -186,7 +186,7 @@ internal fun EunGabiNavHostInternal(

if (value == 0f) {
transitionState.seekTo(0f)
transitionState.snapTo(entity)
transitionState.snapTo(entry)
}
}
}
Expand All @@ -204,12 +204,12 @@ internal fun EunGabiNavHostInternal(
.background(MaterialTheme.colorScheme.background),
contentKey = {
// Ordering-Based Keying Strategy to assume screen is currently pushing or popping.
if (it.index > entity.index) {
if (it.index > entry.index) {
// Case1 : targetState is Higher index than currentEntry. (assuming screen is currently pushing)
entity.id + it.id
entry.id + it.id
} else {
// Case2 : targetState is Lower than currentEntry. (assuming screen is currently popping)
it.id + entity.id
it.id + entry.id
}
},
transitionSpec = {
Expand All @@ -227,14 +227,13 @@ internal fun EunGabiNavHostInternal(
// Enable background dimming when the transition is running. This will apply to the previous screen.
// it currently supports only predictive back gesturing.
if (!inPredictiveBack) return@drawWithContent
if (targetState.index < entity.index || targetState.index < transition.currentState.index) {
if (targetState.index < entry.index || targetState.index < transition.currentState.index) {
drawRect(color = Color.Black.copy(dimAlpha))
}
},
) {
controller
.graph
.findDestination(targetState.eunGabiDestination.fullRoute)
targetState
.eunGabiDestination
.content(this@AnimatedContent, targetState)
}
}
Expand Down

0 comments on commit 967f847

Please sign in to comment.