This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4001741-swiftui/lessons/33
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4001741-swiftui/lessons/33
very interesting lesson.
I wonder if there’s a way to preview the vertical size class with device right in PreviewProvider
. The below solution always get verticalSizeClass
as nil
PetCareView()
.environmentObject(PetPreferences()).previewDevice(PreviewDevice(rawValue: "iPhone 8"))
anything besides
PetCareView()
.environmentObject(PetPreferences())
.previewLayout(.sizeThatFits).environment(\.verticalSizeClass, .regular)
?
Thanks
Just a head’s up, the starter for this lesson does not contain the graph view (PetCareStatusView). I had to look at the completed code to find it and paste it in.
That is a good question! We’re currently updating all of the course to change its preview code due to deprecations. If you find a better way to do it let me know! Laurie.
@moebius - we’re releasing an update that includes fixes to small issues like this. Thanks so much for your patience and getting back to me. Laurie.
PetCareRow in starter project for #33 is missing the PetCareStatusView… Please fix your starter code. It’s been over 6 months…
It’s been six months and they still haven’t fixed it! Hey guys… please fix.
Lol. What a joke, SwiftUI resets the state upon rotating the phone Unbelievable just how incomplete SwiftUI is.
Hey @peter.suwara - I just checked the repository and the PetCareStatusView
is inside the PetCare
folder in the begin
part of the project files. The project must not have been published from the repository updates I made on launch to here. I’ll get this investigated for you. Have a great day.
For the starter app, the first part of the video the app is ran in the Simulator, the PetCareStatusView is displayed even though it was never mentioned to add the child view to the parent PetCareRow passing in the initializer of petModel.moods. After adding the below to the PetCareRow it worked properly. Even though this call is there when animation is being discussed in the video.
PetCareStatusView(petStatusModels: petModel.moods)
After completing the video for with the starter code, the view does not use the full screen in the iPhone 8. So I tried this in the final code and results are the same. Im using Xcode 12.2 Swift 5.3.1, are there changes to correct this that’s not in the video?
This is a great question - new in iOS14 is SwiftUI treating our view like a split view controller, so we can specify on the root tabView
a navigationViewStyle(StackNavigationViewStyle())
modifier to take up the entire view. The complete tabView
should look like this -
PetCareView()
.tabItem {
VStack {
Image(systemName: "person.crop.circle")
.renderingMode(.original)
Text(verbatim: "PetCare")
}
}.tag(3)
SettingsView()
.tabItem {
VStack {
Image(systemName: "gear")
.renderingMode(.original)
Text(verbatim: "Settings")
}
}.tag(4)
}
.navigationViewStyle(StackNavigationViewStyle())
That worked! Thanks for the update, good to know!