Files
GitHawk/Classes/Issues/Milestone/IssueMilestoneCell.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

77 lines
2.7 KiB
Swift

//
// IssueMilestoneCell.swift
// Freetime
//
// Created by Ryan Nystrom on 8/27/17.
// Copyright © 2017 Ryan Nystrom. All rights reserved.
//
import UIKit
import SnapKit
final class IssueMilestoneCell: UICollectionViewCell {
private let titleLabel = UILabel()
private let progress = UIProgressView()
override init(frame: CGRect) {
super.init(frame: frame)
isAccessibilityElement = true
accessibilityTraits |= UIAccessibilityTraitButton
titleLabel.backgroundColor = .clear
contentView.addSubview(titleLabel)
titleLabel.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.left.equalToSuperview()
}
progress.progressTintColor = Styles.Colors.Green.medium.color
progress.trackTintColor = Styles.Colors.Gray.border.color
contentView.addSubview(progress)
progress.snp.makeConstraints { make in
make.centerY.equalToSuperview()
make.height.equalTo(6)
// fit to gutter on all iphones, cap in landscape or ipad
make.width.lessThanOrEqualTo(300).priority(.required)
make.right.equalToSuperview()
make.left.equalTo(titleLabel.snp.right).offset(Styles.Sizes.rowSpacing)
}
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
layoutContentViewForSafeAreaInsets()
}
// MARK: Public API
func configure(milestone: Milestone) {
let milestoneAttributes: [NSAttributedStringKey: Any] = [
.foregroundColor: Styles.Colors.Gray.light.color,
.font: Styles.Text.secondary.preferredFont
]
let titleText = NSMutableAttributedString(
string: NSLocalizedString("Milestone: ", comment: ""),
attributes: milestoneAttributes
)
let titleAttributes: [NSAttributedStringKey: Any] = [
.foregroundColor: Styles.Colors.Gray.dark.color,
.font: Styles.Text.secondaryBold.preferredFont
]
titleText.append(NSAttributedString(string: milestone.title, attributes: titleAttributes))
titleLabel.attributedText = titleText
progress.progress = Float(milestone.totalIssueCount - milestone.openIssueCount) / Float(milestone.totalIssueCount)
let milestoneFormat = NSLocalizedString("Milestone: %@, %.0f percent completed.", comment: "The accessibility label for a repositories' milestone")
let percentProgress = progress.progress * 100
accessibilityLabel = String(format: milestoneFormat, arguments: [milestone.title, percentProgress])
}
}