Skip to content

Commit 5c67a10

Browse files
committed
SummaryTableViewCell: Updating Public API
1 parent 2f7be5f commit 5c67a10

File tree

2 files changed

+52
-27
lines changed

2 files changed

+52
-27
lines changed

WooCommerce/Classes/ViewRelated/Orders/OrderDetails/OrderDetailsViewController.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,8 @@ private extension OrderDetailsViewController {
432432
func configureSummary(cell: SummaryTableViewCell) {
433433
cell.title = viewModel.summaryTitle
434434
cell.dateCreated = viewModel.summaryDateCreated
435-
cell.paymentStatus = viewModel.paymentStatus
436-
cell.paymentBackgroundColor = viewModel.paymentBackgroundColor
437-
cell.paymentBorderColor = viewModel.paymentBorderColor
435+
436+
cell.display(orderStatus: viewModel.order.status)
438437
}
439438

440439
// MARK: - Get order note
Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,58 @@
11
import UIKit
2+
import Yosemite
23

4+
5+
// MARK: - SummaryTableViewCell
6+
//
37
class SummaryTableViewCell: UITableViewCell {
8+
9+
/// Label: Title
10+
///
411
@IBOutlet private weak var titleLabel: UILabel!
5-
@IBOutlet private weak var createdLabel: UILabel!
6-
@IBOutlet private weak var paymentStatusLabel: PaddedLabel!
712

8-
public var paymentBackgroundColor: UIColor = .clear
13+
/// Label: Creation / Update Date
14+
///
15+
@IBOutlet private weak var createdLabel: UILabel!
916

17+
/// Label: Payment Status
18+
///
19+
@IBOutlet private weak var paymentStatusLabel: PaddedLabel!
1020

11-
public var title: String? {
21+
/// Title
22+
///
23+
var title: String? {
1224
get {
1325
return titleLabel.text
1426
}
1527
set {
1628
titleLabel.text = newValue
17-
titleLabel.applyHeadlineStyle()
1829
}
1930
}
2031

21-
public var dateCreated: String? {
32+
/// Date
33+
///
34+
var dateCreated: String? {
2235
get {
2336
return createdLabel.text
2437
}
2538
set {
2639
createdLabel.text = newValue
27-
createdLabel.applyFootnoteStyle()
2840
}
2941
}
3042

31-
public var paymentStatus: String? {
32-
get {
33-
return paymentStatusLabel.text
34-
}
35-
set {
36-
paymentStatusLabel.text = newValue
37-
paymentStatusLabel.applyPaddedLabelDefaultStyles()
38-
paymentStatusLabel.backgroundColor = paymentBackgroundColor
39-
}
43+
/// Displays the specified OrderStatus, and applies the right Label Style
44+
///
45+
func display(orderStatus: OrderStatus) {
46+
paymentStatusLabel.text = orderStatus.description
47+
paymentStatusLabel.applyStyle(for: orderStatus)
4048
}
4149

42-
public var paymentBorderColor: CGColor? {
43-
get {
44-
return paymentStatusLabel.layer.borderColor
45-
}
46-
set {
47-
paymentStatusLabel.layer.borderColor = newValue
48-
}
50+
51+
// MARK: - Overridden Methods
52+
53+
override func awakeFromNib() {
54+
super.awakeFromNib()
55+
configureLabels()
4956
}
5057

5158
override func setSelected(_ selected: Bool, animated: Bool) {
@@ -59,9 +66,28 @@ class SummaryTableViewCell: UITableViewCell {
5966
super.setHighlighted(highlighted, animated: animated)
6067
}
6168
}
69+
}
70+
6271

72+
// MARK: - Private
73+
//
74+
private extension SummaryTableViewCell {
75+
76+
/// Preserves the current Payment BG Color
77+
///
6378
func preserveLabelColors(action: () -> Void) {
79+
let paymentColor = paymentStatusLabel.backgroundColor
80+
6481
action()
65-
paymentStatusLabel.backgroundColor = paymentBackgroundColor
82+
83+
paymentStatusLabel.backgroundColor = paymentColor
84+
}
85+
86+
/// Setup: Labels
87+
///
88+
func configureLabels() {
89+
titleLabel.applyHeadlineStyle()
90+
createdLabel.applyFootnoteStyle()
91+
paymentStatusLabel.applyPaddedLabelDefaultStyles()
6692
}
6793
}

0 commit comments

Comments
 (0)