From 27ebf803c3aa42c5bcc79363c0cb219873df6c1a Mon Sep 17 00:00:00 2001 From: An Tran Date: Mon, 20 Feb 2023 16:54:12 +0700 Subject: [PATCH] Add public select ScenarioID method --- Sources/Scenarios/BaseScenariosManager.swift | 10 +++++++--- Sources/Scenarios/ScenariosManager.swift | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Sources/Scenarios/BaseScenariosManager.swift b/Sources/Scenarios/BaseScenariosManager.swift index 67f6da8..50f0fd1 100644 --- a/Sources/Scenarios/BaseScenariosManager.swift +++ b/Sources/Scenarios/BaseScenariosManager.swift @@ -132,7 +132,11 @@ open class BaseScenariosManager { } @objc public func reset() { - activeScenarioId = nil + select(nil) + } + + public func select(_ scenarioId: ScenarioId?) { + activeScenarioId = scenarioId } // MARK: Private helpers @@ -163,7 +167,7 @@ open class BaseScenariosManager { BaseScenarioSelectorAppController( targetAudience: targetAudience ) { [weak self] id in - self?.activeScenarioId = id + self?.select(id) } } @@ -171,7 +175,7 @@ open class BaseScenariosManager { let previousScenarioId = activeScenarioId DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { - self.activeScenarioId = previousScenarioId + self.select(previousScenarioId) } } diff --git a/Sources/Scenarios/ScenariosManager.swift b/Sources/Scenarios/ScenariosManager.swift index 50e6231..31dabff 100644 --- a/Sources/Scenarios/ScenariosManager.swift +++ b/Sources/Scenarios/ScenariosManager.swift @@ -64,7 +64,7 @@ open class ScenariosManager: BaseScenariosManager { innerAppController = ScenarioSelectorSplitAppController( targetAudience: targetAudience ) { [weak self] id in - self?.activeScenarioId = id + self?.select(id) } } else { innerAppController = ScenarioSelectorAppController( @@ -72,7 +72,7 @@ open class ScenariosManager: BaseScenariosManager { favouriteScenarios: $favouriteScenarios.eraseToAnyPublisher(), layout: scenarioListLayout ) { [weak self] id in - self?.activeScenarioId = id + self?.select(id) } } } else { @@ -81,7 +81,7 @@ open class ScenariosManager: BaseScenariosManager { favouriteScenarios: $favouriteScenarios.eraseToAnyPublisher(), layout: scenarioListLayout ) { [weak self] id in - self?.activeScenarioId = id + self?.select(id) } }