Skip to content

Commit 6c8c1e0

Browse files
authored
[WCiOS17] Update PaymentsRow to not use NavigationLink API (#16195)
2 parents eaa33a0 + d883fe5 commit 6c8c1e0

File tree

9 files changed

+43
-109
lines changed

9 files changed

+43
-109
lines changed

WooCommerce/Classes/POS/Presentation/Order Messages/PointOfSaleOrderSyncCouponsErrorMessageView.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,12 @@ private extension String {
125125

126126
#if DEBUG
127127
#Preview {
128-
if #available(iOS 17.0, *) {
129-
PointOfSaleOrderSyncCouponsErrorMessageView(message: "An error happened!") {}
130-
.environment(POSPreviewHelpers.makePreviewAggregateModel())
131-
}
128+
PointOfSaleOrderSyncCouponsErrorMessageView(message: "An error happened!") {}
129+
.environment(POSPreviewHelpers.makePreviewAggregateModel())
132130
}
133131

134132
#Preview {
135-
if #available(iOS 17.0, *) {
136-
PointOfSaleOrderSyncCouponsErrorMessageView(message: "Lo sentimos, este cupón no se puede aplicar a los productos seleccionados.") {}
137-
.environment(POSPreviewHelpers.makePreviewAggregateModel())
138-
}
133+
PointOfSaleOrderSyncCouponsErrorMessageView(message: "Lo sentimos, este cupón no se puede aplicar a los productos seleccionados.") {}
134+
.environment(POSPreviewHelpers.makePreviewAggregateModel())
139135
}
140136
#endif

WooCommerce/Classes/POS/TabBar/POSIneligibleView.swift

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -209,48 +209,38 @@ private extension POSIneligibleReason {
209209
#if DEBUG
210210

211211
#Preview("Unsupported currency") {
212-
if #available(iOS 17.0, *) {
213-
POSIneligibleView(
214-
reason: .unsupportedCurrency(countryCode: .US, supportedCurrencies: [.USD]),
215-
onRefresh: {}
216-
)
217-
}
212+
POSIneligibleView(
213+
reason: .unsupportedCurrency(countryCode: .US, supportedCurrencies: [.USD]),
214+
onRefresh: {}
215+
)
218216
}
219217

220218
#Preview("WooCommerce plugin not found") {
221-
if #available(iOS 17.0, *) {
222-
POSIneligibleView(
223-
reason: .wooCommercePluginNotFound,
224-
onRefresh: {}
225-
)
226-
}
219+
POSIneligibleView(
220+
reason: .wooCommercePluginNotFound,
221+
onRefresh: {}
222+
)
227223
}
228224

229225
#Preview("Feature switch disabled") {
230-
if #available(iOS 17.0, *) {
231-
POSIneligibleView(
232-
reason: .featureSwitchDisabled,
233-
onRefresh: {}
234-
)
235-
}
226+
POSIneligibleView(
227+
reason: .featureSwitchDisabled,
228+
onRefresh: {}
229+
)
236230
}
237231

238232
#Preview("Site settings unavailable") {
239-
if #available(iOS 17.0, *) {
240-
POSIneligibleView(
241-
reason: .siteSettingsNotAvailable,
242-
onRefresh: {}
243-
)
244-
}
233+
POSIneligibleView(
234+
reason: .siteSettingsNotAvailable,
235+
onRefresh: {}
236+
)
245237
}
246238

247239
#Preview("Unsupported WooCommerce version") {
248-
if #available(iOS 17.0, *) {
249-
POSIneligibleView(
250-
reason: .unsupportedWooCommerceVersion(minimumVersion: "9.6.0"),
251-
onRefresh: {}
252-
)
253-
}
240+
POSIneligibleView(
241+
reason: .unsupportedWooCommerceVersion(minimumVersion: "9.6.0"),
242+
onRefresh: {}
243+
)
254244
}
255245

256246
#endif

