mirror of
https://github.com/zhigang1992/GitHawk.git
synced 2026-06-17 02:52:01 +08:00
* 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
74 lines
1.9 KiB
Swift
74 lines
1.9 KiB
Swift
//
|
|
// LabelListCell.swift
|
|
// Freetime
|
|
//
|
|
// Created by Joe Rocca on 12/7/17.
|
|
// Copyright © 2017 Ryan Nystrom. All rights reserved.
|
|
//
|
|
|
|
import Foundation
|
|
import IGListKit
|
|
|
|
final class LabelListCell: UICollectionViewCell, ListBindable {
|
|
|
|
static let reuse = "cell"
|
|
static let font = Styles.Text.smallTitle.preferredFont
|
|
|
|
static func size(
|
|
_ string: String
|
|
) -> CGSize {
|
|
return string.size(font: font, xPadding: Styles.Sizes.labelTextPadding, yPadding: 3)
|
|
}
|
|
|
|
private let nameLabel = UILabel()
|
|
|
|
override init(frame: CGRect) {
|
|
super.init(frame: frame)
|
|
|
|
isAccessibilityElement = true
|
|
accessibilityTraits |= UIAccessibilityTraitButton
|
|
|
|
layer.cornerRadius = Styles.Sizes.labelCornerRadius
|
|
contentView.layer.cornerRadius = Styles.Sizes.labelCornerRadius
|
|
|
|
nameLabel.font = LabelListCell.font
|
|
contentView.addSubview(nameLabel)
|
|
nameLabel.snp.makeConstraints { make in
|
|
make.center.equalTo(contentView)
|
|
}
|
|
}
|
|
|
|
required init?(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
// MARK: ListBindable
|
|
|
|
func bindViewModel(_ viewModel: Any) {
|
|
guard let viewModel = viewModel as? RepositoryLabel else { return }
|
|
let color = UIColor.fromHex(viewModel.color)
|
|
contentView.backgroundColor = color
|
|
nameLabel.text = viewModel.name
|
|
nameLabel.textColor = color.textOverlayColor
|
|
}
|
|
|
|
// MARK: Public API
|
|
|
|
func configure(label: RepositoryLabel) {
|
|
let color = UIColor.fromHex(label.color)
|
|
backgroundColor = color
|
|
nameLabel.text = label.name
|
|
nameLabel.textColor = color.textOverlayColor
|
|
}
|
|
|
|
// MARK: Accessibility
|
|
|
|
override var accessibilityLabel: String? {
|
|
get {
|
|
return AccessibilityHelper.generatedLabel(forCell: self)
|
|
}
|
|
set { }
|
|
}
|
|
|
|
}
|