diff --git a/iosHyperskillApp/iosHyperskillApp/Sources/Views/SwiftUI/TextEffects/HackerTextView.swift b/iosHyperskillApp/iosHyperskillApp/Sources/Views/SwiftUI/TextEffects/HackerTextView.swift index 4e68639a22..877e867924 100644 --- a/iosHyperskillApp/iosHyperskillApp/Sources/Views/SwiftUI/TextEffects/HackerTextView.swift +++ b/iosHyperskillApp/iosHyperskillApp/Sources/Views/SwiftUI/TextEffects/HackerTextView.swift @@ -28,6 +28,7 @@ struct HackerTextView: View { setRandomCharacters() animateText() + applyFinalTextCharacters() } .onChange(of: text) { _ in animatedText = text @@ -35,6 +36,7 @@ struct HackerTextView: View { setRandomCharacters() animateText() + applyFinalTextCharacters() } } @@ -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