Skip to content

Commit 7e38109

Browse files
authored
Merge pull request #6206 from woocommerce/issue/6203-variable-product-style
Order Creation: Fix styles for variable product rows in the product list
2 parents aa3e5e9 + 77a4675 commit 7e38109

File tree

7 files changed

+46
-31
lines changed

7 files changed

+46
-31
lines changed

WooCommerce/Classes/ViewRelated/Orders/Order Creation/ProductsSection/AddProductToOrder.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ struct AddProductToOrder: View {
6565
if rowViewModel.numberOfVariations > 0,
6666
let addVariationToOrderVM = viewModel.getVariationsViewModel(for: rowViewModel.productOrVariationID) {
6767
LazyNavigationLink(destination: AddProductVariationToOrder(isPresented: $isPresented, viewModel: addVariationToOrderVM)) {
68-
ProductRow(viewModel: rowViewModel)
68+
HStack {
69+
ProductRow(viewModel: rowViewModel)
70+
.frame(maxWidth: .infinity, alignment: .leading)
71+
72+
DisclosureIndicator()
73+
}
6974
}
7075
} else {
7176
ProductRow(viewModel: rowViewModel)

WooCommerce/Classes/ViewRelated/Orders/Order Creation/ProductsSection/ProductRow.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct ProductRow: View {
3030
// Product details
3131
VStack(alignment: .leading) {
3232
Text(viewModel.name)
33+
.bodyStyle()
3334
Text(viewModel.productDetailsLabel)
3435
.subheadlineStyle()
3536
Text(viewModel.skuLabel)

WooCommerce/Classes/ViewRelated/Orders/Simple Payments/Method/SimplePaymentsMethod.swift

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,7 @@ private struct MethodRow: View {
150150
}
151151
.frame(maxWidth: .infinity, alignment: .leading)
152152

153-
Image(uiImage: .chevronImage)
154-
.resizable()
155-
.flipsForRightToLeftLayoutDirection(true)
156-
.frame(width: SimplePaymentsMethod.Layout.chevronWidthHeight(scale: scale),
157-
height: SimplePaymentsMethod.Layout.chevronWidthHeight(scale: scale))
158-
.foregroundColor(Color(.systemGray))
159-
.accessibility(hidden: true)
153+
DisclosureIndicator()
160154
}
161155
.padding(.vertical, SimplePaymentsMethod.Layout.verticalPadding)
162156
.padding(.horizontal, insets: safeAreaInsets)
@@ -206,10 +200,6 @@ private extension SimplePaymentsMethod {
206200
static func iconWidthHeight(scale: CGFloat) -> CGFloat {
207201
24 * scale
208202
}
209-
210-
static func chevronWidthHeight(scale: CGFloat) -> CGFloat {
211-
22 * scale
212-
}
213203
}
214204
}
215205

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import SwiftUI
2+
3+
struct DisclosureIndicator: View {
4+
/// Keeps track of the current screen scale
5+
///
6+
@ScaledMetric private var scale = 1
7+
8+
var body: some View {
9+
Image(uiImage: .chevronImage)
10+
.resizable()
11+
.flipsForRightToLeftLayoutDirection(true)
12+
.frame(width: Constants.chevronSize(scale: scale), height: Constants.chevronSize(scale: scale))
13+
.foregroundColor(Color(.systemGray))
14+
.accessibility(hidden: true)
15+
}
16+
}
17+
18+
// MARK: Constants
19+
private extension DisclosureIndicator {
20+
enum Constants {
21+
static func chevronSize(scale: CGFloat) -> CGFloat {
22+
22 * scale
23+
}
24+
}
25+
}
26+
27+
struct DisclosureIndicator_Previews: PreviewProvider {
28+
static var previews: some View {
29+
DisclosureIndicator()
30+
.previewLayout(.sizeThatFits)
31+
}
32+
}

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ struct NavigationRow<Content: View>: View {
1616
///
1717
let action: () -> Void
1818

19-
/// Keeps track of the current screen scale
20-
///
21-
@ScaledMetric private var scale = 1
22-
2319
/// Environment safe areas
2420
///
2521
@Environment(\.safeAreaInsets) var safeAreaInsets: EdgeInsets
@@ -37,13 +33,7 @@ struct NavigationRow<Content: View>: View {
3733
HStack {
3834
content
3935
Spacer()
40-
Image(uiImage: .chevronImage)
41-
.resizable()
42-
.flipsForRightToLeftLayoutDirection(true)
43-
.frame(width: Layout.chevronWidthHeight(scale: scale),
44-
height: Layout.chevronWidthHeight(scale: scale))
45-
.foregroundColor(Color(.systemGray))
46-
.accessibility(hidden: true)
36+
DisclosureIndicator()
4737
.renderedIf(selectable)
4838
}
4939
.padding()
@@ -56,9 +46,6 @@ struct NavigationRow<Content: View>: View {
5646

5747
private enum Layout {
5848
static let minHeight: CGFloat = 44
59-
static func chevronWidthHeight(scale: CGFloat) -> CGFloat {
60-
22 * scale
61-
}
6249
}
6350

6451
struct NavigationRow_Previews: PreviewProvider {

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@ struct TitleAndValueRow: View {
4141
.padding(.vertical, Constants.verticalPadding)
4242
}
4343

44-
Image(uiImage: .chevronImage)
45-
.flipsForRightToLeftLayoutDirection(true)
44+
DisclosureIndicator()
4645
.renderedIf(selectionStyle == .disclosure)
47-
.frame(width: Constants.imageSize, height: Constants.imageSize)
48-
.foregroundColor(Color(UIColor.gray(.shade30)))
4946
}
5047
.contentShape(Rectangle())
5148
})
@@ -107,7 +104,6 @@ private extension Text {
107104

108105
private extension TitleAndValueRow {
109106
enum Constants {
110-
static let imageSize: CGFloat = 22
111107
static let minHeight: CGFloat = 44
112108
static let maxHeight: CGFloat = 136
113109
static let horizontalPadding: CGFloat = 16

WooCommerce/WooCommerce.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,7 @@
11901190
CC593A6B26EA640800EF0E04 /* PackageCreationError+UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC593A6A26EA640800EF0E04 /* PackageCreationError+UI.swift */; };
11911191
CC69236226010946002FB669 /* LoginProloguePages.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC69236126010946002FB669 /* LoginProloguePages.swift */; };
11921192
CC6923AC26010D8D002FB669 /* LoginProloguePageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC6923AB26010D8D002FB669 /* LoginProloguePageViewController.swift */; };
1193+
CC72BB6427BD842500837876 /* DisclosureIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC72BB6327BD842500837876 /* DisclosureIndicator.swift */; };
11931194
CC770C8A27B1497700CE6ABC /* SearchHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC770C8927B1497700CE6ABC /* SearchHeader.swift */; };
11941195
CC77488E2719A07D0043CDD7 /* ShippingLabelAddressTopBannerFactoryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC77488D2719A07D0043CDD7 /* ShippingLabelAddressTopBannerFactoryTests.swift */; };
11951196
CC8413E423F5C48E00EFC277 /* stop.sh in Resources */ = {isa = PBXBuildFile; fileRef = CCFC011123E9E40B00157A78 /* stop.sh */; };
@@ -2825,6 +2826,7 @@
28252826
CC593A6A26EA640800EF0E04 /* PackageCreationError+UI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "PackageCreationError+UI.swift"; sourceTree = "<group>"; };
28262827
CC69236126010946002FB669 /* LoginProloguePages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginProloguePages.swift; sourceTree = "<group>"; };
28272828
CC6923AB26010D8D002FB669 /* LoginProloguePageViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginProloguePageViewController.swift; sourceTree = "<group>"; };
2829+
CC72BB6327BD842500837876 /* DisclosureIndicator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisclosureIndicator.swift; sourceTree = "<group>"; };
28282830
CC770C8927B1497700CE6ABC /* SearchHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchHeader.swift; sourceTree = "<group>"; };
28292831
CC77488D2719A07D0043CDD7 /* ShippingLabelAddressTopBannerFactoryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShippingLabelAddressTopBannerFactoryTests.swift; sourceTree = "<group>"; };
28302832
CCB366AE274518EC007D437A /* NewOrderViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewOrderViewModelTests.swift; sourceTree = "<group>"; };
@@ -5095,6 +5097,7 @@
50955097
AEACCB6C2785FF4A000D01F0 /* NavigationRow.swift */,
50965098
CCF87BBD279047BC00461C43 /* InfiniteScrollList.swift */,
50975099
CC770C8927B1497700CE6ABC /* SearchHeader.swift */,
5100+
CC72BB6327BD842500837876 /* DisclosureIndicator.swift */,
50985101
);
50995102
path = "SwiftUI Components";
51005103
sourceTree = "<group>";
@@ -8990,6 +8993,7 @@
89908993
0298430C259351F100979CAE /* ShippingLabelsTopBannerFactory.swift in Sources */,
89918994
020BE74D23B1F5EB007FE54C /* TitleAndTextFieldTableViewCell.swift in Sources */,
89928995
023D692E2588BF0900F7DA72 /* ShippingLabelPaperSizeListSelectorCommand.swift in Sources */,
8996+
CC72BB6427BD842500837876 /* DisclosureIndicator.swift in Sources */,
89938997
77E53EC52510C193003D385F /* ProductDownloadListViewController+Droppable.swift in Sources */,
89948998
0259D5F92581F0E6003B1CD6 /* ShippingLabelPaperSizeOptionView.swift in Sources */,
89958999
D81F2D37225F0D160084BF9C /* EmptyListMessageWithActionView.swift in Sources */,

0 commit comments

Comments
 (0)