Building complex navigation stack in watchOS 10

I am having issues presenting one sheet on top of another.

Looking into the Mail app presents a long navigation stack. List of email accounts (1) > list of messages (2) > single message view (3) > text field and suggestions list (4)

1 and 2 use new main & detail navigation with nice circular back button. You can select any message (2), and then you can hit Reply in the bottom right corner. I assume this shows a sheet (3). From the sheet select any option, like Reply. That shows another sheet with a text field and suggestions depicted below. (4)

It looks like the whole navigation stack is preserved because dismissing the top sheet, shows the previous one. When I try to do the same in my app I see this nice warning message.

Currently, only presenting a single sheet is supported.
The next sheet will be presented when the currently presented sheet gets dismissed.

UIKit speaking, in watchOS you can only present views, except, main & detail navigation introduced in watchOS 10, you can't push views. It seems like the Mail app somehow does it. I am wondering if is it a private API.

I will explore 2 NavigationSplitView presented on top of each other and will report back.

Answered by borisy in 764076022

Quick update, will post full details later. I realised that I was using SwiftUI in the wrong way. My problem is that I had a view with multiple .sheet modifiers. If you present a second view, add the .sheet modifier to the second view. Essentially this should allow an unlimited navigation stack.

In case anyone wonders, I wasn't able to solve it. AFAIK there's no way to preserve the navigation stack. I ended up dismissing my first sheet before presenting a second sheet. Weirdly, I still see the warning. Luckily my UX doesn't suffer from this, it's just a warning that I am curious about. In case I would need to build an application with behaviour like Apple Mail, this would be a show stopper.

Accepted Answer

Quick update, will post full details later. I realised that I was using SwiftUI in the wrong way. My problem is that I had a view with multiple .sheet modifiers. If you present a second view, add the .sheet modifier to the second view. Essentially this should allow an unlimited navigation stack.

Building complex navigation stack in watchOS 10
 
 
Q