Skip to content

Commit

Permalink
ALTAPPS-1272: Fix HackerTextView contains incorrect symbols after ani…
Browse files Browse the repository at this point in the history
…mation is completed
  • Loading branch information
ivan-magda committed Jul 26, 2024
1 parent 1b9e0c4 commit 3c5a34b
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ struct HackerTextView: View {

setRandomCharacters()
animateText()
applyFinalTextCharacters()
}
.onChange(of: text) { _ in
animatedText = text
animationID = UUID().uuidString

setRandomCharacters()
animateText()
applyFinalTextCharacters()
}
}

Expand Down Expand Up @@ -95,6 +97,20 @@ struct HackerTextView: View {
animatedText.replaceSubrange(index...index, with: String(character))
}
}

private func applyFinalTextCharacters() {
let currentID = animationID

DispatchQueue.main.asyncAfter(deadline: .now() + duration) {
guard currentID == animationID else {
return
}

if animatedText != text {
animatedText = text
}
}
}
}

#if DEBUG
Expand Down

0 comments on commit 3c5a34b

Please sign in to comment.