11import SwiftUI
22
33struct InPersonPaymentsSelectPlugin : View {
4- let onRefresh : ( Bool ) -> Void
5-
6- @State private var activateWCPay = true
7- @State private var activateStripe = true
4+ let onRefresh : ( ) -> Void
5+ @State var presentedSetupURL : URL ? = nil
86
97 var body : some View {
10- VStack {
11- InPersonPaymentsOnboardingError (
12- title: Localization . unavailable,
8+ ScrollableVStack {
9+ Spacer ( )
10+
11+ InPersonPaymentsOnboardingError . MainContent (
12+ title: Localization . title,
1313 message: Localization . message,
1414 image: InPersonPaymentsOnboardingError . ImageInfo (
15- image: . paymentErrorImage ,
16- height: 180 .0
15+ image: . paymentsPlugin ,
16+ height: 108 .0
1717 ) ,
18- supportLink: false ,
19- learnMore: false ,
20- button: InPersonPaymentsOnboardingError . ButtonInfo (
21- text: Localization . primaryButton,
22- action: {
23- onRefresh ( activateStripe)
24- }
25- )
18+ supportLink: false
2619 )
2720
28- VStack {
29- // Switch to activate WooCommercePayments
30- Toggle ( Localization . wcPay, isOn: $activateWCPay)
31- . onChange ( of: activateWCPay, perform: { value in
32- activateStripe = !value
33- } )
21+ Spacer ( )
3422
35- // Switch to activate Stripe extension
36- Toggle ( Localization . stripeExtension, isOn: $activateStripe)
37- . onChange ( of: activateStripe, perform: { value in
38- activateWCPay = !value
39- } )
23+ Button {
24+ presentedSetupURL = setupURL
25+ } label: {
26+ HStack {
27+ Text ( Localization . primaryButton)
28+ Image ( uiImage: . externalImage)
29+ }
4030 }
41- . padding ( [ . leading, . trailing, . bottom] )
31+ . buttonStyle ( PrimaryButtonStyle ( ) )
32+ . padding ( . bottom, 24.0 )
33+
34+ InPersonPaymentsLearnMore ( )
4235 }
36+ . safariSheet ( url: $presentedSetupURL, onDismiss: onRefresh)
37+ }
38+
39+ var setupURL : URL ? {
40+ guard let adminURL = ServiceLocator . stores. sessionManager. defaultSite? . adminURL else {
41+ return nil
42+ }
43+
44+ return URL ( string: adminURL)
4345 }
4446}
4547
4648private enum Localization {
47- static let unavailable = NSLocalizedString (
49+ static let title = NSLocalizedString (
4850 " Please select an extension " ,
4951 comment: " Title for the error screen when there is more than one extension active. "
5052 )
@@ -54,24 +56,14 @@ private enum Localization {
5456 comment: " Message requesting merchants to select between available payments processors "
5557 )
5658
57- static let stripeExtension = NSLocalizedString (
58- " Stripe Extension " ,
59- comment: " Message asking merchants whether the Stripe Extension should be active "
60- )
61-
62- static let wcPay = NSLocalizedString (
63- " WooCommerce Payments " ,
64- comment: " Message asking merchants whether the WooCommerce Payments should be active "
65- )
66-
6759 static let primaryButton = NSLocalizedString (
68- " Refresh " ,
69- comment: " Button to reload plugin data after selecting a payment plugin "
60+ " Select extension in Store Admin " ,
61+ comment: " Button to set up the WooCommerce Payments plugin after installing it "
7062 )
7163}
7264
7365struct InPersonPaymentsSelectPlugin_Previews : PreviewProvider {
7466 static var previews : some View {
75- InPersonPaymentsSelectPlugin ( onRefresh: { _ in } )
67+ InPersonPaymentsSelectPlugin ( onRefresh: { } )
7668 }
7769}
0 commit comments