I am trying to implement a button in swift UI that will show a loading indicator on click. but after the button click, the loading indicator is not animating.
{
Button(action: {
self.isLoading = true
}) {
HStack {
if isLoading {
Circle()
.trim(from: 0, to: 0.7)
.stroke(Color.green, lineWidth: 5)
.frame(width: 50, height: 50)
.rotationEffect(Angle(degrees: isLoading ? 360 : 0))
.animation(.default
.repeatForever(autoreverses: false), value: isLoading)
}
Text( isLoading ? "Processing" : "Submit")
.fontWeight(.semibold)
.font(.title)
}
}
.frame(width: 250, height: 50)
.background(.white)
}

