I'm trying to get an activity indicator to rotate during download. For some reason, when I try to get the animation to repeat forever, it throws an error way at the bottom of the VStack code.
This works:
struct AddView: View {
@State var showActivitySpinner: Bool = false
@State var urlText: String = ""
var body: some View {
VStack{
Image(systemName: "arrow.2.circlepath.circle")
.resizable()
.frame(width: 80, height: 80)
.opacity(showActivitySpinner ? 1 : 0)
.rotationEffect(.degrees(showActivitySpinner ? 360 : 0))
.animation(.easeIn(duration: 1.0))
Spacer()
.frame(maxHeight: 100)
TextField("placeholder text", text: $urlText)
.textFieldStyle(RoundedBorderTextFieldStyle())
.font(Font.system(size: 16, design: .default))
.offset(y: -50)
Button(
action:{self.myFunction()},
label: {
HStack{
Image(systemName: "plus.circle.fill")
Text("Add")
.font(.title)
}
}
)
}
.padding()
.offset(y: -100)
}
But then when I add .repeatForever(), xcode has a problem with the VStack offset.