scroll transition SwiftUI multiple constraints

  Kiến thức lập trình

in SwiftUI, we have a new feature that indicates whether a view is the identity(is at the center of the scroll view) or not, my for each is in a HStack which is in a ScrollView:

ForEach(viewModel.unwinds, id: .self) { unwindViewData in
          .scrollTransition { content, phase in
                  .opacity(phase.isIdentity ? 1 : 0.6)
                  .scaleEffect(phase.isIdentity ? 1 : 0.9)

I also have a:

@State private var shouldScale = false

Now in the code above, what I want to do is:

.scaleEffect(phase.isIdentity && shouldScale ? 1 : 0.9)

But I get the following error:

Main actor-isolated property 'shouldScale' can not be referenced from a non-isolated autoclosure

Is there anyway to get around this issue? In my example, the user can go to the edit context which I would set the shouldScale to false, and in that case, I want to make all the cards have the same size. But seems like I cannot access that property here.