Suppose we have a view in NavigationView stack. This view has a onDisappear handler. The system calls this handler when the view is being covered by another view in stack, and when our view is popped from the stack.
Is there a way to obtain a real reason - is it covered or is it popped?
OK, some code:
var body: some View {
NavigationView
{
NavigationLink(destination: DetailView())
{
Text("View details")
}
}
.onAppear
{
if <NavigationView was recently created?> // the essence of the question
{
print("NavigationView was recently created")
}
else
{
print("DetailView popped and disappeared")
}
}
}