Skip to content

Commit aa03d78

Browse files
committed
Use row as custom button to have better accessbility
1 parent ff1d7b2 commit aa03d78

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

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

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ struct SimplePaymentsMethod: View {
2929
print("Tapped Card")
3030
}
3131
}
32-
.padding(.leading)
32+
.padding(.horizontal)
3333
.background(Color(.listForeground))
3434

3535
Divider()
3636

37+
// Pushes content to the top
3738
Spacer()
3839
}
3940
.background(Color(.listBackground).ignoresSafeArea())
@@ -61,14 +62,27 @@ private struct MethodRow: View {
6162
@ScaledMetric private var scale = 1
6263

6364
var body: some View {
64-
HStack(spacing: SimplePaymentsMethod.Layout.noSpacing) {
65-
Image(uiImage: icon)
66-
.resizable()
67-
.frame(width: SimplePaymentsMethod.Layout.iconWidthHeight(scale: scale),
68-
height: SimplePaymentsMethod.Layout.iconWidthHeight(scale: scale))
69-
.foregroundColor(Color(.systemGray))
70-
71-
TitleAndValueRow(title: title, value: .content(""), selectable: true, action: action)
65+
Button(action: action) {
66+
HStack {
67+
Image(uiImage: icon)
68+
.resizable()
69+
.flipsForRightToLeftLayoutDirection(true)
70+
.frame(width: SimplePaymentsMethod.Layout.iconWidthHeight(scale: scale),
71+
height: SimplePaymentsMethod.Layout.iconWidthHeight(scale: scale))
72+
.foregroundColor(Color(.systemGray))
73+
74+
Text(title)
75+
.bodyStyle()
76+
.frame(maxWidth: .infinity, alignment: .leading)
77+
78+
Image(uiImage: .chevronImage)
79+
.resizable()
80+
.flipsForRightToLeftLayoutDirection(true)
81+
.frame(width: SimplePaymentsMethod.Layout.chevronWidthHeight(scale: scale),
82+
height: SimplePaymentsMethod.Layout.chevronWidthHeight(scale: scale))
83+
.foregroundColor(Color(.systemGray))
84+
}
85+
.padding(.vertical, SimplePaymentsMethod.Layout.verticalPadding)
7286
}
7387
}
7488
}
@@ -83,9 +97,15 @@ private extension SimplePaymentsMethod {
8397

8498
enum Layout {
8599
static let noSpacing: CGFloat = 0
100+
static let verticalPadding: CGFloat = 11
101+
86102
static func iconWidthHeight(scale: CGFloat) -> CGFloat {
87103
24 * scale
88104
}
105+
106+
static func chevronWidthHeight(scale: CGFloat) -> CGFloat {
107+
22 * scale
108+
}
89109
}
90110
}
91111

0 commit comments

Comments
 (0)