From 2dd3627c8dd8266572debc34df307ef2d94696d1 Mon Sep 17 00:00:00 2001 From: Isaac Udy Date: Mon, 16 Sep 2024 20:45:15 +1200 Subject: [PATCH] Add NavigationInstructionFilter for `acceptFromFlow` --- .../enro/core/container/NavigationInstructionFilter.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/enro-core/src/main/java/dev/enro/core/container/NavigationInstructionFilter.kt b/enro-core/src/main/java/dev/enro/core/container/NavigationInstructionFilter.kt index 92e8915d..92671ceb 100644 --- a/enro-core/src/main/java/dev/enro/core/container/NavigationInstructionFilter.kt +++ b/enro-core/src/main/java/dev/enro/core/container/NavigationInstructionFilter.kt @@ -3,6 +3,7 @@ package dev.enro.core.container import dev.enro.core.NavigationDirection import dev.enro.core.NavigationInstruction import dev.enro.core.NavigationKey +import dev.enro.core.result.flows.FlowStep /** * A NavigationContainerFilter is used to determine whether or not a given [NavigationInstruction.Open] @@ -75,6 +76,14 @@ public class NavigationContainerFilterBuilder internal constructor() { */ public fun acceptAll(): NavigationInstructionFilter = NavigationInstructionFilter { true } +/** + * A [NavigationInstructionFilter] that accepts only [NavigationInstruction.Open] instructions which have been added to the container + * by a [dev.enro.core.result.flows.NavigationFlow]. + */ +public fun acceptFromFlow(): NavigationInstructionFilter = NavigationInstructionFilter { + it.internal.resultKey is FlowStep<*> +} + /** * A [NavigationInstructionFilter] that accepts no [NavigationInstruction.Open] instructions. *