Skip to content

Commit

Permalink
feat: propagate flow outcome to presenting vc
Browse files Browse the repository at this point in the history
  • Loading branch information
El-Fitz committed Dec 2, 2024
1 parent 98144e2 commit ae1c608
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
1 change: 0 additions & 1 deletion WireUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
})
Expand Down Expand Up @@ -149,9 +161,9 @@ public class IndividualToTeamMigrationViewController: UIViewController {
)
childController.pushViewController(vc, animated: true)
case .toApp:
break
actionCallback(.completionGoToApp)
case .toTeamManagement:
break
actionCallback(.completionGoToTeamManagement)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
)
}

Expand Down

0 comments on commit ae1c608

Please sign in to comment.