From ae1c6089a84c9801a3c419dde199c7b7f455af41 Mon Sep 17 00:00:00 2001 From: El-Fitz <8971906+El-Fitz@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:53:36 +0100 Subject: [PATCH] feat: propagate flow outcome to presenting vc --- WireUI/Package.swift | 1 - ...ividualToTeamMigrationViewController.swift | 20 +++++++++++++++---- .../Views/Previews/_FeaturePreview.swift | 5 +++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/WireUI/Package.swift b/WireUI/Package.swift index 020ed449fb..ff6c1e7d3e 100644 --- a/WireUI/Package.swift +++ b/WireUI/Package.swift @@ -24,7 +24,6 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/swiftlang/swift-docc-plugin", from: "1.1.0"), - .package(path: "../SourceryPlugin"), .package(name: "WireDomainPackage", path: "../WireDomain"), .package(name: "WireFoundation", path: "../WireFoundation"), .package(path: "../WirePlugins") diff --git a/WireUI/Sources/WireIndividualToTeamMigrationUI/IndividualToTeamMigrationViewController.swift b/WireUI/Sources/WireIndividualToTeamMigrationUI/IndividualToTeamMigrationViewController.swift index 9362670225..c074f3bca9 100644 --- a/WireUI/Sources/WireIndividualToTeamMigrationUI/IndividualToTeamMigrationViewController.swift +++ b/WireUI/Sources/WireIndividualToTeamMigrationUI/IndividualToTeamMigrationViewController.swift @@ -23,6 +23,12 @@ import WireDomainAPI import WireFoundation public class IndividualToTeamMigrationViewController: UIViewController { + public enum Action: Sendable { + case cancel + case completionGoToApp + case completionGoToTeamManagement + } + enum Step: Sendable { case teamPlanSelection(features: [TeamPlanFeature]) case teamName @@ -76,12 +82,18 @@ public class IndividualToTeamMigrationViewController: UIViewController { case toTeamManagement } + let actionCallback: @Sendable (Action) -> Void let childController: UINavigationController var currentStep: Step let features: [TeamPlanFeature] let useCase: any IndividualToTeamMigrationUseCase - public init(features: [TeamPlanFeature], useCase: any IndividualToTeamMigrationUseCase) { + public init( + features: [TeamPlanFeature], + useCase: any IndividualToTeamMigrationUseCase, + actionCallback: @escaping @Sendable (Action) -> Void + ) { + self.actionCallback = actionCallback self.currentStep = .teamPlanSelection(features: features) self.childController = UINavigationController() self.features = features @@ -109,7 +121,7 @@ public class IndividualToTeamMigrationViewController: UIViewController { case .toCancellationAlert: let alert = cancellationSheetFactory( onLeave: { [weak self] in - self?.transition(to: .toApp) + self?.actionCallback(.cancel) }, onContinue: { [weak self] in self?.transition(to: .dismissCancellationAlert) }) @@ -149,9 +161,9 @@ public class IndividualToTeamMigrationViewController: UIViewController { ) childController.pushViewController(vc, animated: true) case .toApp: - break + actionCallback(.completionGoToApp) case .toTeamManagement: - break + actionCallback(.completionGoToTeamManagement) } } } diff --git a/WireUI/Sources/WireIndividualToTeamMigrationUI/Views/Previews/_FeaturePreview.swift b/WireUI/Sources/WireIndividualToTeamMigrationUI/Views/Previews/_FeaturePreview.swift index 3238d9a1f1..6c58febcb0 100644 --- a/WireUI/Sources/WireIndividualToTeamMigrationUI/Views/Previews/_FeaturePreview.swift +++ b/WireUI/Sources/WireIndividualToTeamMigrationUI/Views/Previews/_FeaturePreview.swift @@ -32,10 +32,11 @@ fileprivate struct FeaturePreviewContainer: UIViewControllerRepresentable { let features: [TeamPlanFeature] func makeUIViewController(context: Context) -> IndividualToTeamMigrationViewController { - // Return MyViewController instance + return IndividualToTeamMigrationViewController( features: features, - useCase: MockUseCase() + useCase: MockUseCase(), + actionCallback: { _ in } ) }