@mikaelacaron turns out it is not too difficult to add a companion watchOS app to a normal iOS app! It can use the same ViewModel as the main app, plus re-use some of its views/ notifications. Maybe Chris’s Recipe app, or Video app would make for good iOS companion apps as well. One thing, I like about the Apple Watch is as you watch a video, or listen to music it shows you the typical player information, song/ video title, fast-forward/ go-backwards and pause types of interactions.
Some of the things that Apple does differently versus some of the CWC+ videos is to ensure that each View’s preview works. So it was kind of refreshing to see the screen pop-up with a rendering as soon as you type.
Also, I like how the tutorial has you test against the smallest and largest screen sizes. Chris touched on this a few times in the Foundations course, but I’d like to learn how to make Views work on the various screen sizes better. I hope the Design course goes over this.
I also liked how Apple would show previews for two scenarios, depending on whether/ not the Object was nil, through a Group:
static var previews: some View {
Group {
NotificationView()
}
NotificationView(title: "Turtle Rock", message: "You are within 5 miles of Turtle Rock.", landmark: ModelData().landmarks[0])
}
Another interesting modifier is the .lineLimit(0)
that’s used to prevent any additional lines. It produces the run-on text above that goes off the screen, because it was place on the VStack
.
Although, one thing I didn’t like is that they would have you code elements of the screen that you couldn’t see in the Preview unless, you entered up the live preview mode, then swiped down. Perhaps making these elements into a separate View would have been a better way to visualize them before letting them trail further down in a ScrollView
.
It was also interesting to see special code added to the app called a conditional compilation that only uses this code in the build, if the target is for watchOS:
#if os(watchOS)
WKNotificationScene(
controller: NotificationController.self,
category: "LandmarkNear"
)
#endif
Although, I was dissapointed at the end that my test notification did not display.