It appears as if .sheet is now acting as .fullScreenCover within WatchOS 7.
Anyone else running into this? Wondering if this is now expected behavior on WatchOS or if it's a bug...
Code Block navigiationTitle{ button("Done"){ //Dismis the .sheet } }
Seems to continue in watchOS 8. I have filed feedback about this with the release of watchOS 7 already. (FB9055341)
EDIT: On Stackoverflow I found out that this issue is actually due to a SwiftUI change. The title of a sheet on watchOS is no longer an actual title, but a button in a toolbar. To change it you can overwrite the toolbar:
MySheet().toolbar {
ToolbarItem(placement: .cancellationAction) {
Button(title, action: action)
}
}
In the action you can use the environment value for presentationMode
to close the sheet.
The button will be clickable and it will replace the cancel title. So this is more a documentation and restructuring issue that almost no one caught.
The fix is actually much simpler (at least for me running watchOS 10). If you embed your sheet view in a navigation stack like this, there will be a little circular "X" button at the top left of your sheet.
MyMainView()
.sheet {
NavigationStack {
MySheetView()
}
}
As it turns out, the default cancel button is embedded in the toolbar, and the toolbar doesn't show up at all unless your view is embedded in a navigation stack