Center the Home activity strip

This commit is contained in:
Georg Bauer
2026-07-31 18:00:51 +02:00
parent de49db0910
commit 9c7cef3869
2 changed files with 8 additions and 3 deletions

View File

@@ -128,6 +128,8 @@ xcrun simctl launch booted de.rfc1437.gotcha
- [ ] Home shows the selected server name, contribution total, nine labeled - [ ] Home shows the selected server name, contribution total, nine labeled
months with gaps between them, and recent activity. months with gaps between them, and recent activity.
- [ ] The nine-month activity strip is horizontally centered beneath its title
without clipping either edge.
- [ ] Activity rows have the correct icon, repository, summary, and date. - [ ] Activity rows have the correct icon, repository, summary, and date.
- [ ] The compact icon row below the activity graph sits flat on the normal - [ ] The compact icon row below the activity graph sits flat on the normal
background with no border or pill and defaults to the clock. Select the background with no border or pill and defaults to the clock. Select the

View File

@@ -562,8 +562,11 @@ final class HeatmapView: UIView {
(calendar.dateComponents([.day], from: firstWeek, to: lastDate).day ?? 0) / 7 + 1 (calendar.dateComponents([.day], from: firstWeek, to: lastDate).day ?? 0) / 7 + 1
) )
let monthGap: CGFloat = 4 let monthGap: CGFloat = 4
let width = max(4, min(6, (bounds.width - 32) / weekCount - 1)) let monthGaps = CGFloat(max(months.count - 1, 0)) * monthGap
let width = max(4, min(6, (bounds.width - 32 - monthGaps) / weekCount - 1))
let gap = width + 1 let gap = width + 1
let graphWidth = (weekCount - 1) * gap + width + monthGaps
let graphOrigin = max(0, (bounds.width - graphWidth) / 2)
let labelAttributes: [NSAttributedString.Key: Any] = [ let labelAttributes: [NSAttributedString.Key: Any] = [
.font: UIFont.preferredFont(forTextStyle: .caption2), .font: UIFont.preferredFont(forTextStyle: .caption2),
.foregroundColor: UIColor.secondaryLabel, .foregroundColor: UIColor.secondaryLabel,
@@ -572,7 +575,7 @@ final class HeatmapView: UIView {
let days = calendar.dateComponents([.day], from: firstWeek, to: month).day ?? 0 let days = calendar.dateComponents([.day], from: firstWeek, to: month).day ?? 0
monthFormatter.string(from: month).draw( monthFormatter.string(from: month).draw(
at: CGPoint( at: CGPoint(
x: 16 + CGFloat(days / 7) * gap + CGFloat(index) * monthGap, x: graphOrigin + CGFloat(days / 7) * gap + CGFloat(index) * monthGap,
y: 34 y: 34
), ),
withAttributes: labelAttributes withAttributes: labelAttributes
@@ -595,7 +598,7 @@ final class HeatmapView: UIView {
colors[Int(min(cell.level, 4))].setFill() colors[Int(min(cell.level, 4))].setFill()
UIBezierPath( UIBezierPath(
roundedRect: CGRect( roundedRect: CGRect(
x: 16 + CGFloat(days / 7) * gap + CGFloat(monthIndex) * monthGap, x: graphOrigin + CGFloat(days / 7) * gap + CGFloat(monthIndex) * monthGap,
y: 48 + CGFloat(calendar.component(.weekday, from: date) - 1) * gap, y: 48 + CGFloat(calendar.component(.weekday, from: date) - 1) * gap,
width: width, width: width,
height: width height: width