11import UIKit
22import SwiftUI
3+ import Yosemite
34
45final class InPersonPaymentsMenuViewController : UITableViewController {
56 private var rows = [ Row] ( )
7+ private let configurationLoader : CardPresentConfigurationLoader
68
79 init ( ) {
10+ configurationLoader = CardPresentConfigurationLoader ( )
811 super. init ( style: . grouped)
912 }
1013
@@ -28,10 +31,23 @@ private extension InPersonPaymentsMenuViewController {
2831 func configureRows( ) {
2932 rows = [
3033 . orderCardReader,
31- . manageCardReader,
32- . bbposChipper2XBTManual,
33- . stripeM2Manual
34- ]
34+ . manageCardReader
35+ ] + readerManualRows( )
36+ }
37+
38+ func readerManualRows( ) -> [ Row ] {
39+ configurationLoader. configuration. supportedReaders. map { readerType in
40+ switch readerType {
41+ case . chipper:
42+ return . bbposChipper2XBTManual
43+ case . stripeM2:
44+ return . stripeM2Manual
45+ case . wisepad3:
46+ return . wisepad3Manual
47+ case . other:
48+ preconditionFailure ( " Unknown card reader type was present in the supported readers list. This should not be possible " )
49+ }
50+ }
3551 }
3652
3753 func configureTableView( ) {
@@ -59,6 +75,8 @@ private extension InPersonPaymentsMenuViewController {
5975 configureChipper2XManual ( cell: cell)
6076 case let cell as LeftImageTableViewCell where row == . stripeM2Manual:
6177 configureStripeM2Manual ( cell: cell)
78+ case let cell as LeftImageTableViewCell where row == . wisepad3Manual:
79+ configureWisepad3Manual ( cell: cell)
6280 default :
6381 fatalError ( )
6482 }
@@ -91,6 +109,13 @@ private extension InPersonPaymentsMenuViewController {
91109 cell. selectionStyle = . default
92110 cell. configure ( image: . cardReaderManualIcon, text: Localization . stripeM2CardReaderManual)
93111 }
112+
113+ func configureWisepad3Manual( cell: LeftImageTableViewCell ) {
114+ cell. imageView? . tintColor = . text
115+ cell. accessoryType = . disclosureIndicator
116+ cell. selectionStyle = . default
117+ cell. configure ( image: . cardReaderManualIcon, text: Localization . wisepad3CardReaderManual)
118+ }
94119}
95120
96121// MARK: - Convenience methods
@@ -126,6 +151,10 @@ extension InPersonPaymentsMenuViewController {
126151 func stripeM2ManualWasPressed( ) {
127152 WebviewHelper . launch ( Constants . stripeM2ManualURL, with: self )
128153 }
154+
155+ func wisepad3ManualWasPressed( ) {
156+ WebviewHelper . launch ( Constants . wisepad3ManualURL, with: self )
157+ }
129158}
130159
131160// MARK: - UITableViewDataSource
@@ -163,6 +192,8 @@ extension InPersonPaymentsMenuViewController {
163192 bbposChipper2XBTManualWasPressed ( )
164193 case . stripeM2Manual:
165194 stripeM2ManualWasPressed ( )
195+ case . wisepad3Manual:
196+ wisepad3ManualWasPressed ( )
166197 }
167198 }
168199}
@@ -190,6 +221,11 @@ private extension InPersonPaymentsMenuViewController {
190221 " Stripe M2 card reader manual " ,
191222 comment: " Navigates to Stripe M2 Card Reader manual "
192223 )
224+
225+ static let wisepad3CardReaderManual = NSLocalizedString (
226+ " WisePad 3 card reader manual " ,
227+ comment: " Navigates to WisePad 3 Card Reader manual "
228+ )
193229 }
194230}
195231
@@ -198,6 +234,7 @@ private enum Row: CaseIterable {
198234 case manageCardReader
199235 case bbposChipper2XBTManual
200236 case stripeM2Manual
237+ case wisepad3Manual
201238
202239 var type : UITableViewCell . Type {
203240 LeftImageTableViewCell . self
@@ -212,6 +249,7 @@ private enum Constants {
212249 static let woocommercePurchaseCardReaderURL = URL ( string: " https://woocommerce.com/products/m2-card-reader/ " ) !
213250 static let bbposChipper2XBTManualURL = URL ( string: " https://developer.bbpos.com/quick_start_guide/Chipper%202X%20BT%20Quick%20Start%20Guide.pdf " ) !
214251 static let stripeM2ManualURL = URL ( string: " https://stripe.com/files/docs/terminal/m2_product_sheet.pdf " ) !
252+ static let wisepad3ManualURL = URL ( string: " https://stripe.com/files/docs/terminal/wp3_product_sheet.pdf " ) !
215253}
216254
217255// MARK: - SwiftUI compatibility
0 commit comments