From a418616407dde76e2042354cf30eb9f30988acc8 Mon Sep 17 00:00:00 2001 From: dragon Date: Tue, 20 Jun 2023 07:51:10 +0545 Subject: [PATCH 1/2] fix: Calling start and then end too quickly causes dismiss to fail --- Progress/Classes/Prog.swift | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Progress/Classes/Prog.swift b/Progress/Classes/Prog.swift index dad3891..b6e8e52 100644 --- a/Progress/Classes/Prog.swift +++ b/Progress/Classes/Prog.swift @@ -22,6 +22,11 @@ public final class Prog { internal var progressors: [[Progressor]] = [] internal var maxEndingAnimationDuration: TimeInterval = 0.4 internal var fadingDuration: TimeInterval = 0.2 + internal var competedAnimation = false { + didSet { + + } + } // MARK: - Progressors var builtInProgressorTypes: [String: Progressor.Type] = [ @@ -113,6 +118,7 @@ public final class Prog { print("\(parent) is already in progress") return } + shared.competedAnimation = false shared.progressParents.append(parent) shared.progressors.append([]) @@ -122,6 +128,11 @@ public final class Prog { } static func recursiveStart(in parent: ProgressParent, remainingTypes: [ProgressorType], completion: @escaping (()->Void)) { + if shared.competedAnimation { + shared.competedAnimation = true + completion() + } + if let type = remainingTypes.first { start(in: parent, type: type) { var remain = remainingTypes @@ -172,13 +183,14 @@ public final class Prog { - parameter completion: callback function after all the ending animation */ public static func end(in parent: ProgressParent, completion: @escaping (()->Void) = {}) { - recursiveEnd(in: parent, remainingProgressors: progressors(of: parent).reversed()) { - if let index = shared.progressParents.index(where: { $0 === parent}) { - shared.progressParents.remove(at: index) - shared.progressors.remove(at: index) + shared.competedAnimation = true + recursiveEnd(in: parent, remainingProgressors: progressors(of: parent).reversed()) { + if let index = shared.progressParents.index(where: { $0 === parent}) { + shared.progressParents.remove(at: index) + shared.progressors.remove(at: index) + } + completion() } - completion() - } } static func recursiveEnd(in parent: ProgressParent, remainingProgressors: [Progressor], completion: @escaping (()->Void)) { From 7a40ce92e1e69f9179ee20be43f5bd869e42af90 Mon Sep 17 00:00:00 2001 From: dragon Date: Tue, 20 Jun 2023 07:52:50 +0545 Subject: [PATCH 2/2] fix: Calling start and then end too quickly causes dismiss to fail --- Progress/Classes/Prog.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Progress/Classes/Prog.swift b/Progress/Classes/Prog.swift index b6e8e52..b182a92 100644 --- a/Progress/Classes/Prog.swift +++ b/Progress/Classes/Prog.swift @@ -22,11 +22,7 @@ public final class Prog { internal var progressors: [[Progressor]] = [] internal var maxEndingAnimationDuration: TimeInterval = 0.4 internal var fadingDuration: TimeInterval = 0.2 - internal var competedAnimation = false { - didSet { - - } - } + internal var competedAnimation = false // MARK: - Progressors var builtInProgressorTypes: [String: Progressor.Type] = [