Fix timer memory leak in ProgressAnimation

This commit is contained in:
Beingpax 2025-08-29 19:03:31 +05:45
parent c67fdeb73c
commit 82f3464f5d

View File

@ -121,6 +121,7 @@ struct ProcessingIndicator: View {
// MARK: - Progress Animation Component
struct ProgressAnimation: View {
@State private var currentDot = 0
@State private var timer: Timer?
let animationSpeed: Double
var body: some View {
@ -132,11 +133,15 @@ struct ProgressAnimation: View {
}
}
.onAppear {
Timer.scheduledTimer(withTimeInterval: animationSpeed, repeats: true) { _ in
timer = Timer.scheduledTimer(withTimeInterval: animationSpeed, repeats: true) { _ in
currentDot = (currentDot + 1) % 7
if currentDot >= 5 { currentDot = -1 }
}
}
.onDisappear {
timer?.invalidate()
timer = nil
}
}
}