A problem similar to https://developer.apple.com/forums/thread/761211 posted by @matti777. I was trying to implement the interaction of draggable point. When some point is activated, the color would change accordingly. When I define a .hoverEffect {} like below, the change of color in .fill() functionality stops working:
struct DraggableCircleView: View {
@Binding var position: CGPoint
@Binding var activeIndex: Int
var currentIndex: Int
var radius:CGFloat = 20
var body: some View {
Circle()
.fill(activeIndex == currentIndex ? Color.blue : Color.white.opacity(0.1))
.frame(width: radius, height: radius)
.hoverEffect(.highlight)
// the issue occurred when the code below added:
// .hoverEffect { effect, isactive, _ in
// effect.scaleEffect(isactive ? 1.5 : 0.8)
// }
.position(position)
.gesture(
DragGesture()
.onChanged { value in
self.position = value.location
activeIndex = currentIndex
}
)
.gesture(
TapGesture()
.onEnded({
activeIndex = currentIndex
})
)
.transition(.opacity)
.animation(.easeInOut, value: activeIndex)
}
}
Occurring on VisionOS 2.0 Beta 4 SDK, Xcode 16 Beta 4.
Does anyone have a workaround for this? I would really much like to have a hover scale effect for my draggable point. In addition, .hoverEffect(.highlight) does not break changes of fill color.
Anyone interest in my full code can contact me and ask for it due to the post length limit.