Skip to content

Commit 26be5a6

Browse files
committed
Type-erase WCSettingsWebView through externalViews
1 parent 53dd19a commit 26be5a6

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

WooCommerce/Classes/POS/Adaptors/POSServiceLocatorAdaptor.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,8 @@ private struct POSExternalViewAdaptor: POSExternalViewProviding {
115115
onSelection: onSelection
116116
))
117117
}
118+
119+
func createWCWebView(adminUrl: URL, completion: @escaping () -> Void) -> AnyView {
120+
AnyView(WCSettingsWebView(adminUrl: adminUrl, completion: completion))
121+
}
118122
}

WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Connection Alerts/PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import SwiftUI
33
struct PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView: View {
44
@StateObject var viewModel: PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressAlertViewModel
55
let animation: POSCardPresentPaymentAlertAnimation
6+
@Environment(\.posExternalViews) private var externalViews
67

78
var body: some View {
89
VStack(spacing: PointOfSaleReaderConnectionModalLayout.contentButtonSpacing) {
@@ -29,8 +30,8 @@ struct PointOfSaleCardPresentPaymentConnectingFailedUpdateAddressView: View {
2930
.multilineTextAlignment(.center)
3031
.accessibilityElement(children: .contain)
3132
.posSheet(isPresented: $viewModel.shouldShowSettingsWebView) {
32-
WCSettingsWebView(adminUrl: viewModel.settingsAdminUrl,
33-
completion: viewModel.settingsWebViewWasDismissed)
33+
externalViews.createWCWebView(adminUrl: viewModel.settingsAdminUrl,
34+
completion: viewModel.settingsWebViewWasDismissed)
3435
}
3536
}
3637
}

WooCommerce/Classes/POS/Protocols/POSDependencyProviding.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ protocol POSExternalViewProviding {
5959
title: String,
6060
cancelButtonTitle: String,
6161
onSelection: @escaping (Coupon.DiscountType) -> Void) -> AnyView
62+
func createWCWebView(adminUrl: URL, completion: @escaping () -> Void) -> AnyView
6263
}
6364

6465
/// Main protocol that combines all POS dependency providers

WooCommerce/Classes/POS/Utils/POSEnvironmentKeys.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,8 @@ struct EmptyPOSExternalView: POSExternalViewProviding {
142142
onSelection: @escaping (Coupon.DiscountType) -> Void) -> AnyView {
143143
AnyView(EmptyView())
144144
}
145+
func createWCWebView(adminUrl: URL, completion: @escaping () -> Void) -> AnyView {
146+
AnyView(EmptyView())
147+
}
145148
init() {}
146149
}

0 commit comments

Comments
 (0)