Files
GitHawk/Classes/Issues/Status/IssueStatusCell.swift
Ryan Nystrom e56c29a9a6 Redesigned Issues interface (#1983)
* clean up title model

* update title style

* organize issue SC method

* remove background colors from styled text in issues

* collection view bg white

* remove card inset and clean up snap superview code

* clean up label design

* thread is root and change base font size

* remove borders on comment cells

* adjust collapse design

* adjust comment line spacing and make non-root body smaller

* refactor detail view

* viewer header background color

* more buttons in reaction cell

* vertical spacers working

* design basically finished;

* scroll to bottom accounts for inset

* PR review background color white

* fixup PR review comments

* spacing on merge and review

* readme background white

* rename to just "spacer"

* horizontal spacing

* fix tests
2018-07-27 11:03:09 -04:00

65 lines
1.8 KiB
Swift

//
// IssueStatusCell.swift
// Freetime
//
// Created by Ryan Nystrom on 6/4/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import UIKit
import IGListKit
import SnapKit
final class IssueStatusCell: UICollectionViewCell, ListBindable {
let button = UIButton()
let lockedButton = UIButton()
override init(frame: CGRect) {
super.init(frame: frame)
button.setupAsLabel()
contentView.addSubview(button)
button.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalToSuperview()
}
lockedButton.setTitle(Constants.Strings.locked, for: .normal)
lockedButton.config(pullRequest: false, state: .locked)
lockedButton.setupAsLabel()
contentView.addSubview(lockedButton)
lockedButton.snp.makeConstraints { make in
make.centerY.equalTo(button)
make.left.equalTo(button.snp.right).offset(Styles.Sizes.columnSpacing)
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
layoutContentViewForSafeAreaInsets()
}
// MARK: ListBindable
func bindViewModel(_ viewModel: Any) {
guard let viewModel = viewModel as? IssueStatusModel else { return }
let title: String
switch viewModel.status {
case .closed: title = Constants.Strings.closed
case .open: title = Constants.Strings.open
case .merged: title = Constants.Strings.merged
}
button.setTitle(title, for: .normal)
button.config(pullRequest: viewModel.pullRequest, state: viewModel.status.buttonState)
lockedButton.isHidden = !viewModel.locked
}
}