Skip to content

Commit 0d3a82c

Browse files
authored
Merge pull request #5415 from woocommerce/issue/5289-icons
Add icons to rows on the Card Reader settings screen
2 parents 7221929 + 84924ca commit 0d3a82c

File tree

9 files changed

+117
-12
lines changed

9 files changed

+117
-12
lines changed

WooCommerce/Classes/Extensions/UIImage+Woo.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,30 @@ extension UIImage {
408408
return UIImage(named: "card-reader-low-battery")!
409409
}
410410

411+
/// Shopping cart
412+
///
413+
static var shoppingCartIcon: UIImage {
414+
return UIImage(named: "icon-shopping-cart")!
415+
.withRenderingMode(.alwaysTemplate)
416+
.imageFlippedForRightToLeftLayoutDirection()
417+
}
418+
419+
/// Credit card
420+
///
421+
static var creditCardIcon: UIImage {
422+
return UIImage(named: "icon-card")!
423+
.withRenderingMode(.alwaysTemplate)
424+
.imageFlippedForRightToLeftLayoutDirection()
425+
}
426+
427+
/// Card Reader Manual
428+
///
429+
static var cardReaderManualIcon: UIImage {
430+
return UIImage(named: "icon-card-reader-manual")!
431+
.withRenderingMode(.alwaysTemplate)
432+
.imageFlippedForRightToLeftLayoutDirection()
433+
}
434+
411435
/// Files Download Icon
412436
///
413437
static var cloudImage: UIImage {

WooCommerce/Classes/ViewRelated/Dashboard/Settings/In-Person Payments/InPersonPaymentsMenuViewController.swift

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,33 +50,36 @@ private extension InPersonPaymentsMenuViewController {
5050
///
5151
func configure(_ cell: UITableViewCell, for row: Row, at indexPath: IndexPath) {
5252
switch cell {
53-
case let cell as BasicTableViewCell where row == .orderCardReader:
53+
case let cell as LeftImageTableViewCell where row == .orderCardReader:
5454
configureOrderCardReader(cell: cell)
55-
case let cell as BasicTableViewCell where row == .manageCardReader:
55+
case let cell as LeftImageTableViewCell where row == .manageCardReader:
5656
configureManageCardReader(cell: cell)
57-
case let cell as BasicTableViewCell where row == .bbposChipper2XBTManual:
57+
case let cell as LeftImageTableViewCell where row == .bbposChipper2XBTManual:
5858
configureBBPOSChipper2XBTManual(cell: cell)
5959
default:
6060
fatalError()
6161
}
6262
}
6363

64-
func configureOrderCardReader(cell: UITableViewCell) {
64+
func configureOrderCardReader(cell: LeftImageTableViewCell) {
65+
cell.imageView?.tintColor = .text
6566
cell.accessoryType = .disclosureIndicator
6667
cell.selectionStyle = .default
67-
cell.textLabel?.text = NSLocalizedString("Order card reader", comment: "Navigates to Card Reader ordering screen")
68+
cell.configure(image: .shoppingCartIcon, text: Localization.orderCardReader)
6869
}
6970

70-
func configureManageCardReader(cell: UITableViewCell) {
71+
func configureManageCardReader(cell: LeftImageTableViewCell) {
72+
cell.imageView?.tintColor = .text
7173
cell.accessoryType = .disclosureIndicator
7274
cell.selectionStyle = .default
73-
cell.textLabel?.text = NSLocalizedString("Manage card reader", comment: "Navigates to Card Reader management screen")
75+
cell.configure(image: .creditCardIcon, text: Localization.manageCardReader)
7476
}
7577

76-
func configureBBPOSChipper2XBTManual(cell: UITableViewCell) {
78+
func configureBBPOSChipper2XBTManual(cell: LeftImageTableViewCell) {
79+
cell.imageView?.tintColor = .text
7780
cell.accessoryType = .disclosureIndicator
7881
cell.selectionStyle = .default
79-
cell.textLabel?.text = NSLocalizedString("Card reader manual", comment: "Navigates to Card Reader manual")
82+
cell.configure(image: .cardReaderManualIcon, text: Localization.cardReaderManual)
8083
}
8184
}
8285

@@ -148,6 +151,27 @@ extension InPersonPaymentsMenuViewController {
148151
}
149152
}
150153

154+
// MARK: - Localizations
155+
//
156+
private extension InPersonPaymentsMenuViewController {
157+
enum Localization {
158+
static let orderCardReader = NSLocalizedString(
159+
"Order card reader",
160+
comment: "Navigates to Card Reader ordering screen"
161+
)
162+
163+
static let manageCardReader = NSLocalizedString(
164+
"Manage card reader",
165+
comment: "Navigates to Card Reader management screen"
166+
)
167+
168+
static let cardReaderManual = NSLocalizedString(
169+
"Card reader manual",
170+
comment: "Navigates to Card Reader manual"
171+
)
172+
}
173+
}
174+
151175
private enum Row: CaseIterable {
152176
case orderCardReader
153177
case manageCardReader
@@ -156,11 +180,11 @@ private enum Row: CaseIterable {
156180
var type: UITableViewCell.Type {
157181
switch self {
158182
case .orderCardReader:
159-
return BasicTableViewCell.self
183+
return LeftImageTableViewCell.self
160184
case .manageCardReader:
161-
return BasicTableViewCell.self
185+
return LeftImageTableViewCell.self
162186
case .bbposChipper2XBTManual:
163-
return BasicTableViewCell.self
187+
return LeftImageTableViewCell.self
164188
}
165189
}
166190

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "icon-card-reader-manual.pdf",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
},
12+
"properties" : {
13+
"preserves-vector-representation" : true
14+
}
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "icon-card.pdf",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
},
12+
"properties" : {
13+
"preserves-vector-representation" : true
14+
}
15+
}
Binary file not shown.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"images" : [
3+
{
4+
"filename" : "icon-shopping-cart.pdf",
5+
"idiom" : "universal"
6+
}
7+
],
8+
"info" : {
9+
"author" : "xcode",
10+
"version" : 1
11+
},
12+
"properties" : {
13+
"preserves-vector-representation" : true
14+
}
15+
}
Binary file not shown.

WooCommerce/WooCommerceTests/Extensions/IconsTests.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,4 +528,16 @@ final class IconsTests: XCTestCase {
528528
func test_lightningImage_is_not_nil() {
529529
XCTAssertNotNil(UIImage.lightningImage)
530530
}
531+
532+
func test_shoppingCartIcon_is_not_nil() {
533+
XCTAssertNotNil(UIImage.shoppingCartIcon)
534+
}
535+
536+
func test_creditCardIcon_is_not_nil() {
537+
XCTAssertNotNil(UIImage.creditCardIcon)
538+
}
539+
540+
func test_cardReaderManualIcon_is_not_nil() {
541+
XCTAssertNotNil(UIImage.cardReaderManualIcon)
542+
}
531543
}

0 commit comments

Comments
 (0)