Skip to content

Commit 1984012

Browse files
committed
Use the same card border modifier as in product card views.
1 parent ac3c0e0 commit 1984012

File tree

1 file changed

+9
-31
lines changed

1 file changed

+9
-31
lines changed

WooCommerce/Classes/POS/Presentation/ItemRowView.swift

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ struct ItemRowView: View {
88
@Environment(\.colorScheme) var colorScheme
99
@Binding private var showProductImage: Bool
1010

11+
private var dimension: CGFloat {
12+
min(Constants.productCardSize * scale, Constants.maximumProductCardSize)
13+
}
14+
1115
init(cartItem: CartItem, showImage: Binding<Bool> = .constant(true), onItemRemoveTapped: (() -> Void)? = nil) {
1216
self.cartItem = cartItem
1317
self._showProductImage = showImage
@@ -49,43 +53,19 @@ struct ItemRowView: View {
4953
}
5054
.frame(maxWidth: .infinity, idealHeight: Constants.productCardSize * scale)
5155
.background(Color.posSurfaceContainerLowest)
52-
.overlay {
53-
RoundedRectangle(cornerRadius: Constants.productCardCornerRadius)
54-
.stroke(Color.posCartItemOutline, lineWidth: cardOutlineWidth)
55-
}
56-
.clipShape(RoundedRectangle(cornerRadius: Constants.productCardCornerRadius))
56+
.posItemCardBorderStyles()
5757
.padding(.horizontal, Constants.horizontalPadding)
5858
}
5959

6060
@ViewBuilder
6161
private var productImage: some View {
6262
if !showProductImage {
6363
EmptyView()
64-
} else if let imageSource = cartItem.item.productImageSource {
65-
ProductImageThumbnail(productImageURL: URL(string: imageSource),
66-
productImageSize: Constants.productCardSize,
67-
scale: scale,
68-
foregroundColor: .clear,
69-
cachesOriginalImage: true)
70-
.frame(width: min(Constants.productCardSize * scale, Constants.maximumProductCardSize),
71-
height: Constants.productCardSize * scale)
72-
.clipped()
7364
} else {
74-
Rectangle()
75-
.frame(width: min(Constants.productCardSize * scale, Constants.maximumProductCardSize),
76-
height: Constants.productCardSize * scale)
77-
.foregroundColor(Color(.secondarySystemFill))
78-
}
79-
}
80-
}
81-
82-
private extension ItemRowView {
83-
var cardOutlineWidth: CGFloat {
84-
switch colorScheme {
85-
case .dark:
86-
return 0
87-
default:
88-
return Constants.cardOutlineWidth
65+
POSItemImageView(imageSource: cartItem.item.productImageSource,
66+
imageSize: dimension,
67+
scale: 1)
68+
.frame(width: dimension, height: dimension)
8969
}
9070
}
9171
}
@@ -94,8 +74,6 @@ private extension ItemRowView {
9474
enum Constants {
9575
static let productCardSize: CGFloat = 96
9676
static let maximumProductCardSize: CGFloat = Self.productCardSize * 1.5
97-
static let productCardCornerRadius: CGFloat = 8
98-
static let cardOutlineWidth: CGFloat = 1
9977
static let horizontalPadding: CGFloat = 16
10078
static let horizontalElementSpacing: CGFloat = 16
10179
static let cardContentHorizontalPadding: CGFloat = 16

0 commit comments

Comments
 (0)