1

I would like to have a similar navigation structure to the built-in Workout app in watchOS. I have a list of tennis rules formats, analogous to workout types in the Workout app. Tapping one starts a match in a new interface controller. In WatchKit, as far as I know, I can only push an interface controller or present one. Both approaches risk the user canceling the match earlier from the top left chevron or tapping the status bar in a presented modally.

The workout does not have that limitation during a workout session, instead, the user ends the workout from switching pages in its page-based navigation. Does SwiftUI with its fully programmatic way of watchOS app development allow for accomplishing this?

Below is the initial view of the Workout app

enter image description here

Selecting a workout switches to a screen where the top left title isn't tappable, which is what I'd like to accomplish (the initial view is completely hidden and does not show when you swipe between the three pages)

enter image description here

Brian Nezhad
  • 6,148
  • 9
  • 44
  • 69
Curiosity
  • 544
  • 1
  • 15
  • 29

2 Answers2

4

Maybe you need to modify your view with:

    .navigationBarBackButtonHidden(true)

Did you try that?

Kristof Van Landschoot
  • 1,427
  • 1
  • 12
  • 30
1

I think you need to take a look at reloadRootPageControllers()

See https://developer.apple.com/documentation/watchkit/wkinterfacecontroller/2868441-reloadrootpagecontrollers

The basic idea appears to be that you are replacing the current interface controllers with the named ones listed in this method.

WKInterfaceController.reloadRootPageControllers(withNames: ["workout","nowPlaying"], contexts: [workoutToRecord], orientation: WKPageOrientation.horizontal, pageIndex: 0)

In my Interval Training app I call this method once a user has selected their workout. and this interface is then replaced with workout interface and now playing page.

Workout Select Page

You will note that there is no back button for them to accidentally return to the workout select screen.

Running Workout

Hope that helps.

Drew Westcott
  • 521
  • 4
  • 13