diff --git a/apps/ios/Shared/Views/ChatList/ChatListView.swift b/apps/ios/Shared/Views/ChatList/ChatListView.swift index 53c4be35a4..87c49889c8 100644 --- a/apps/ios/Shared/Views/ChatList/ChatListView.swift +++ b/apps/ios/Shared/Views/ChatList/ChatListView.swift @@ -123,7 +123,7 @@ struct ChatListView: View { } .onChange(of: activeUserPickerSheet) { if $0 != nil { - DispatchQueue.main.asyncAfter(deadline: .now() + 0.75) { + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { userPickerShown = false } } diff --git a/apps/ios/Shared/Views/Helpers/SheetRepresentable.swift b/apps/ios/Shared/Views/Helpers/SheetRepresentable.swift index c1429d8784..01410ad26f 100644 --- a/apps/ios/Shared/Views/Helpers/SheetRepresentable.swift +++ b/apps/ios/Shared/Views/Helpers/SheetRepresentable.swift @@ -62,15 +62,24 @@ struct SheetRepresentable: UIViewControllerRepresentable { required init?(coder: NSCoder) { fatalError("init(coder:) missing") } func animate(isPresented: Bool) { - let sheetDismissed = animator.fractionComplete == (animator.isReversed ? 1 : 0) - if isPresented || !sheetDismissed { - animator.pauseAnimation() - animator.isReversed = !isPresented - animator.continueAnimation( - withTimingParameters: easeOutCubic, - durationFactor: 1 - ) + let alreadyAnimating = animator.isRunning && isPresented != animator.isReversed + let sheetFullyDismissed = animator.fractionComplete == (animator.isReversed ? 1 : 0) + let sheetFullyPresented = animator.fractionComplete == (animator.isReversed ? 0 : 1) + + if !isPresented && sheetFullyDismissed || + isPresented && sheetFullyPresented || + alreadyAnimating { + return } + + animator.pauseAnimation() + animator.isReversed = !isPresented + animator.continueAnimation( + withTimingParameters: isPresented + ? easeOutCubic + : UICubicTimingParameters(animationCurve: .easeIn), + durationFactor: 1 - animator.fractionComplete + ) } override func viewDidLoad() {