From f41ef19c884b8a9be20e95f1d68125881eeb27bd Mon Sep 17 00:00:00 2001 From: Alex Vanyo Date: Fri, 2 Jun 2023 18:03:55 -0700 Subject: [PATCH] Refine navigation impl --- .../navigation/BackstackNavigation.kt | 26 +++++++------------ .../MutableBackstackNavigationController.kt | 22 ++++++---------- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/navigation/src/commonMain/kotlin/com/alexvanyo/composelife/navigation/BackstackNavigation.kt b/navigation/src/commonMain/kotlin/com/alexvanyo/composelife/navigation/BackstackNavigation.kt index 4263e69e44..5ae3459755 100644 --- a/navigation/src/commonMain/kotlin/com/alexvanyo/composelife/navigation/BackstackNavigation.kt +++ b/navigation/src/commonMain/kotlin/com/alexvanyo/composelife/navigation/BackstackNavigation.kt @@ -59,14 +59,11 @@ fun MutableBackstackMap.popUpTo( currentEntryId: Uuid, id: Uuid, inclusive: Boolean = false, -): Uuid { - val predicate: (BackstackEntry) -> 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 @@ -81,14 +78,11 @@ fun MutableBackstackMap.popUpTo( currentEntryId: Uuid, predicate: (T) -> Boolean, inclusive: Boolean = false, -): Uuid { - val entryPredicate: (BackstackEntry) -> 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. diff --git a/navigation/src/commonMain/kotlin/com/alexvanyo/composelife/navigation/MutableBackstackNavigationController.kt b/navigation/src/commonMain/kotlin/com/alexvanyo/composelife/navigation/MutableBackstackNavigationController.kt index d413474e92..d3b5d09985 100644 --- a/navigation/src/commonMain/kotlin/com/alexvanyo/composelife/navigation/MutableBackstackNavigationController.kt +++ b/navigation/src/commonMain/kotlin/com/alexvanyo/composelife/navigation/MutableBackstackNavigationController.kt @@ -138,13 +138,10 @@ fun MutableBackstackNavigationController.popUpTo( fun MutableBackstackNavigationController.popUpTo( id: Uuid, inclusive: Boolean = false, -) { - val predicate: (BackstackEntry) -> 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 @@ -156,13 +153,10 @@ fun MutableBackstackNavigationController.popUpTo( fun MutableBackstackNavigationController.popUpTo( predicate: (T) -> Boolean, inclusive: Boolean = false, -) { - val entryPredicate: (BackstackEntry) -> Boolean = { predicate(it.value) } - popUpTo( - entryPredicate = entryPredicate, - inclusive = inclusive, - ) -} +) = popUpTo( + entryPredicate = { predicate(it.value) }, + inclusive = inclusive, +) /** * A navigation action which adds the destination.