Skip to content

Commit 72dade1

Browse files
authored
Merge branch 'trunk' into issue/14593-make-pos-aggregate-model-require-iOS-17
2 parents 9f1c91f + a553f74 commit 72dade1

File tree

5 files changed

+116
-66
lines changed

5 files changed

+116
-66
lines changed

Hardware/Hardware/CardReader/StripeCardReader/StripeCardReaderService.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,13 @@ extension StripeCardReaderService: CardReaderService {
430430
}
431431

432432
paymentCancellable.cancel({ [weak self] error in
433-
if error == nil {
433+
// If the action could not be canceled,
434+
// e.g. it has already completed, the completion block will be called with an
435+
// error. Otherwise, the completion block will be called with nil.
436+
if let error {
437+
let underlyingError = Self.logAndDecodeError(error)
438+
promise(.failure(CardReaderServiceError.paymentCancellation(underlyingError: underlyingError)))
439+
} else {
434440
self?.paymentCancellable = nil
435441
cancelPaymentIntent()
436442
}

RELEASE-NOTES.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
*** Use [*****] to indicate smoke tests of all critical flows should be run on the final IPA before release (e.g. major library or OS update).
33
21.7
44
-----
5+
- [*] Orders: Improved accessibility UI for Tax Rates related views [https://github.com/woocommerce/woocommerce-ios/pull/15043]
56
- [*] Product Details: Display cover tag on the first product image [https://github.com/woocommerce/woocommerce-ios/pull/15041]
67
- [*] Payments: Update learn more links to open Stripe-specific docs when using that gateway [https://github.com/woocommerce/woocommerce-ios/pull/15035]
7-
- [x] Now, usernames and emails in text fields across multiple login views are no longer capitalized. [https://github.com/woocommerce/woocommerce-ios/pull/15002]
8+
- [*] Now, usernames and emails in text fields across multiple login views are no longer capitalized. [https://github.com/woocommerce/woocommerce-ios/pull/15002]
89

910
21.6
1011
-----

WooCommerce/Classes/POS/Card Present Payments/CardPresentPaymentService.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ final class CardPresentPaymentService: CardPresentPaymentFacade {
108108
DDLogError("Attempting to cancel the payment has failed \(error)")
109109
}
110110

111+
paymentTask?.cancel()
111112
connectionControllerManager.knownReaderProvider.forgetCardReader()
112113

113114
return await withCheckedContinuation { continuation in

WooCommerce/Classes/POS/Models/PointOfSaleAggregateModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ extension PointOfSaleAggregateModel {
187187
}
188188
}
189189
.removeDuplicates()
190-
.sink { _ in
190+
.sink { [weak self] _ in
191191
Task { @MainActor [weak self] in
192192
await self?.collectCardPayment()
193193
}

WooCommerce/Classes/ViewRelated/Orders/Order Creation/Taxes/NewTaxRateSelectorView.swift

Lines changed: 105 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import SwiftUI
22
import WooFoundation
33

44
struct NewTaxRateSelectorView: View {
5-
/// Scale of the view based on accessibility changes
6-
@ScaledMetric private var scale: CGFloat = 1.0
7-
85
@Environment(\.dismiss) var dismiss
96

107
@StateObject var viewModel: NewTaxRateSelectorViewModel
@@ -22,58 +19,47 @@ struct NewTaxRateSelectorView: View {
2219

2320
var body: some View {
2421
NavigationView {
25-
VStack(alignment: .leading, spacing: 0) {
26-
Group {
27-
HStack(alignment: .top, spacing: Layout.explanatoryBoxHorizontalSpacing) {
28-
Image(systemName: "info.circle")
29-
.foregroundColor(Color(.wooCommercePurple(.shade60)))
30-
Text(Localization.infoText)
31-
}
32-
.padding(Layout.generalPadding)
33-
}
34-
.overlay(
35-
RoundedRectangle(cornerRadius: Layout.explanatoryBoxCornerRadius)
36-
.stroke(Color(.separator), lineWidth: 1)
37-
)
38-
.padding(Layout.generalPadding)
22+
ScrollView {
23+
taxRateSelectorHeaderView
3924

40-
switch viewModel.syncState {
25+
VStack(alignment: .leading, spacing: 0) {
26+
switch viewModel.syncState {
4127
case .results:
42-
Text(Localization.taxRatesSectionTitle.uppercased())
43-
.footnoteStyle()
44-
.multilineTextAlignment(.leading)
45-
.padding([.leading, .trailing], Layout.generalPadding)
46-
.padding([.top, .bottom], Layout.taxRatesSectionTitleVerticalPadding)
47-
48-
Divider()
49-
50-
ScrollView {
51-
LazyVStack(spacing: 0) {
52-
ForEach(Array(viewModel.taxRateViewModels.enumerated()), id: \.offset) { index, taxRateViewModel in
53-
TaxRateRow(viewModel: taxRateViewModel) {
54-
viewModel.onRowSelected(with: index, storeSelectedTaxRate: storeSelectedTaxRate)
55-
dismiss()
56-
}
28+
Text(Localization.taxRatesSectionTitle.uppercased())
29+
.footnoteStyle()
30+
.multilineTextAlignment(.leading)
31+
.padding([.leading, .trailing], Layout.generalPadding)
32+
.padding([.top, .bottom], Layout.taxRatesSectionTitleVerticalPadding)
5733

58-
Divider()
59-
}
60-
.background(Color(.listForeground(modal: false)))
34+
Divider()
6135

62-
resultsListFooter
63-
.renderedIf(!viewModel.shouldShowBottomActivityIndicator)
36+
ScrollView {
37+
LazyVStack(spacing: 0) {
38+
ForEach(Array(viewModel.taxRateViewModels.enumerated()), id: \.offset) { index, taxRateViewModel in
39+
TaxRateRow(viewModel: taxRateViewModel) {
40+
viewModel.onRowSelected(with: index, storeSelectedTaxRate: storeSelectedTaxRate)
41+
dismiss()
42+
}
6443

65-
InfiniteScrollIndicator(showContent: viewModel.shouldShowBottomActivityIndicator)
66-
.padding(.top, Layout.generalPadding)
67-
.onAppear {
68-
viewModel.onLoadNextPageAction()
44+
Divider()
6945
}
46+
.background(Color(.listForeground(modal: false)))
47+
48+
resultsListFooter
49+
.renderedIf(!viewModel.shouldShowBottomActivityIndicator)
50+
51+
InfiniteScrollIndicator(showContent: viewModel.shouldShowBottomActivityIndicator)
52+
.padding(.top, Layout.generalPadding)
53+
.onAppear {
54+
viewModel.onLoadNextPageAction()
55+
}
56+
}
7057
}
71-
}
7258

73-
storeTaxRateBottomView
59+
storeTaxRateBottomView
7460

7561
case .empty:
76-
EmptyState(title: Localization.emptyStateTitle,
62+
EmptyState(title: Localization.emptyStateTitle,
7763
description: Localization.emptyStateDescription,
7864
image: .emptyTaxRatesImage)
7965
.padding(Layout.generalPadding)
@@ -102,6 +88,7 @@ struct NewTaxRateSelectorView: View {
10288
}
10389
}
10490
.background(Color(.listForeground(modal: false)))
91+
}
10592
}
10693
}
10794
.onAppear {
@@ -132,8 +119,29 @@ struct NewTaxRateSelectorView: View {
132119
showingWPAdminWebView = false
133120
})
134121
}
122+
}
123+
124+
private extension NewTaxRateSelectorView {
125+
var taxRateSelectorHeaderView: some View {
126+
Group {
127+
HStack(alignment: .top, spacing: Layout.explanatoryBoxHorizontalSpacing) {
128+
Image(systemName: "info.circle")
129+
.foregroundColor(Color(.wooCommercePurple(.shade60)))
130+
Text(Localization.infoText)
131+
.minimumScaleFactor(0.75)
132+
.allowsTightening(true)
133+
.fixedSize(horizontal: false, vertical: true)
134+
}
135+
.padding(Layout.generalPadding)
136+
}
137+
.overlay(
138+
RoundedRectangle(cornerRadius: Layout.explanatoryBoxCornerRadius)
139+
.stroke(Color(.separator), lineWidth: 1)
140+
)
141+
.padding(Layout.generalPadding)
142+
}
135143

136-
private var resultsListFooter: some View {
144+
var resultsListFooter: some View {
137145
Group {
138146
Text(Localization.listFooterResultsSectionTitle)
139147
.foregroundColor(Color(.textSubtle))
@@ -158,10 +166,9 @@ struct NewTaxRateSelectorView: View {
158166
}
159167
}
160168

161-
private var storeTaxRateBottomView: some View {
169+
var storeTaxRateBottomView: some View {
162170
VStack {
163171
Divider()
164-
165172
Toggle(isOn: $storeSelectedTaxRate) {
166173
VStack(alignment: .leading, spacing: Layout.fixedBottomPanelVerticalSpace) {
167174
Text(Localization.fixedBottomPanelBody)
@@ -193,20 +200,55 @@ extension NewTaxRateSelectorView {
193200
static let fixedBottomPanelVerticalSpace: CGFloat = 4
194201
}
195202
enum Localization {
196-
static let navigationTitle = NSLocalizedString("Set Tax Rate", comment: "Navigation title for the tax rate selector")
197-
static let cancelButton = NSLocalizedString("Cancel", comment: "Cancel button title for the tax rate selector")
198-
static let infoText = NSLocalizedString("This will change the customer’s address to the location of the tax rate you select.",
199-
comment: "Explanatory text for the tax rate selector")
200-
static let taxRatesSectionTitle = NSLocalizedString("Select a tax rate", comment: "Title for the tax rate selector section")
201-
static let editTaxRatesInWpAdminButtonTitle = NSLocalizedString("Edit tax rates in admin",
202-
comment: "Title of the button that prompts the user to edit tax rates in the web")
203-
static let emptyStateTitle = NSLocalizedString("We couldn’t find any tax rates", comment: "Title for the empty state on the Tax Rates selector screen")
204-
static let emptyStateDescription = NSLocalizedString("Add tax rates in admin. Only tax rates with location information will be shown here.",
205-
comment: "Description for the empty state on the Tax Rates selector screen")
206-
static let listFooterResultsSectionTitle = NSLocalizedString("Can’t find the rate you’re looking for?",
207-
comment: "Text to prompt the user to edit tax rates in the web")
208-
static let fixedBottomPanelBody = NSLocalizedString("Add this rate to all created orders", comment: "Body for the action to store selected tax rate")
209-
static let fixedBottomPanelFootnote = NSLocalizedString("This will not affect online orders",
210-
comment: "Footnote for the action to store selected tax rate")
203+
static let navigationTitle = NSLocalizedString(
204+
"newTaxRateSelectorView.navigationTitle",
205+
value: "Set Tax Rate",
206+
comment: "Navigation title for the tax rate selector")
207+
static let cancelButton = NSLocalizedString(
208+
"newTaxRateSelectorView.cancelButton",
209+
value: "Cancel",
210+
comment: "Cancel button title for the tax rate selector")
211+
static let infoText = NSLocalizedString(
212+
"newTaxRateSelectorView.infoText",
213+
value: "This will change the customer’s address to the location of the tax rate you select.",
214+
comment: "Explanatory text for the tax rate selector")
215+
static let taxRatesSectionTitle = NSLocalizedString(
216+
"newTaxRateSelectorView.taxRatesSectionTitle",
217+
value: "Select a tax rate",
218+
comment: "Title for the tax rate selector section")
219+
static let editTaxRatesInWpAdminButtonTitle = NSLocalizedString(
220+
"newTaxRateSelectorView.editTaxRatesInWpAdminButtonTitle",
221+
value: "Edit tax rates in admin",
222+
comment: "Title of the button that prompts the user to edit tax rates in the web")
223+
static let emptyStateTitle = NSLocalizedString(
224+
"newTaxRateSelectorView.emptyStateTitle",
225+
value: "We couldn’t find any tax rates",
226+
comment: "Title for the empty state on the Tax Rates selector screen")
227+
static let emptyStateDescription = NSLocalizedString(
228+
"newTaxRateSelectorView.emptyStateDescription",
229+
value: "Add tax rates in admin. Only tax rates with location information will be shown here.",
230+
comment: "Description for the empty state on the Tax Rates selector screen")
231+
static let listFooterResultsSectionTitle = NSLocalizedString(
232+
"newTaxRateSelectorView.listFooterResultsSectionTitle",
233+
value: "Can’t find the rate you’re looking for?",
234+
comment: "Text to prompt the user to edit tax rates in the web")
235+
static let fixedBottomPanelBody = NSLocalizedString(
236+
"newTaxRateSelectorView.taxRfixedBottomPanelBodyatesSectionTitle",
237+
value: "Add this rate to all created orders",
238+
comment: "Body for the action to store selected tax rate")
239+
static let fixedBottomPanelFootnote = NSLocalizedString(
240+
"newTaxRateSelectorView.fixedBottomPanelFootnote",
241+
value: "This will not affect online orders",
242+
comment: "Footnote for the action to store selected tax rate")
211243
}
212244
}
245+
246+
#Preview {
247+
let viewModel = NewTaxRateSelectorViewModel(siteID: 123, onTaxRateSelected: { _ in })
248+
let taxEduViewModel = TaxEducationalDialogViewModel(orderTaxLines: [], taxBasedOnSetting: nil)
249+
250+
NewTaxRateSelectorView(viewModel: viewModel,
251+
taxEducationalDialogViewModel: taxEduViewModel,
252+
onDismissWpAdminWebView: { },
253+
storeSelectedTaxRate: false)
254+
}

0 commit comments

Comments
 (0)