Skip to content

Commit 7a4ef7b

Browse files
committed
OrderListCell: Cleanup
1 parent fb1ec25 commit 7a4ef7b

File tree

1 file changed

+42
-7
lines changed

1 file changed

+42
-7
lines changed

WooCommerce/Classes/ViewRelated/Orders/OrderListCell.swift

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
11
import UIKit
22

33

4+
// MARK: - OrderListCell
5+
//
46
class OrderListCell: UITableViewCell {
5-
@IBOutlet var titleLabel: UILabel!
6-
@IBOutlet var totalLabel: UILabel!
7-
@IBOutlet var paymentStatusLabel: PaddedLabel!
87

8+
/// Order's Title
9+
///
10+
@IBOutlet private var titleLabel: UILabel!
911

12+
/// Order's Total
13+
///
14+
@IBOutlet private var totalLabel: UILabel!
15+
16+
/// Payment
17+
///
18+
@IBOutlet private var paymentStatusLabel: PaddedLabel!
19+
20+
21+
/// Renders the specified Order ViewModel
22+
///
1023
func configureCell(viewModel: OrderDetailsViewModel) {
1124
titleLabel.text = viewModel.summaryTitle
12-
titleLabel.applyHeadlineStyle()
1325

1426
totalLabel.text = viewModel.totalFriendlyString
15-
totalLabel.applyBodyStyle()
1627

17-
paymentStatusLabel.text = viewModel.paymentStatus
18-
paymentStatusLabel.applyStatusStyle(for: viewModel.orderStatusViewModel.orderStatus)
28+
paymentStatusLabel.text = viewModel.order.status.description
29+
paymentStatusLabel.applyStyle(for: viewModel.order.status)
30+
}
31+
32+
33+
// MARK: - Overridden Methods
34+
35+
override func awakeFromNib() {
36+
super.awakeFromNib()
37+
configureLabels()
1938
}
2039

2140
override func setSelected(_ selected: Bool, animated: Bool) {
@@ -34,12 +53,28 @@ class OrderListCell: UITableViewCell {
3453
super.prepareForReuse()
3554
paymentStatusLabel.layer.borderColor = UIColor.clear.cgColor
3655
}
56+
}
57+
58+
59+
// MARK: - Private
60+
//
61+
private extension OrderListCell {
3762

63+
/// Preserves the current Payment BG Color
64+
///
3865
func preserveLabelColors(action: () -> Void) {
3966
let paymentColor = paymentStatusLabel.backgroundColor
4067

4168
action()
4269

4370
paymentStatusLabel.backgroundColor = paymentColor
4471
}
72+
73+
/// Setup: Labels
74+
///
75+
func configureLabels() {
76+
titleLabel.applyHeadlineStyle()
77+
totalLabel.applyBodyStyle()
78+
paymentStatusLabel.applyFootnoteStyle()
79+
}
4580
}

0 commit comments

Comments
 (0)