Show issue state beside title

This commit is contained in:
Georg Bauer
2026-07-31 12:58:54 +02:00
parent c44e5f19c7
commit 6374636b04
4 changed files with 56 additions and 4 deletions

View File

@@ -1659,6 +1659,7 @@ public func FfiConverterTypeHomePage_lower(_ value: HomePage) -> RustBuffer {
public struct IssuePage: Equatable, Hashable {
public var title: String
public var state: String
public var meta: String
public var milestone: String
public var body: String
@@ -1666,8 +1667,9 @@ public struct IssuePage: Equatable, Hashable {
// Default memberwise initializers are never public by default, so we
// declare one manually.
public init(title: String, meta: String, milestone: String, body: String, comments: [CommentRow]) {
public init(title: String, state: String, meta: String, milestone: String, body: String, comments: [CommentRow]) {
self.title = title
self.state = state
self.meta = meta
self.milestone = milestone
self.body = body
@@ -1691,6 +1693,7 @@ public struct FfiConverterTypeIssuePage: FfiConverterRustBuffer {
return
try IssuePage(
title: FfiConverterString.read(from: &buf),
state: FfiConverterString.read(from: &buf),
meta: FfiConverterString.read(from: &buf),
milestone: FfiConverterString.read(from: &buf),
body: FfiConverterString.read(from: &buf),
@@ -1700,6 +1703,7 @@ public struct FfiConverterTypeIssuePage: FfiConverterRustBuffer {
public static func write(_ value: IssuePage, into buf: inout [UInt8]) {
FfiConverterString.write(value.title, into: &buf)
FfiConverterString.write(value.state, into: &buf)
FfiConverterString.write(value.meta, into: &buf)
FfiConverterString.write(value.milestone, into: &buf)
FfiConverterString.write(value.body, into: &buf)

View File

@@ -103,6 +103,7 @@ final class IssueViewController: MarkdownPageViewController {
)
replaceContent(detailViews(
title: page.title,
issueState: page.state,
meta: page.meta,
body: page.body,
comments: page.comments,
@@ -665,6 +666,7 @@ final class DiffViewController: UIViewController {
private func detailViews(
title: String,
issueState: String? = nil,
meta: String,
body: String,
comments: [CommentRow],
@@ -680,7 +682,7 @@ private func detailViews(
metaLabel.textColor = .secondaryLabel
metaLabel.numberOfLines = 0
let bodyView = markdownView(body)
var views: [UIView] = [titleLabel, metaLabel]
var views: [UIView] = [issueState.map { issueTitle(titleLabel, state: $0) } ?? titleLabel, metaLabel]
if !milestone.isEmpty {
let milestoneLabel = UILabel()
milestoneLabel.attributedText = symbolText(
@@ -695,6 +697,31 @@ private func detailViews(
return views + [separator(), bodyView] + commentViews(comments)
}
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 stack = UIStackView(arrangedSubviews: [icon, titleLabel])
stack.axis = .horizontal
stack.alignment = .firstBaseline
stack.spacing = 8
return stack
}
private func commentViews(_ comments: [CommentRow]) -> [UIView] {
guard !comments.isEmpty else { return [] }
var views: [UIView] = [sectionLabel("Comments")]