Skip to content

Commit

Permalink
Adds a similar utility for popping
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpatrickmorgan committed Sep 30, 2022
1 parent 9026a14 commit c4f332f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Sources/FlowStacks/RoutableCollection+utilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ public extension RoutableCollection where Element: RouteProtocol {
mutating func popToRoot() {
popTo(index: 0)
}

/// Pops all screens in the current navigation stack only, without dismissing any screens.
mutating func popToCurrentNavigationRoot() {
var index = endIndex - 1
while indices.contains(index), !self[index].isPresented, index > 0 {
index -= 1
}
goBackTo(index: index)
}

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

0 comments on commit c4f332f

Please sign in to comment.