Skip to content

Commit c4f332f

Browse files
Adds a similar utility for popping
1 parent 9026a14 commit c4f332f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Sources/FlowStacks/RoutableCollection+utilities.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ public extension RoutableCollection where Element: RouteProtocol {
186186
mutating func popToRoot() {
187187
popTo(index: 0)
188188
}
189+
190+
/// Pops all screens in the current navigation stack only, without dismissing any screens.
191+
mutating func popToCurrentNavigationRoot() {
192+
var index = endIndex - 1
193+
while indices.contains(index), !self[index].isPresented, index > 0 {
194+
index -= 1
195+
}
196+
goBackTo(index: index)
197+
}
189198

190199
/// Pops to the topmost (most recently pushed) screen in the stack
191200
/// that satisfies the given condition. If no screens satisfy the condition,

0 commit comments

Comments
 (0)