Abit confused why J cant be found.
I am trying to click on the navigation link and open up a whole new view that shows title and the paragraph. How Chris did (shown in the second picture)
In your JournalView, remove the $ sign.
In your DetailView, remove the @Binding wrapper and leave it as just a var…
My approach to solving this challenge is a little different than yours. My suggestion above did not work for me either so this is the way I went about it:
I have a LazyVGrid as you do but I am not using a NavigationLink to get to the DetailView.
The challenge says to present the DetailView as a .sheet
so with that in mind I used an onTapGesture
to present the sheet.
Before doing that I declared a State property to store the name of the image to be passed to the DetailView and named it selectedImage
. I also declared a Boolean which will be used to trigger the sheet to be shown and named that isShowingDetail
with an initial value of false.
In the DetailView I declared a @Binding var imageName: String
In the body of that View I added an Image(imageName)
and added a couple of modifiers to allow the image to be resized and set the aspectRatio to fit.
Back in the Home view I added the onTapGesture
and in that I set selectedImage
to be the current journal entry imageName and also set isShowingDetail
to be true.
The sheet was configured as:
.sheet(isPresented: $isShowingDetail, content: {
DetailView(imageName: $selectedImage)
})
…and that works fine.
Thanks chris, the previous solution (the first one you told me) that worked. Thank you !