Skip to content

Commit a2b787d

Browse files
committed
create builder function with actions
1 parent 2e6cca4 commit a2b787d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

WooCommerce/Classes/Authentication/Epilogue/StorePickerError.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
import SwiftUI
2+
import SafariServices
23

34
/// Hosting controller wrapper for `StorePickerError`
45
///
56
final class StorePickerErrorHostingController: UIHostingController<StorePickerError> {
7+
8+
/// Creates an `StorePickerErrorHostingController` with preconfigured button actions.
9+
///
10+
static func createWithActions(presentingViewController: UIViewController) -> StorePickerErrorHostingController {
11+
.init(
12+
troubleshootingAction: {
13+
let safariViewController = SFSafariViewController(url: WooConstants.URLs.troubleshootErrorLoadingData.asURL())
14+
presentingViewController.present(safariViewController, animated: true)
15+
},
16+
contactSupportAction: {
17+
ZendeskManager.shared.showNewRequestIfPossible(from: presentingViewController)
18+
},
19+
dismissAction: {
20+
presentingViewController.dismiss(animated: true)
21+
}
22+
)
23+
}
24+
625
init(troubleshootingAction: @escaping () -> Void, contactSupportAction: @escaping () -> Void, dismissAction: @escaping () -> Void) {
726
super.init(rootView: StorePickerError(troubleshootingAction: troubleshootingAction,
827
contactSupportAction: contactSupportAction,

0 commit comments

Comments
 (0)