Skip to content

Commit 4ae12d2

Browse files
authored
Merge branch 'trunk' into issue/14004-better-application-password-disabled-note-take-2
2 parents dc68ebc + ff996a8 commit 4ae12d2

24 files changed

+412
-108
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
- [*] Now, usernames and emails in text fields across multiple login views are no longer capitalized. [https://github.com/woocommerce/woocommerce-ios/pull/15002]
88
- [*] Product Details: Display cover tag on the first product image [https://github.com/woocommerce/woocommerce-ios/pull/15041]
99
- [*] Payments: Update learn more links to open Stripe-specific docs when using that gateway [https://github.com/woocommerce/woocommerce-ios/pull/15035]
10+
- [*] Orders: Improved accessibility UI for Tax Rates related views [https://github.com/woocommerce/woocommerce-ios/pull/15043]
11+
- [*] Product Details: Display cover tag on the first product image [https://github.com/woocommerce/woocommerce-ios/pull/15041]
12+
- [*] Payments: Update learn more links to open Stripe-specific docs when using that gateway [https://github.com/woocommerce/woocommerce-ios/pull/15035]
13+
- [*] Now, usernames and emails in text fields across multiple login views are no longer capitalized. [https://github.com/woocommerce/woocommerce-ios/pull/15002]
1014

1115
21.6
1216
-----

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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ protocol PointOfSaleAggregateModelProtocol {
3737
func checkOut() async
3838
}
3939

40+
@available(iOS 17.0, *)
4041
class PointOfSaleAggregateModel: ObservableObject, PointOfSaleAggregateModelProtocol {
4142
@Published private(set) var orderStage: PointOfSaleOrderStage = .building
4243

@@ -86,6 +87,7 @@ class PointOfSaleAggregateModel: ObservableObject, PointOfSaleAggregateModelProt
8687
}
8788

8889
// MARK: - ItemList
90+
@available(iOS 17.0, *)
8991
extension PointOfSaleAggregateModel {
9092
private func publishItemsViewState() {
9193
itemsController.itemsViewStatePublisher.assign(to: &$itemsViewState)
@@ -117,6 +119,7 @@ private extension POSItem {
117119
}
118120
}
119121

122+
@available(iOS 17.0, *)
120123
extension PointOfSaleAggregateModel {
121124
func addToCart(_ item: POSItem) {
122125
guard let cartItem = item.cartItem else { return }
@@ -149,7 +152,7 @@ extension PointOfSaleAggregateModel {
149152
}
150153

151154
// MARK: - Card payments
152-
155+
@available(iOS 17.0, *)
153156
extension PointOfSaleAggregateModel {
154157
private func publishCardReaderConnectionStatus() {
155158
// When adopting Observable, we can use `assign(to: on:)` here instead
@@ -184,7 +187,7 @@ extension PointOfSaleAggregateModel {
184187
}
185188
}
186189
.removeDuplicates()
187-
.sink { _ in
190+
.sink { [weak self] _ in
188191
Task { @MainActor [weak self] in
189192
await self?.collectCardPayment()
190193
}
@@ -305,6 +308,7 @@ extension PointOfSaleAggregateModel {
305308
}
306309
}
307310

311+
@available(iOS 17.0, *)
308312
private extension PointOfSaleAggregateModel {
309313
func publishPaymentMessages() {
310314
cardPresentPaymentService.paymentEventPublisher
@@ -395,7 +399,7 @@ private extension PointOfSaleAggregateModel {
395399
}
396400

397401
// MARK: - Order syncing
398-
402+
@available(iOS 17.0, *)
399403
extension PointOfSaleAggregateModel {
400404
@MainActor
401405
func checkOut() async {
@@ -415,6 +419,7 @@ extension PointOfSaleAggregateModel {
415419
}
416420
}
417421

422+
@available(iOS 17.0, *)
418423
private extension PointOfSaleAggregateModel {
419424
enum Constants {
420425
static let initialPage: Int = 1

WooCommerce/Classes/POS/Presentation/CardReaderConnection/CardReaderConnectionStatusView.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 17.0, *)
34
struct CardReaderConnectionStatusView: View {
45
@Environment(\.posBackgroundAppearance) var backgroundAppearance
56
@EnvironmentObject var posModel: PointOfSaleAggregateModel
@@ -64,6 +65,7 @@ struct CardReaderConnectionStatusView: View {
6465
}
6566
}
6667

68+
@available(iOS 17.0, *)
6769
private extension CardReaderConnectionStatusView {
6870
@ViewBuilder
6971
func progressIndicatingCardReaderStatus(title: String) -> some View {
@@ -81,6 +83,7 @@ private extension CardReaderConnectionStatusView {
8183
}
8284
}
8385

86+
@available(iOS 17.0, *)
8487
private extension CardReaderConnectionStatusView {
8588
var connectedFontColor: Color {
8689
switch backgroundAppearance {
@@ -101,6 +104,7 @@ private extension CardReaderConnectionStatusView {
101104
}
102105
}
103106

107+
@available(iOS 17.0, *)
104108
private extension CardReaderConnectionStatusView {
105109
enum Constants {
106110
static let buttonImageAndTextSpacing: CGFloat = 12
@@ -118,6 +122,7 @@ private extension CardReaderConnectionStatusView {
118122
}
119123
}
120124

125+
@available(iOS 17.0, *)
121126
private extension CardReaderConnectionStatusView {
122127
enum Localization {
123128
static let readerConnected = NSLocalizedString(
@@ -156,6 +161,7 @@ private extension CardReaderConnectionStatusView {
156161

157162
#if DEBUG
158163

164+
@available(iOS 17.0, *)
159165
#Preview {
160166
VStack {
161167
CardReaderConnectionStatusView()

WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/PointOfSaleCardPresentPaymentInLineMessage.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 17.0, *)
34
struct PointOfSaleCardPresentPaymentInLineMessage: View {
45
private let messageType: PointOfSaleCardPresentPaymentMessageType
56

@@ -45,6 +46,7 @@ struct PointOfSaleCardPresentPaymentInLineMessage: View {
4546
private var animation: POSCardPresentPaymentInLineMessageAnimation { .init(namespace: namespace) }
4647
}
4748

49+
@available(iOS 17.0, *)
4850
#Preview {
4951
PointOfSaleCardPresentPaymentInLineMessage(messageType: .processing(
5052
viewModel: PointOfSaleCardPresentPaymentProcessingMessageViewModel()))

WooCommerce/Classes/POS/Presentation/CardReaderConnection/UI States/Reader Messages/PointOfSalePaymentSuccessView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 17.0, *)
34
struct PointOfSalePaymentSuccessView: View {
45
let viewModel: PointOfSalePaymentSuccessViewModel
56
@Environment(\.colorScheme) var colorScheme
@@ -88,6 +89,7 @@ struct PointOfSalePaymentSuccessView: View {
8889
}
8990
}
9091

92+
@available(iOS 17.0, *)
9193
private extension PointOfSalePaymentSuccessView {
9294
enum Constants {
9395
static let imageName: String = "checkmark"
@@ -102,6 +104,7 @@ private extension PointOfSalePaymentSuccessView {
102104
}
103105
}
104106

107+
@available(iOS 17.0, *)
105108
#Preview {
106109
return PointOfSalePaymentSuccessView(
107110
viewModel: PointOfSalePaymentSuccessViewModel(formattedOrderTotal: "$3.00",

WooCommerce/Classes/POS/Presentation/CartView.swift

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import SwiftUI
22

3+
@available(iOS 17.0, *)
34
struct CartView: View {
45
@EnvironmentObject private var posModel: PointOfSaleAggregateModel
56
private let viewHelper = CartViewHelper()
@@ -14,6 +15,8 @@ struct CartView: View {
1415
posModel.cart.isNotEmpty && offSetPosition < 0
1516
}
1617

18+
@State private var shouldShowItemImages: Bool = false
19+
1720
var body: some View {
1821
VStack {
1922
DynamicHStack(spacing: Constants.cartHeaderSpacing) {
@@ -70,6 +73,7 @@ struct CartView: View {
7073
VStack(spacing: Constants.cartItemSpacing) {
7174
ForEach(posModel.cart, id: \.id) { cartItem in
7275
ItemRowView(cartItem: cartItem,
76+
showImage: $shouldShowItemImages,
7377
onItemRemoveTapped: posModel.orderStage == .building ? {
7478
posModel.remove(cartItem: cartItem)
7579
} : nil)
@@ -81,6 +85,15 @@ struct CartView: View {
8185
.background(GeometryReader { geometry in
8286
Color.clear.preference(key: ScrollOffSetPreferenceKey.self,
8387
value: geometry.frame(in: coordinateSpace).origin.y)
88+
.onAppear {
89+
updateItemImageVisibility(cartListWidth: geometry.size.width)
90+
}
91+
.onChange(of: geometry.size.width) {
92+
updateItemImageVisibility(cartListWidth: $0)
93+
}
94+
.onChange(of: dynamicTypeSize) {
95+
updateItemImageVisibility(dynamicTypeSize: $0, cartListWidth: geometry.size.width)
96+
}
8497
})
8598
.onPreferenceChange(ScrollOffSetPreferenceKey.self) { position in
8699
self.offSetPosition = position
@@ -135,6 +148,7 @@ private struct ScrollOffSetPreferenceKey: PreferenceKey {
135148
}
136149
}
137150

151+
@available(iOS 17.0, *)
138152
private extension CartView {
139153
var backgroundColor: Color {
140154
switch colorScheme {
@@ -156,8 +170,42 @@ private extension CartView {
156170
cart: posModel.cart,
157171
orderStage: posModel.orderStage)
158172
}
173+
174+
func updateItemImageVisibility(dynamicTypeSize: DynamicTypeSize? = nil, cartListWidth: CGFloat) {
175+
let newVisibility = cartListWidth >= minimumWidthToShowItemImages(with: dynamicTypeSize ?? self.dynamicTypeSize)
176+
guard newVisibility != shouldShowItemImages else {
177+
return
178+
}
179+
shouldShowItemImages = newVisibility
180+
}
181+
182+
func minimumWidthToShowItemImages(with dynamicTypeSize: DynamicTypeSize) -> CGFloat {
183+
switch dynamicTypeSize {
184+
case .xSmall, .small:
185+
240
186+
case .medium:
187+
260
188+
case .large:
189+
270
190+
case .xLarge:
191+
280
192+
case .xxLarge, .xxxLarge:
193+
300
194+
case .accessibility1:
195+
320
196+
case .accessibility2:
197+
400
198+
case .accessibility3, .accessibility4:
199+
420
200+
case .accessibility5:
201+
450
202+
@unknown default:
203+
450
204+
}
205+
}
159206
}
160207

208+
@available(iOS 17.0, *)
161209
private extension CartView {
162210
enum Constants {
163211
static let primaryFont: POSFontStyle = .posTitleEmphasized
@@ -201,6 +249,7 @@ private extension CartView {
201249

202250
/// View sub-components
203251
///
252+
@available(iOS 17.0, *)
204253
private extension CartView {
205254
var checkoutButton: some View {
206255
Button {
@@ -254,6 +303,7 @@ private extension CartView {
254303
}
255304

256305
#if DEBUG
306+
@available(iOS 17.0, *)
257307
#Preview {
258308
let itemsController = PointOfSalePreviewItemsController()
259309
let posModel = PointOfSaleAggregateModel(

WooCommerce/Classes/POS/Presentation/Item Selector/ChildItemList.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import SwiftUI
22
import Yosemite
33

44
/// Displays a scrollable list of child items in POS.
5+
@available(iOS 17.0, *)
56
struct ChildItemList: View {
67
private let parentItem: POSItem
78
private let title: String
@@ -46,6 +47,7 @@ struct ChildItemList: View {
4647
}
4748
}
4849

50+
@available(iOS 17.0, *)
4951
private extension ChildItemList {
5052
@ViewBuilder var headerView: some View {
5153
HStack {
@@ -104,6 +106,7 @@ private extension ChildItemList {
104106
}
105107
}
106108

109+
@available(iOS 17.0, *)
107110
private extension ChildItemList {
108111
enum Localization {
109112
static let back = NSLocalizedString(
@@ -120,6 +123,7 @@ private extension ChildItemList {
120123

121124
#if DEBUG
122125

126+
@available(iOS 17.0, *)
123127
#Preview("Variable product child items") {
124128
let parentProduct = POSVariableParentProduct(
125129
id: .init(),
@@ -166,6 +170,7 @@ private extension ChildItemList {
166170
.environmentObject(posModel)
167171
}
168172

173+
@available(iOS 17.0, *)
169174
#Preview("Variable items load error") {
170175
let parentProduct = POSVariableParentProduct(
171176
id: .init(),

WooCommerce/Classes/POS/Presentation/Item Selector/ItemList.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import protocol WooFoundation.Analytics
44
import struct Yosemite.POSVariableParentProduct
55

66
/// Displays a list of POS items or placeholder card based on the given state.
7+
@available(iOS 17.0, *)
78
struct ItemList<HeaderView: View>: View {
89
@Environment(\.floatingControlAreaSize) private var floatingControlAreaSize: CGSize
910
@EnvironmentObject var posModel: PointOfSaleAggregateModel
@@ -75,6 +76,7 @@ private enum Constants {
7576
static let itemSpacing: CGFloat = 16
7677
}
7778

79+
@available(iOS 17.0, *)
7880
private struct ItemListRow: View {
7981
let item: POSItem
8082
let analytics: Analytics = ServiceLocator.analytics
@@ -106,6 +108,7 @@ private struct ItemListRow: View {
106108
}
107109
}
108110

111+
@available(iOS 17.0, *)
109112
private extension ItemListRow {
110113
enum Localization {
111114
static let variationsAvailable = NSLocalizedString(
@@ -117,7 +120,7 @@ private extension ItemListRow {
117120
}
118121

119122
#if DEBUG
120-
123+
@available(iOS 17.0, *)
121124
#Preview("Loaded with items") {
122125
ItemList(
123126
state:
@@ -146,6 +149,7 @@ private extension ItemListRow {
146149
)
147150
}
148151

152+
@available(iOS 17.0, *)
149153
#Preview("Loading") {
150154
let posModel = PointOfSaleAggregateModel(
151155
itemsController: PointOfSalePreviewItemsController(),

0 commit comments

Comments
 (0)