-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
ProjectPamphletSubpageCell.swift
84 lines (67 loc) · 3.2 KB
/
ProjectPamphletSubpageCell.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
83
84
import KsApi
import Library
import Prelude
import UIKit
internal final class ProjectPamphletSubpageCell: UITableViewCell, ValueCell {
@IBOutlet private var countContainerView: UIView!
@IBOutlet private var countLabel: UILabel!
@IBOutlet private var rootStackView: UIStackView!
@IBOutlet private var separatorView: UIView!
@IBOutlet private var subpageLabel: UILabel!
@IBOutlet private var topSeparatorView: UIView!
private let viewModel: ProjectPamphletSubpageCellViewModelType = ProjectPamphletSubpageCellViewModel()
internal func configureWith(value subpage: ProjectPamphletSubpage) {
self.viewModel.inputs.configureWith(subpage: subpage)
self.setNeedsLayout()
}
internal override func bindStyles() {
super.bindStyles()
_ = self
|> baseTableViewCellStyle()
|> ProjectPamphletSubpageCell.lens.accessibilityTraits .~ UIAccessibilityTraits.button
|> ProjectPamphletSubpageCell.lens.contentView.layoutMargins %~~ { _, cell in
cell.traitCollection.isRegularRegular
? .init(topBottom: Styles.gridHalf(5), leftRight: Styles.grid(16))
: .init(topBottom: Styles.gridHalf(5), leftRight: Styles.gridHalf(7))
}
_ = self.countContainerView
|> UIView.lens.layoutMargins .~ .init(topBottom: Styles.grid(1), leftRight: Styles.grid(2))
|> UIView.lens.layer.borderWidth .~ 1
_ = self.countLabel
|> UILabel.lens.font .~ .ksr_headline(size: 13)
|> UIView.lens.contentHuggingPriority(for: .horizontal) .~ UILayoutPriority.required
|> UIView.lens.contentCompressionResistancePriority(for: .horizontal) .~ UILayoutPriority.required
_ = self.rootStackView
|> UIStackView.lens.spacing .~ Styles.grid(1)
|> UIStackView.lens.alignment .~ .center
|> UIStackView.lens.distribution .~ .fill
_ = [self.separatorView, self.topSeparatorView]
||> separatorStyle
_ = self.subpageLabel
|> UILabel.lens.numberOfLines .~ 2
|> UILabel.lens.font .~ .ksr_body(size: 14)
|> UILabel.lens.backgroundColor .~ .ksr_white
|> UIView.lens.contentHuggingPriority(for: .horizontal) .~ UILayoutPriority.defaultLow
|> UIView.lens.contentCompressionResistancePriority(for: .horizontal) .~ UILayoutPriority.defaultLow
self.setNeedsLayout()
}
internal override func bindViewModel() {
super.bindViewModel()
self.countLabel.rac.text = self.viewModel.outputs.countLabelText
self.countLabel.rac.textColor = self.viewModel.outputs.countLabelTextColor
self.countLabel.rac.backgroundColor = self.viewModel.outputs.countLabelBackgroundColor
self.countContainerView.rac.backgroundColor = self.viewModel.outputs.countLabelBackgroundColor
self.viewModel.outputs.countLabelBorderColor
.observeForUI()
.observeValues { [weak self] in
self?.countContainerView.layer.borderColor = $0.cgColor
}
self.topSeparatorView.rac.hidden = self.viewModel.outputs.topSeparatorViewHidden
self.separatorView.rac.hidden = self.viewModel.outputs.separatorViewHidden
self.subpageLabel.rac.text = self.viewModel.outputs.labelText
self.subpageLabel.rac.textColor = self.viewModel.outputs.labelTextColor
}
internal override func layoutSubviews() {
super.layoutSubviews()
}
}