Skip to content

Commit 16e8e41

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

6 files changed

Lines changed: 41 additions & 9 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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct MigrationViewControllerFactory {
1616
self.coordinator = coordinator
1717
}
1818

19-
func viewController(for step: MigrationStep) -> UIViewController? {
19+
func viewController(for parent: UIViewController, in step: MigrationStep) -> UIViewController? {
2020
switch step {
2121
case .welcome:
2222
return makeWelcomeViewController()
@@ -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/MigrationNavigationController.swift

Lines changed: 10 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()
@@ -63,7 +72,7 @@ class MigrationNavigationController: UINavigationController {
6372

6473
private func updateStack(for step: MigrationStep) {
6574
// sets the stack for the next navigation step, if there's one
66-
guard let viewController = factory.viewController(for: step) else {
75+
guard let viewController = factory.viewController(for: self, in: step) else {
6776
return
6877
}
6978
// if we want to support backwards navigation, we need to set

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ final class MigrationWelcomeViewController: UIViewController {
5151
self.updateTableViewContentInset()
5252
}
5353

54+
override func viewDidAppear(_ animated: Bool) {
55+
super.viewDidAppear(animated)
56+
let supportVC = SupportTableViewController(configuration: .currentAccountConfiguration())
57+
self.present(UINavigationController(rootViewController: supportVC), animated: animated)
58+
}
59+
5460
// MARK: - Setup and Updates
5561

5662
private func setupTableView() {

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,25 @@ 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+
let actionsConfiguration = MigrationActionsViewConfiguration(step: .welcome, primaryHandler: primaryHandler, secondaryHandler: secondaryHandler)
3346
configuration = MigrationStepConfiguration(headerConfiguration: headerConfiguration, actionsConfiguration: actionsConfiguration)
3447
}
3548
}

0 commit comments

Comments
 (0)