Skip to content

Commit bedc8b4

Browse files
committed
Progress presenting the support screen from the migration flow
1 parent 82a4472 commit bedc8b4

6 files changed

Lines changed: 47 additions & 8 deletions

File tree

WordPress/Classes/ViewRelated/Support/SupportTableViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ private extension SupportTableViewController {
171171
)
172172
}
173173

174-
// Log out sections
174+
// Log out Section
175175
var logOutSections: ImmuTableSection?
176176
if configuration.showsLogOutButton {
177177
let logOutRow = DestructiveButtonRow(

WordPress/Jetpack/Classes/System/JetpackWindowManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ class JetpackWindowManager: WindowManager {
4343

4444
// TODO: Add logic in here to trigger migration UI if needed
4545
private var shouldShowMigrationUI: Bool {
46-
false
46+
true
4747
}
4848
}

WordPress/Jetpack/Classes/ViewRelated/WordPress-to-Jetpack Migration/Common/MigrationDependencyContainer.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ struct MigrationViewControllerFactory {
4444
}
4545
}
4646

47+
// MARK: - View Models
48+
4749
private func makeWelcomeViewModel() -> MigrationWelcomeViewModel {
4850
MigrationWelcomeViewModel(account: makeAccount(), coordinator: coordinator)
4951
}
5052

53+
// MARK: - View Controllers
54+
5155
private func makeWelcomeViewController() -> UIViewController {
5256
MigrationWelcomeViewController(viewModel: makeWelcomeViewModel())
5357
}

WordPress/Jetpack/Classes/ViewRelated/WordPress-to-Jetpack Migration/Common/Navigation/MigrationFlowCoordinator.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ final class MigrationFlowCoordinator: ObservableObject {
88
// related to this property.
99
@Published private(set) var currentStep = MigrationStep.welcome
1010

11+
/// Call this closure to display the support screen
12+
var routeToSupportViewController: (() -> Void)?
13+
1114
func transitionToNextStep() {
1215
Task { [weak self] in
1316
if let nextStep = await Self.nextStep(from: currentStep) {

WordPress/Jetpack/Classes/ViewRelated/WordPress-to-Jetpack Migration/Common/Navigation/MigrationNavigationController.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@ import Combine
22
import UIKit
33

44
class MigrationNavigationController: UINavigationController {
5+
6+
// MARK: - Properties
7+
58
/// Navigation coordinator
69
private let coordinator: MigrationFlowCoordinator
710
/// The view controller factory used to push view controllers on the stack
811
private let factory: MigrationViewControllerFactory
912
/// Receives state changes to set the navigation stack accordingly
1013
private var cancellable: AnyCancellable?
1114

15+
// MARK: - Orientation
16+
1217
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
1318
if WPDeviceIdentification.isiPhone() {
1419
return .portrait
@@ -21,6 +26,8 @@ class MigrationNavigationController: UINavigationController {
2126
.portrait
2227
}
2328

29+
// MARK: - Init
30+
2431
init(coordinator: MigrationFlowCoordinator, factory: MigrationViewControllerFactory) {
2532
self.coordinator = coordinator
2633
self.factory = factory
@@ -36,6 +43,8 @@ class MigrationNavigationController: UINavigationController {
3643
fatalError("init(coder:) has not been implemented")
3744
}
3845

46+
// MARK: - Configuration
47+
3948
private func configure() {
4049
let navigationBar = self.navigationBar
4150
let standardAppearance = UINavigationBarAppearance()
@@ -49,7 +58,15 @@ class MigrationNavigationController: UINavigationController {
4958
navigationBar.compactScrollEdgeAppearance = scrollEdgeAppearance
5059
}
5160
navigationBar.isTranslucent = true
52-
listenForStateChanges()
61+
configure(coordinator: coordinator)
62+
}
63+
64+
private func configure(coordinator: MigrationFlowCoordinator) {
65+
coordinator.routeToSupportViewController = { [weak self] in
66+
let destination = SupportTableViewController(configuration: .currentAccountConfiguration())
67+
self?.present(UINavigationController(rootViewController: destination), animated: true)
68+
}
69+
self.listenForStateChanges()
5370
}
5471

5572
private func listenForStateChanges() {

WordPress/Jetpack/Classes/ViewRelated/WordPress-to-Jetpack Migration/Welcome/MigrationWelcomeViewModel.swift

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,27 @@ final class MigrationWelcomeViewModel {
2424
let headerConfiguration = MigrationHeaderConfiguration(step: .welcome,
2525
multiSite: blogListDataSource.visibleBlogsCount > 1)
2626

27-
let actionsConfiguration = MigrationActionsViewConfiguration(step: .welcome,
28-
primaryHandler: { [weak coordinator] in
27+
let primaryHandler = { [weak coordinator] () -> Void in
2928
coordinator?.transitionToNextStep()
30-
},
31-
secondaryHandler: { })
32-
29+
}
30+
let secondaryHandler = { [weak coordinator] () -> Void in
31+
// Which object is responsible for displaying the support screen?
32+
//
33+
// The following code needs to be executed somewhere:
34+
//
35+
// let destination = SupportTableViewController()
36+
// presentingViewController.present(destination, completion: nil)
37+
//
38+
// Approaches considered:
39+
//
40+
// 1. The View Model shouldn't be responsible for displaying the support screen
41+
// 2. The coordination can't perform the presentation because it doesn't have access to the `presenting` view controller
42+
// 3. I thought of making the `MigrationViewControllerFactory` responsible for creating the `secondaryHandler` and injecting it into this view model
43+
// But that didn't work as well.
44+
//
45+
coordinator?.routeToSupportViewController?()
46+
}
47+
let actionsConfiguration = MigrationActionsViewConfiguration(step: .welcome, primaryHandler: primaryHandler, secondaryHandler: secondaryHandler)
3348
configuration = MigrationStepConfiguration(headerConfiguration: headerConfiguration, actionsConfiguration: actionsConfiguration)
3449
}
3550
}

0 commit comments

Comments
 (0)