Skip to content

Commit

Permalink
Refine navigation impl
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvanyo committed Dec 26, 2024
1 parent f243367 commit f41ef19
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ fun <T> MutableBackstackMap<T>.popUpTo(
currentEntryId: Uuid,
id: Uuid,
inclusive: Boolean = false,
): Uuid {
val predicate: (BackstackEntry<T>) -> Boolean = { it.id == id }
return popUpTo(
currentEntryId = currentEntryId,
entryPredicate = predicate,
inclusive = inclusive,
)
}
): Uuid = popUpTo(
currentEntryId = currentEntryId,
entryPredicate = { it.id == id },
inclusive = inclusive,
)

/**
* A navigation action on [MutableBackstackMap] that pops the backstack until the [predicate] is `true` for some
Expand All @@ -81,14 +78,11 @@ fun <T> MutableBackstackMap<T>.popUpTo(
currentEntryId: Uuid,
predicate: (T) -> Boolean,
inclusive: Boolean = false,
): Uuid {
val entryPredicate: (BackstackEntry<T>) -> Boolean = { predicate(it.value) }
return popUpTo(
currentEntryId = currentEntryId,
entryPredicate = entryPredicate,
inclusive = inclusive,
)
}
): Uuid = popUpTo(
currentEntryId = currentEntryId,
entryPredicate = { predicate(it.value) },
inclusive = inclusive,
)

/**
* A navigation action which adds the destination.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,10 @@ fun <T> MutableBackstackNavigationController<T>.popUpTo(
fun <T> MutableBackstackNavigationController<T>.popUpTo(
id: Uuid,
inclusive: Boolean = false,
) {
val predicate: (BackstackEntry<T>) -> Boolean = { it.id == id }
popUpTo(
entryPredicate = predicate,
inclusive = inclusive,
)
}
) = popUpTo(
entryPredicate = { it.id == id },
inclusive = inclusive,
)

/**
* A navigation action that pops the backstack until the [predicate] is `true` for some entry's value, starting at the
Expand All @@ -156,13 +153,10 @@ fun <T> MutableBackstackNavigationController<T>.popUpTo(
fun <T> MutableBackstackNavigationController<T>.popUpTo(
predicate: (T) -> Boolean,
inclusive: Boolean = false,
) {
val entryPredicate: (BackstackEntry<T>) -> Boolean = { predicate(it.value) }
popUpTo(
entryPredicate = entryPredicate,
inclusive = inclusive,
)
}
) = popUpTo(
entryPredicate = { predicate(it.value) },
inclusive = inclusive,
)

/**
* A navigation action which adds the destination.
Expand Down

0 comments on commit f41ef19

Please sign in to comment.