Skip to content

Commit 26afc18

Browse files
committed
Connect navigation from order type picker to NewOrder view
1 parent f04e697 commit 26afc18

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Creation/AddOrderCoordinator.swift

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private extension AddOrderCoordinator {
6363
case .quick:
6464
presentSimplePaymentsAmountController()
6565
case .full:
66-
// TODO: start full order creation flow
66+
presentNewOrderController()
6767
return
6868
}
6969
}
@@ -80,4 +80,12 @@ private extension AddOrderCoordinator {
8080

8181
ServiceLocator.analytics.track(event: WooAnalyticsEvent.SimplePayments.simplePaymentsFlowStarted())
8282
}
83+
84+
/// Presents `NewOrderHostingController`.
85+
///
86+
func presentNewOrderController() {
87+
let viewController = NewOrderHostingController()
88+
let newOrderNC = WooNavigationController(rootViewController: viewController)
89+
navigationController.present(newOrderNC, animated: true)
90+
}
8391
}

WooCommerce/Classes/ViewRelated/Orders/Order Creation/NewOrder.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
import SwiftUI
22

3+
/// Hosting controller that wraps an `NewOrder` view.
4+
///
5+
final class NewOrderHostingController: UIHostingController<NewOrder> {
6+
7+
init() {
8+
super.init(rootView: NewOrder())
9+
}
10+
11+
required dynamic init?(coder aDecoder: NSCoder) {
12+
fatalError("init(coder:) has not been implemented")
13+
}
14+
}
15+
316
/// View to create a new manual order
417
///
518
struct NewOrder: View {

WooCommerce/WooCommerceTests/ViewRelated/Orders/Order Creation/AddOrderCoordinatorTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ final class AddOrderCoordinatorTests: XCTestCase {
6666
assertThat(presentedNC, isAnInstanceOf: WooNavigationController.self)
6767
assertThat(presentedNC?.topViewController, isAnInstanceOf: SimplePaymentsAmountHostingController.self)
6868
}
69+
70+
func test_it_opens_order_creation_when_its_only_available_type() throws {
71+
// Given
72+
let coordinator = makeAddProductCoordinator(isOrderCreationEnabled: true,
73+
shouldShowSimplePaymentsButton: false)
74+
75+
// When
76+
coordinator.start()
77+
waitUntil {
78+
coordinator.navigationController.presentedViewController != nil
79+
}
80+
81+
// Then
82+
let presentedNC = coordinator.navigationController.presentedViewController as? UINavigationController
83+
assertThat(presentedNC, isAnInstanceOf: WooNavigationController.self)
84+
assertThat(presentedNC?.topViewController, isAnInstanceOf: NewOrderHostingController.self)
85+
}
6986
}
7087

7188
private extension AddOrderCoordinatorTests {

0 commit comments

Comments
 (0)