Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit d08ecbb

Browse files
authored
simplify action cell layout (#1574)
1 parent 506eb90 commit d08ecbb

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

Classes/Issues/Managing/IssueManagingActionCell.swift

+6-13
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ final class IssueManagingActionCell: UICollectionViewCell, ListBindable {
1515
private let label = UILabel()
1616
private let imageView = UIImageView()
1717

18-
static let iconHeight = Styles.Sizes.buttonIcon.height + Styles.Sizes.rowSpacing * 3
19-
static let height = ceil(iconHeight + Styles.Sizes.rowSpacing * 2.5 + Styles.Text.secondary.size)
18+
static let iconHeight = Styles.Sizes.buttonIcon.height + Styles.Sizes.rowSpacing * 2
19+
static let height = ceil(iconHeight + Styles.Sizes.rowSpacing * 2.5 + Styles.Text.secondary.preferredFont.lineHeight)
2020

2121
override init(frame: CGRect) {
2222
super.init(frame: frame)
@@ -28,35 +28,28 @@ final class IssueManagingActionCell: UICollectionViewCell, ListBindable {
2828
contentView.layer.cornerRadius = Styles.Sizes.cardCornerRadius
2929

3030
let iconSize = IssueManagingActionCell.iconHeight
31-
imageView.contentMode = .center
31+
imageView.contentMode = .bottom
3232
imageView.clipsToBounds = true
3333
contentView.addSubview(imageView)
3434
imageView.snp.makeConstraints { make in
3535
make.size.equalTo(CGSize(width: iconSize, height: iconSize))
36-
make.centerX.equalTo(contentView)
37-
make.top.equalTo(contentView).offset(Styles.Sizes.rowSpacing/2)
36+
make.centerX.equalToSuperview()
37+
make.centerY.equalToSuperview().offset(-iconSize/2)
3838
}
3939

4040
label.textColor = tint
4141
label.font = Styles.Text.secondaryBold.preferredFont
4242
contentView.addSubview(label)
4343
label.snp.makeConstraints { make in
4444
make.centerX.equalTo(imageView)
45-
make.top.equalTo(imageView.snp.bottom).offset(-Styles.Sizes.rowSpacing)
45+
make.top.equalTo(imageView.snp.bottom).offset(Styles.Sizes.rowSpacing/2 + 2)
4646
}
4747
}
4848

4949
required init?(coder aDecoder: NSCoder) {
5050
fatalError("init(coder:) has not been implemented")
5151
}
5252

53-
override func layoutSubviews() {
54-
super.layoutSubviews()
55-
let height = bounds.height - Styles.Sizes.rowSpacing
56-
contentView.frame = CGRect(x: 0, y: 0, width: height, height: height)
57-
contentView.center = CGPoint(x: bounds.width/2, y: bounds.height/2)
58-
}
59-
6053
override var isSelected: Bool {
6154
didSet {
6255
highlight(isSelected)

Classes/Issues/Managing/IssueManagingSectionController.swift

+5-7
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ PeopleViewControllerDelegate {
6868
self.client = client
6969
super.init()
7070
inset = UIEdgeInsets(top: Styles.Sizes.gutter, left: 0, bottom: Styles.Sizes.gutter, right: 0)
71+
minimumInteritemSpacing = Styles.Sizes.rowSpacing
72+
minimumLineSpacing = Styles.Sizes.rowSpacing
7173
selectionDelegate = self
7274
dataSource = self
7375
}
@@ -205,14 +207,10 @@ PeopleViewControllerDelegate {
205207
else { fatalError("Collection context must be set") }
206208

207209
let height = IssueManagingActionCell.height
208-
let width = HangingChadItemWidth(
209-
index: index,
210-
count: viewModels.count,
211-
containerWidth: containerWidth,
212-
desiredItemWidth: height
213-
)
210+
211+
let rawRowCount = min(CGFloat(viewModels.count), floor(containerWidth / (height + minimumInteritemSpacing)))
214212
return CGSize(
215-
width: width,
213+
width: floor((containerWidth - (rawRowCount - 1) * minimumInteritemSpacing) / rawRowCount),
216214
height: height
217215
)
218216
}

0 commit comments

Comments
 (0)