Skip to content

Commit 09d2806

Browse files
committed
fix: tidier reviewer chips, collapsed counts and captions
1 parent 702b919 commit 09d2806

6 files changed

Lines changed: 31 additions & 13 deletions

File tree

‎Sources/GitHubFloat/Views.swift‎

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,14 @@ struct ContentView: View {
148148
.contentShape(Rectangle())
149149
}
150150

151+
private func count(_ n: Int, _ icon: String, _ help: String) -> some View {
152+
HStack(spacing: 2) {
153+
Image(systemName: icon)
154+
Text("\(n)").monospacedDigit()
155+
}
156+
.help(help)
157+
}
158+
151159
private var subtitle: some View {
152160
HStack(spacing: 4) {
153161
if let error = store.error {
@@ -157,9 +165,13 @@ struct ContentView: View {
157165
Text("No project connected")
158166
} else if let last = store.lastUpdated {
159167
if settings.collapsed {
160-
Label("\(store.mine.count)", systemImage: "person.fill").help("Mine")
161-
Label("\(store.reviewing.count)", systemImage: "eye").help("Reviewing")
162-
Label("\(store.open.count)", systemImage: "person.badge.plus").help("Needs reviewer")
168+
HStack(spacing: 8) {
169+
count(store.mine.count, "person.fill", "Mine")
170+
count(store.reviewing.count, "eye", "Reviewing")
171+
count(store.open.count, "person.badge.plus", "Needs reviewer")
172+
}
173+
.fixedSize()
174+
.layoutPriority(1)
163175
Text("·")
164176
}
165177
TimelineView(.periodic(from: .now, by: 30)) { _ in
@@ -176,10 +188,12 @@ struct ContentView: View {
176188

177189
private func updatedText(_ date: Date) -> String {
178190
let s = Int(Date().timeIntervalSince(date))
191+
// The collapsed bar shares the line with the counts, so it only shows the age.
192+
let short = settings.collapsed
179193
switch s {
180-
case ..<30: return "updated just now"
181-
case ..<3600: return "updated \(max(1, s / 60))m ago"
182-
default: return "updated \(s / 3600)h ago"
194+
case ..<30: return short ? "now" : "updated just now"
195+
case ..<3600: return short ? "\(max(1, s / 60))m ago" : "updated \(max(1, s / 60))m ago"
196+
default: return short ? "\(s / 3600)h ago" : "updated \(s / 3600)h ago"
183197
}
184198
}
185199

@@ -313,7 +327,7 @@ struct ContentView: View {
313327
} else {
314328
scroller {
315329
VStack(alignment: .leading, spacing: 8) {
316-
Text("Others' tasks in \(settings.reviewStatus) without a reviewer assigned · longest waiting first")
330+
Text("No reviewer yet, longest waiting first")
317331
.font(.system(size: 10))
318332
.foregroundStyle(.tertiary)
319333
.padding(.top, 2)
@@ -552,7 +566,8 @@ struct TaskRow: View {
552566
.font(.system(size: 10)).foregroundStyle(.tertiary)
553567
}
554568
ForEach(task.prs) { pr in
555-
PRLine(pr: pr, showRepo: pr.repo != task.repo)
569+
// In Reviewing the line above already says where you stand.
570+
PRLine(pr: pr, showRepo: pr.repo != task.repo, hiding: tab == .reviewing ? viewer : nil)
556571
}
557572
if let onReReview {
558573
HStack {
@@ -654,6 +669,7 @@ struct TaskRow: View {
654669
struct PRLine: View {
655670
let pr: PullRequest
656671
let showRepo: Bool
672+
var hiding: String? = nil
657673

658674
var body: some View {
659675
HStack(spacing: 6) {
@@ -684,16 +700,18 @@ struct PRLine: View {
684700
}
685701

686702
private var reviewers: some View {
687-
HStack(spacing: 4) {
688-
ForEach(pr.reviewers.prefix(3), id: \.self) { r in
703+
let shown = pr.reviewers.filter { $0.login != hiding }
704+
return HStack(spacing: 4) {
705+
ForEach(shown.prefix(3), id: \.self) { r in
689706
HStack(spacing: 2) {
690707
Image(systemName: r.symbol).foregroundStyle(r.color)
691-
Text(r.login).lineLimit(1).truncationMode(.tail).frame(maxWidth: 64, alignment: .leading)
708+
// Long logins are cut, short ones keep their own width so the group hugs the right edge.
709+
Text(r.login.count > 12 ? r.login.prefix(11) + "…" : r.login).lineLimit(1).fixedSize()
692710
}
693711
.help("\(r.login): \(r.state.replacingOccurrences(of: "_", with: " ").lowercased())")
694712
}
695-
if pr.reviewers.count > 3 {
696-
Text("+\(pr.reviewers.count - 3)")
713+
if shown.count > 3 {
714+
Text("+\(shown.count - 3)")
697715
}
698716
}
699717
.font(.system(size: 9))

‎docs/collapsed.png‎

-898 Bytes
Loading

‎docs/mine.png‎

1.79 KB
Loading

‎docs/needs-reviewer.png‎

-10.8 KB
Loading

‎docs/reviewing.png‎

-15.5 KB
Loading

‎docs/social-preview.png‎

1.36 KB
Loading

0 commit comments

Comments
 (0)