-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
ProjectHeaderCell.swift
82 lines (65 loc) · 1.82 KB
/
ProjectHeaderCell.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import Library
import Prelude
import UIKit
public enum ProjectHeaderCellStyles {
public enum Layout {
public static let insets: CGFloat = Styles.grid(200)
}
}
final class ProjectHeaderCell: UITableViewCell, ValueCell {
// MARK: - Properties
private lazy var titleTextLabel: UILabel = {
UILabel(frame: .zero)
|> \.translatesAutoresizingMaskIntoConstraints .~ false
}()
// MARK: - Lifecycle
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
self.bindStyles()
self.configureViews()
}
required init?(coder _: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
// MARK: - Styles
override func bindStyles() {
super.bindStyles()
// The separatorInset removes the bottom separator line from the view
_ = self
|> baseTableViewCellStyle()
|> \.separatorInset .~
.init(
top: 0,
left: 0,
bottom: 0,
right: self.bounds.size.width + ProjectHeaderCellStyles.Layout.insets
)
_ = self.contentView
|> \.layoutMargins .~ .init(
topBottom: Styles.grid(3),
leftRight: Styles.grid(3)
)
_ = self.titleTextLabel
|> titleLabelStyle
}
// MARK: - Configuration
func configureWith(value: String) {
_ = self.titleTextLabel
|> \.text .~ value
return
}
private func configureViews() {
_ = (self.titleTextLabel, self.contentView)
|> ksr_addSubviewToParent()
|> ksr_constrainViewToMarginsInParent()
}
}
// MARK: - Styles
private let titleLabelStyle: LabelStyle = { view in
view
|> \.backgroundColor .~ .ksr_white
|> \.font .~ UIFont.ksr_title1().bolded
|> \.lineBreakMode .~ .byWordWrapping
|> \.numberOfLines .~ 0
|> \.textColor .~ .ksr_support_700
}