Skip to content

Commit 9a77a4a

Browse files
committed
You can now check whether the navigation stack contains a specific view.
1 parent d2465f5 commit 9a77a4a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sources/NavigationStack/NavigationStack.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ public class NavigationStack: ObservableObject {
4545
viewStack.depth
4646
}
4747

48+
/// Returns a Boolean value indicating whether the stack contains a view with the specified ID.
49+
/// - Parameter id: The ID of the view to look for.
50+
/// - Returns: **true** if the stack contains a view with the specified ID; otherwise, **false**.
51+
public func containsView(withId id: String) -> Bool {
52+
viewStack.indexForView(withId: id) != nil
53+
}
54+
4855
/// Navigates to a view.
4956
/// - Parameters:
5057
/// - element: The destination view.

0 commit comments

Comments
 (0)