File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
WooCommerce/Classes/Extensions Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ import Foundation
2+ import UIKit
3+ import Yosemite
4+
5+
6+ // MARK: - UILabel + OrderStatus Methods
7+ //
8+ extension UILabel {
9+
10+ /// Applies the appropriate Style for a given OrderStatus
11+ ///
12+ func applyStyle( for status: OrderStatus ) {
13+ applyFootnoteStyle ( )
14+ applyLayerSettings ( )
15+ applyBackground ( for: status)
16+ }
17+
18+ /// Setup: Layer
19+ ///
20+ private func applyLayerSettings( ) {
21+ layer. borderWidth = OrderStatusSettings . borderWidth
22+ layer. cornerRadius = OrderStatusSettings . cornerRadius
23+ }
24+
25+ /// Setup: Background Color
26+ ///
27+ private func applyBackground( for status: OrderStatus ) {
28+ switch status {
29+ case . processing:
30+ fallthrough
31+ case . pending:
32+ backgroundColor = StyleManager . statusSuccessColor
33+ layer. borderColor = StyleManager . statusSuccessBoldColor. cgColor
34+ case . failed:
35+ fallthrough
36+ case . refunded:
37+ backgroundColor = StyleManager . statusDangerColor
38+ layer. borderColor = StyleManager . statusDangerBoldColor. cgColor
39+ case . completed:
40+ backgroundColor = StyleManager . statusPrimaryColor
41+ layer. borderColor = StyleManager . statusPrimaryBoldColor. cgColor
42+ case . onHold:
43+ fallthrough
44+ case . cancelled:
45+ fallthrough
46+ case . custom:
47+ fallthrough
48+ default :
49+ backgroundColor = StyleManager . statusNotIdentifiedColor
50+ layer. borderColor = StyleManager . statusNotIdentifiedBoldColor. cgColor
51+ }
52+ }
53+ }
54+
55+
56+ // MARK: - Private
57+ //
58+ private extension UILabel {
59+
60+ enum OrderStatusSettings {
61+ static let borderWidth = CGFloat ( 1.0 )
62+ static let cornerRadius = CGFloat ( 4.0 )
63+ }
64+ }
You can’t perform that action at this time.
0 commit comments