WooCommerce/Classes/POS/TabBar/POSTabCoordinator.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,7 @@ private extension POSTabCoordinator {
146146
let orderService = POSOrderService(siteID: siteID,
147147
credentials: credentials,
148148
selectedSite: defaultSitePublisher,
149-
appPasswordSupportState: isAppPasswordSupported),
150-
#available(iOS 17.0, *) {
149+
appPasswordSupportState: isAppPasswordSupported) {
151150
let posView = PointOfSaleEntryPointView(
152151
siteID: siteID,
153152
itemFetchStrategyFactory: posItemFetchStrategyFactory,

WooCommerce/Classes/ViewModels/Order Details/OrderPaymentDetailsViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ final class OrderPaymentDetailsViewModel {
1212
}
1313

1414
var subtotalValue: String {
15-
return order.subtotalValue(currencyFormatter: currencyFormatter) ?? String()
15+
return order.subtotalValue(currencyFormatter: currencyFormatter)
1616
}
1717

1818
var shouldHideSubtotal: Bool {

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/Payments Menu/InPersonPaymentsMenu.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ struct InPersonPaymentsMenu: View {
8282
viewModel.purchaseCardReaderTapped()
8383
} label: {
8484
PaymentsRow(image: Image(uiImage: .shoppingCartIcon),
85-
title: Localization.purchaseCardReader,
86-
isActive: $viewModel.presentPurchaseCardReader) {
87-
AuthenticatedWebView(isPresented: .constant(true),
88-
viewModel: viewModel.purchaseCardReaderWebViewModel)
89-
}
85+
title: Localization.purchaseCardReader)
9086
}
9187
.buttonStyle(.scrollViewRow)
88+
.navigationDestination(isPresented: $viewModel.presentPurchaseCardReader) {
89+
AuthenticatedWebView(isPresented: .constant(true),
90+
viewModel: viewModel.purchaseCardReaderWebViewModel)
91+
}
9292

9393
Button {
9494
viewModel.manageCardReadersTapped()
@@ -118,12 +118,12 @@ struct InPersonPaymentsMenu: View {
118118
viewModel.cardReaderManualsTapped()
119119
} label: {
120120
PaymentsRow(image: Image(uiImage: .cardReaderManualIcon),
121-
title: Localization.cardReaderManuals,
122-
isActive: $viewModel.presentCardReaderManuals) {
123-
CardReaderManualsView()
124-
}
121+
title: Localization.cardReaderManuals)
125122
}
126123
.buttonStyle(.scrollViewRow)
124+
.navigationDestination(isPresented: $viewModel.presentCardReaderManuals) {
125+
CardReaderManualsView()
126+
}
127127
.accessibilityIdentifier(AccessibilityIdentifiers.cardReaderManualRow)
128128
} header: {
129129
Text(Localization.cardReaderSectionTitle.uppercased())

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/Payments Menu/PaymentsRow.swift

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
import SwiftUI
22

3-
struct PaymentsRow<Destination>: View where Destination: View {
3+
struct PaymentsRow: View {
44
private let image: Image
55
private let title: String
66
private let subtitle: String?
77
private let shouldBadgeImage: Bool
8-
private var isActive: Binding<Bool>?
9-
@ViewBuilder private let destination: (() -> Destination)?
108

119
init(image: Image,
1210
title: String,
1311
subtitle: String? = nil,
14-
shouldBadgeImage: Bool = false,
15-
isActive: Binding<Bool>,
16-
@ViewBuilder destination: @escaping () -> Destination) {
12+
shouldBadgeImage: Bool = false) {
1713
self.image = image
1814
self.title = title
1915
self.subtitle = subtitle
2016
self.shouldBadgeImage = shouldBadgeImage
21-
self.destination = destination
22-
self.isActive = isActive
2317
}
2418

2519
var body: some View {
@@ -49,36 +43,6 @@ struct PaymentsRow<Destination>: View where Destination: View {
4943
Spacer()
5044
}
5145
.contentShape(Rectangle())
52-
53-
navigationLink
54-
}
55-
56-
@ViewBuilder
57-
private var navigationLink: some View {
58-
if let isActive,
59-
let destination {
60-
NavigationLink(isActive: isActive) {
61-
destination()
62-
} label: {
63-
EmptyView()
64-
}
65-
} else {
66-
EmptyView()
67-
}
68-
}
69-
}
70-
71-
extension PaymentsRow where Destination == Never {
72-
init(image: Image,
73-
title: String,
74-
subtitle: String? = nil,
75-
shouldBadgeImage: Bool = false) {
76-
self.image = image
77-
self.title = title
78-
self.subtitle = subtitle
79-
self.shouldBadgeImage = shouldBadgeImage
80-
self.destination = nil
81-
self.isActive = nil
8246
}
8347
}
8448

WooCommerce/Classes/ViewRelated/Orders/Order Details/Address Edit/AddressMapPickerView.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,5 @@ private extension AddressMapPickerView {
162162
}
163163

164164
#Preview {
165-
if #available(iOS 17, *) {
166-
AddressMapPickerView(fields: .constant(.init()), countryByCode: { _ in nil })
167-
} else {
168-
EmptyView()
169-
}
165+
AddressMapPickerView(fields: .constant(.init()), countryByCode: { _ in nil })
170166
}

WooCommerce/Classes/ViewRelated/Orders/Order Details/Address Edit/EditOrderAddressForm.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,7 @@ struct SingleAddressForm: View {
244244
}
245245
}
246246
.sheet(isPresented: $showMapPicker) {
247-
if #available(iOS 17, *) {
248-
AddressMapPickerView(fields: $fields, countryByCode: countryByCode)
249-
}
247+
AddressMapPickerView(fields: $fields, countryByCode: countryByCode)
250248
}
251249
}
252250

@@ -324,7 +322,7 @@ struct SingleAddressForm: View {
324322
.padding(.horizontal, insets: safeAreaInsets)
325323
.accessibility(addTraits: .isHeader)
326324
VStack(spacing: 0) {
327-
if #available(iOS 17, *), ServiceLocator.featureFlagService.isFeatureFlagEnabled(.orderAddressMapSearch) {
325+
if ServiceLocator.featureFlagService.isFeatureFlagEnabled(.orderAddressMapSearch) {
328326
Button(action: {
329327
showMapPicker = true
330328
ServiceLocator.analytics.track(.orderDetailEditAddressMapPickerTapped,

WooCommerce/Classes/ViewRelated/ReusableViews/SwiftUI Components/BadgeView.swift

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,9 @@ private extension BadgeView {
9696
func backgroundView() -> some View {
9797
switch backgroundShape {
9898
case .circle:
99-
if #available(iOS 17, *) {
100-
Circle()
101-
.fill(customizations.backgroundColor)
102-
.stroke(Color.white, lineWidth: Layout.borderLineWidth)
103-
} else {
104-
ZStack {
105-
Circle()
106-
.fill(customizations.backgroundColor)
107-
Circle()
108-
.stroke(Color.white, lineWidth: Layout.borderLineWidth)
109-
}
110-
}
99+
Circle()
100+
.fill(customizations.backgroundColor)
101+
.stroke(Color.white, lineWidth: Layout.borderLineWidth)
111102
case .roundedRectangle(let cornerRadius):
112103
RoundedRectangle(cornerRadius: cornerRadius)
113104
.stroke(.white, lineWidth: Layout.borderLineWidth)

0 commit comments

Comments
 (0)