Show issue state icons in lists

This commit is contained in:
Georg Bauer
2026-07-31 17:07:13 +02:00
parent f38c3c4939
commit e39695fc60
6 changed files with 48 additions and 21 deletions

View File

@@ -282,6 +282,7 @@ final class IssuesViewController: RefreshingTableViewController {
}
final class IssueCell: UITableViewCell {
private let stateIcon = UIImageView()
private let titleLabel = UILabel()
private let summaryLabel = UILabel()
private let labels = UIStackView()
@@ -293,6 +294,9 @@ final class IssueCell: UITableViewCell {
accessoryType = .disclosureIndicator
titleLabel.font = .preferredFont(forTextStyle: .headline)
titleLabel.numberOfLines = 2
let titleStack = UIStackView(arrangedSubviews: [stateIcon, titleLabel])
titleStack.alignment = .firstBaseline
titleStack.spacing = 8
summaryLabel.font = .preferredFont(forTextStyle: .subheadline)
summaryLabel.textColor = .secondaryLabel
summaryLabel.numberOfLines = 2
@@ -304,7 +308,7 @@ final class IssueCell: UITableViewCell {
milestoneLabel.font = .preferredFont(forTextStyle: .caption1)
milestoneLabel.adjustsFontForContentSizeCategory = true
let stack = UIStackView(
arrangedSubviews: [titleLabel, summaryLabel, labels, metaLabel, milestoneLabel]
arrangedSubviews: [titleStack, summaryLabel, labels, metaLabel, milestoneLabel]
)
stack.axis = .vertical
stack.spacing = 6
@@ -322,6 +326,7 @@ final class IssueCell: UITableViewCell {
required init?(coder: NSCoder) { fatalError("init(coder:) is not supported") }
func configure(_ row: IssueRow) {
configureIssueStateIcon(stateIcon, state: row.state, textStyle: .headline)
titleLabel.text = row.title
summaryLabel.text = row.summary
metaLabel.text = row.meta

View File

@@ -1130,23 +1130,8 @@ private func detailViews(
}
private func issueTitle(_ titleLabel: UILabel, state: String) -> UIView {
let symbol: String
let color: UIColor
let accessibilityLabel: String
switch state {
case "open":
(symbol, color, accessibilityLabel) = ("exclamationmark.circle.fill", .systemGreen, "Open issue")
case "closed":
(symbol, color, accessibilityLabel) = ("checkmark.circle.fill", .systemPurple, "Closed issue")
default:
(symbol, color, accessibilityLabel) = ("questionmark.circle.fill", .systemGray, "Unknown issue state")
}
let icon = UIImageView(image: UIImage(systemName: symbol))
icon.tintColor = color
icon.preferredSymbolConfiguration = UIImage.SymbolConfiguration(textStyle: .title1)
icon.setContentHuggingPriority(.required, for: .horizontal)
icon.isAccessibilityElement = true
icon.accessibilityLabel = accessibilityLabel
let icon = UIImageView()
configureIssueStateIcon(icon, state: state, textStyle: .title1)
let stack = UIStackView(arrangedSubviews: [icon, titleLabel])
stack.axis = .horizontal
stack.alignment = .firstBaseline

View File

@@ -255,3 +255,28 @@ func symbolText(_ symbol: String, text: String, font: UIFont, color: UIColor) ->
]))
return output
}
func configureIssueStateIcon(
_ icon: UIImageView,
state: String,
textStyle: UIFont.TextStyle
) {
let symbol: String
let color: UIColor
let accessibilityLabel: String
switch state {
case "open":
(symbol, color, accessibilityLabel) = ("exclamationmark.circle.fill", .systemGreen, "Open issue")
case "closed":
(symbol, color, accessibilityLabel) = ("checkmark.circle.fill", .systemPurple, "Closed issue")
default:
(symbol, color, accessibilityLabel) = ("questionmark.circle.fill", .systemGray, "Unknown issue state")
}
icon.image = UIImage(systemName: symbol)
icon.tintColor = color
icon.preferredSymbolConfiguration = UIImage.SymbolConfiguration(textStyle: textStyle)
icon.setContentHuggingPriority(.required, for: .horizontal)
icon.setContentCompressionResistancePriority(.required, for: .horizontal)
icon.isAccessibilityElement = true
icon.accessibilityLabel = accessibilityLabel
}