mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-05-28 11:35:24 +00:00
improve handling of repeated sheet presentation state changes
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,15 +62,24 @@ struct SheetRepresentable<Content: View>: 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() {
|
||||
|
||||
Reference in New Issue
Block a user