@@ -2,6 +2,8 @@ import SwiftUI
22import struct WooFoundation. SafariView
33
44struct PointOfSaleSettingsHardwareDetailView : View {
5+ @Environment ( PointOfSaleAggregateModel . self) private var posModel
6+ @Environment ( \. posFeatureFlags) private var featureFlags
57 @Environment ( \. dynamicTypeSize) private var dynamicTypeSize
68 @Environment ( \. posAnalytics) private var analytics
79
@@ -69,7 +71,12 @@ struct PointOfSaleSettingsHardwareDetailView: View {
6971 . navigationDestination ( for: NavigationDestination . self) { destination in
7072 switch destination {
7173 case . hardware( . cardReaders) :
72- cardReadersView
74+ if featureFlags. isFeatureFlagEnabled ( . pointOfSaleSettingsCardReaderFlow) {
75+ cardReadersView
76+ } else {
77+ // TODO: Legacy view to be removed along feature flag on WOOMOB-1591
78+ legacyCardReadersView
79+ }
7380 case . hardware( . scanners) :
7481 scannersView
7582 }
@@ -92,7 +99,7 @@ struct PointOfSaleSettingsHardwareDetailView: View {
9299 }
93100 }
94101
95- private var cardReadersView : some View {
102+ private var legacyCardReadersView : some View {
96103 VStack ( spacing: POSSpacing . none) {
97104 POSPageHeaderView (
98105 title: Localization . cardReadersTitle,
@@ -161,6 +168,62 @@ struct PointOfSaleSettingsHardwareDetailView: View {
161168 }
162169 }
163170
171+ private var cardReadersView : some View {
172+ VStack ( spacing: POSSpacing . none) {
173+ POSPageHeaderView (
174+ title: Localization . cardReadersTitle,
175+ backButtonConfiguration: . init( state: . enabled, action: {
176+ navigationPath. removeLast ( )
177+ } , buttonIcon: " chevron.left " ) )
178+ . foregroundColor ( . posSurface)
179+
180+ List {
181+ if case . connected = posModel. cardReaderConnectionStatus {
182+ VStack ( spacing: POSPadding . xSmall) {
183+ HStack {
184+ Text ( Localization . readerModelTitle)
185+ . foregroundStyle ( . primary)
186+ Spacer ( )
187+ Text ( cardReaderName)
188+ . foregroundStyle ( . secondary)
189+ }
190+ . padding ( )
191+ HStack {
192+ Text ( Localization . readerBatteryTitle)
193+ . foregroundStyle ( . primary)
194+ Spacer ( )
195+ Text ( formattedBatteryLevel)
196+ . foregroundStyle ( . secondary)
197+ }
198+ . padding ( )
199+ }
200+ . font ( . posBodyMediumRegular( ) )
201+ } else {
202+ POSSettingsCardView ( title: Localization . cardReaderConnectTitle,
203+ subtitle: Localization . cardReaderConnectSubtitle,
204+ action: {
205+ posModel. connectCardReader ( )
206+ } )
207+ }
208+
209+ POSSettingsCardView ( title: Localization . cardReaderDocumentationTitle,
210+ subtitle: Localization . cardReaderDocumentationSubtitle,
211+ action: { showCardReaderDocumentationModal = true } )
212+ . accessibilityAddTraits ( . isButton)
213+ . listRowSeparator ( . hidden)
214+ }
215+ . listStyle ( . plain)
216+ . scrollContentBackground ( . hidden)
217+ . listRowBackground ( Color . clear)
218+ . background ( backgroundColor)
219+ . foregroundColor ( . posOnSurface)
220+ }
221+ . navigationBarBackButtonHidden ( true )
222+ . posFullScreenCover ( isPresented: $showCardReaderDocumentationModal) {
223+ SafariView ( url: POSConstants . URLs. inPersonPaymentsLearnMoreWCPay. asURL ( ) )
224+ }
225+ }
226+
164227 private var scannersView : some View {
165228 VStack ( spacing: POSSpacing . none) {
166229 POSPageHeaderView (
@@ -204,7 +267,8 @@ struct PointOfSaleSettingsHardwareDetailView: View {
204267 }
205268}
206269
207- extension PointOfSaleSettingsHardwareDetailView {
270+ // MARK: - Navigation
271+ private extension PointOfSaleSettingsHardwareDetailView {
208272 enum HardwareDestination : Identifiable , CaseIterable {
209273 case cardReaders
210274 case scanners
@@ -381,6 +445,16 @@ private extension PointOfSaleSettingsHardwareDetailView {
381445 value: " Configure barcode scanner settings " ,
382446 comment: " Description of Barcode scanner settings configuration. "
383447 )
448+ static let cardReaderConnectTitle = NSLocalizedString (
449+ " pointOfSaleSettingsHardwareDetailView.cardReaderConnectTitle " ,
450+ value: " Connect card reader " ,
451+ comment: " Title for card reader connect button when no reader is connected. "
452+ )
453+ static let cardReaderConnectSubtitle = NSLocalizedString (
454+ " pointOfSaleSettingsHardwareDetailView.cardReaderConnectSubtitle " ,
455+ value: " Connect your card reader and start accepting payments " ,
456+ comment: " Subtitle for card reader connect button when no reader is connected. "
457+ )
384458 }
385459}
386460
0 commit comments