commit 820becc820dd4ff38b631db877817cab661c7ca8
parent cb3abf3be5c65b69cb57dbccbc2dc126b1f4d6c0
Author: Michael Camilleri <[email protected]>
Date: Sat, 17 Oct 2026 06:22:55 +0900
Use semantic names for app spacing
Each view set its own spacing, so the same gap was typed out in many
places and changing one meant finding every copy.
This commit gives the spacing a few names in Theme, chosen by role
rather than size: the screen margin, the space above and below a survey
prompt, the gaps between the parts of an answer, between items in a
group, beside an icon, between chips and beneath a title, the space
above a section heading and the padding around timeline rows. Two roles
that share a value today can now change apart. Gaps tuned to particular
fonts and the sizes of particular controls stay with their views.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat
| M | Notes/Design.md | | | 6 | ++++-- |
| M | Reportage/Views/Home/HomeView.swift | | | 16 | ++++++++-------- |
| M | Reportage/Views/Survey/PlaceAnswerView.swift | | | 14 | +++++++------- |
| M | Reportage/Views/Survey/QuestionPage.swift | | | 16 | ++++++++-------- |
| M | Reportage/Views/Survey/SurveyView.swift | | | 8 | ++++---- |
| M | Reportage/Views/Survey/TokenAnswer.swift | | | 16 | ++++++++-------- |
| M | Reportage/Views/Theme/Theme.swift | | | 29 | +++++++++++++++++++++++++++++ |
7 files changed, 68 insertions(+), 37 deletions(-)
diff --git a/Notes/Design.md b/Notes/Design.md
@@ -93,8 +93,10 @@ The look is called Almanac: ink on paper, like a printed journal. prompt, ink-outlined answer buttons, chips for chosen tokens and an underlined search field. -Spacing values are still set per view. A design pass, folding them into a few -named values in `Theme`, waits until the Phase 2 screens settle. +Spacing lives in `Theme` as a few values named by role (the screen margin, +the gap between a prompt and its answer, between items in a group and so on), +so one role can change without others that share its value. Gaps tuned to +particular fonts and the sizes of particular controls stay with their views. ## Data Model
diff --git a/Reportage/Views/Home/HomeView.swift b/Reportage/Views/Home/HomeView.swift
@@ -112,13 +112,13 @@ struct ReportList: View {
var body: some View {
List {
HomeHeader(onStart: onStart, onQuickLog: onQuickLog)
- .listRowInsets(EdgeInsets(top: 8, leading: 24, bottom: 20, trailing: 24))
+ .listRowInsets(EdgeInsets(top: 8, leading: Theme.margin, bottom: 20, trailing: Theme.margin))
.listRowBackground(Theme.paper)
.listRowSeparatorTint(Theme.ink)
.listRowSeparator(.hidden, edges: .top)
if days.isEmpty {
EmptyReports()
- .listRowInsets(EdgeInsets(top: 0, leading: 24, bottom: 0, trailing: 24))
+ .listRowInsets(EdgeInsets(top: 0, leading: Theme.margin, bottom: 0, trailing: Theme.margin))
.listRowBackground(Theme.paper)
.listRowSeparator(.hidden)
}
@@ -126,7 +126,7 @@ struct ReportList: View {
Section {
ForEach(day) { report in
row(for: report)
- .listRowInsets(EdgeInsets(top: 18, leading: 24, bottom: 18, trailing: 24))
+ .listRowInsets(EdgeInsets(top: Theme.rowPadding, leading: Theme.margin, bottom: Theme.rowPadding, trailing: Theme.margin))
.listRowBackground(Theme.paper)
.listRowSeparatorTint(Theme.rule)
}
@@ -173,7 +173,7 @@ struct HomeHeader: View {
.foregroundStyle(Theme.ink)
.accessibilityAddTraits(.isHeader)
Spacer()
- HStack(spacing: 12) {
+ HStack(spacing: Theme.itemGap) {
QuickLogButton(action: onQuickLog)
NewReportMenu(onStart: onStart)
}
@@ -237,8 +237,8 @@ struct DayHeader: View {
Text(date, format: Self.format(for: date))
.eyebrow(Calendar.current.isDateInToday(date) ? Theme.accent : Theme.muted)
.frame(maxWidth: .infinity, alignment: .leading)
- .padding(.horizontal, 24)
- .padding(.top, 16)
+ .padding(.horizontal, Theme.margin)
+ .padding(.top, Theme.headingTop)
.padding(.bottom, 4)
.background(Theme.paper)
.listRowInsets(EdgeInsets())
@@ -281,7 +281,7 @@ struct ReportRow: View {
var body: some View {
let summary = describer.summary(of: report)
let kind = report.kind.flatMap(ReportKind.init)
- HStack(alignment: .firstTextBaseline, spacing: 12) {
+ HStack(alignment: .firstTextBaseline, spacing: Theme.itemGap) {
ReportTime(date: report.date, timeZone: report.timeZone)
.frame(width: 60, alignment: .leading)
VStack(alignment: .leading, spacing: 6) {
@@ -345,7 +345,7 @@ struct ReportTime: View {
var body: some View {
if let date {
let zone = timeZone.flatMap(TimeZone.init(identifier:)) ?? .current
- VStack(alignment: .leading, spacing: 2) {
+ VStack(alignment: .leading, spacing: Theme.lineGap) {
Text(date, format: Self.format(in: zone))
.font(Theme.serif(.title3, weight: .medium))
.monospacedDigit()
diff --git a/Reportage/Views/Survey/PlaceAnswerView.swift b/Reportage/Views/Survey/PlaceAnswerView.swift
@@ -13,7 +13,7 @@ struct PlaceAnswerView: View {
var body: some View {
@Bindable var picker = picker
- VStack(spacing: 20) {
+ VStack(spacing: Theme.blockGap) {
// The map makes way for the keyboard while searching.
if showsMap && !isSearchFocused {
PlaceMap(
@@ -82,7 +82,7 @@ struct PlaceMap: View {
withAnimation(.smooth) { position = camera(on: focus) }
}
} else if isLocating {
- HStack(spacing: 10) {
+ HStack(spacing: Theme.iconGap) {
ProgressView()
Text("Finding where you are…")
.font(.subheadline)
@@ -94,7 +94,7 @@ struct PlaceMap: View {
.frame(height: 180)
.clipShape(.rect(cornerRadius: 12))
.overlay(RoundedRectangle(cornerRadius: 12).strokeBorder(Theme.rule))
- .padding(.horizontal, 24)
+ .padding(.horizontal, Theme.margin)
}
/// What the map centres on: the chosen place, or else the report's
@@ -175,9 +175,9 @@ struct PlaceSectionHeader: View {
title
.eyebrow()
.frame(maxWidth: .infinity, alignment: .leading)
- .padding(.top, 12)
+ .padding(.top, Theme.headingTop)
.padding(.bottom, 4)
- .listRowInsets(EdgeInsets(top: 0, leading: 24, bottom: 0, trailing: 24))
+ .listRowInsets(EdgeInsets(top: 0, leading: Theme.margin, bottom: 0, trailing: Theme.margin))
.background(Theme.paper)
}
@@ -197,8 +197,8 @@ struct PlaceRow: View {
var body: some View {
Button(action: onToggle) {
- HStack(spacing: 12) {
- VStack(alignment: .leading, spacing: 2) {
+ HStack(spacing: Theme.itemGap) {
+ VStack(alignment: .leading, spacing: Theme.lineGap) {
Text(candidate.name)
.font(Theme.serif(.body))
.foregroundStyle(Theme.ink)
diff --git a/Reportage/Views/Survey/QuestionPage.swift b/Reportage/Views/Survey/QuestionPage.swift
@@ -13,11 +13,11 @@ struct QuestionPage: View {
var body: some View {
@Bindable var model = model
- VStack(alignment: .leading, spacing: 24) {
+ VStack(alignment: .leading, spacing: Theme.promptGap) {
Text(question.prompt)
.font(Theme.serif(.largeTitle, weight: .medium))
.frame(maxWidth: .infinity, alignment: .leading)
- .padding(.horizontal, 24)
+ .padding(.horizontal, Theme.margin)
.accessibilityAddTraits(.isHeader)
switch question.kind {
case .yesNo:
@@ -46,7 +46,7 @@ struct QuestionPage: View {
NoteAnswer(text: $model[textFor: question.id], isActive: isCurrent)
}
}
- .padding(.top, 28)
+ .padding(.top, Theme.pageTop)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
}
}
@@ -85,7 +85,7 @@ struct YesNoAnswer: View {
let onAnswer: () -> Void
var body: some View {
- VStack(spacing: 12) {
+ VStack(spacing: Theme.itemGap) {
AnswerOptionButton(
title: Text("Yes", comment: "Answer to a yes/no question"),
isSelected: selection == ResponseValue.yesOption
@@ -99,7 +99,7 @@ struct YesNoAnswer: View {
select(ResponseValue.noOption)
}
}
- .padding(.horizontal, 24)
+ .padding(.horizontal, Theme.margin)
}
private func select(_ option: String) {
@@ -115,7 +115,7 @@ struct ChoiceAnswer: View {
var body: some View {
ScrollView {
- VStack(spacing: 12) {
+ VStack(spacing: Theme.itemGap) {
ForEach(options, id: \.self) { option in
AnswerOptionButton(title: Text(option), isSelected: selection == option) {
selection = option
@@ -123,7 +123,7 @@ struct ChoiceAnswer: View {
}
}
}
- .padding(.horizontal, 24)
+ .padding(.horizontal, Theme.margin)
}
}
}
@@ -140,7 +140,7 @@ struct UnderlinedField<Content: View>: View {
.fill(Theme.ink)
.frame(height: 1.5)
}
- .padding(.horizontal, 24)
+ .padding(.horizontal, Theme.margin)
}
}
diff --git a/Reportage/Views/Survey/SurveyView.swift b/Reportage/Views/Survey/SurveyView.swift
@@ -270,7 +270,7 @@ struct SurveyHeader: View {
SurveyProgress(position: position, count: count)
}
}
- .padding(.horizontal, 24)
+ .padding(.horizontal, Theme.margin)
.padding(.top, 8)
.background(Theme.paper)
}
@@ -299,14 +299,14 @@ struct SurveyProgress: View {
struct NoQuestions: View {
var body: some View {
- VStack(alignment: .leading, spacing: 12) {
+ VStack(alignment: .leading, spacing: Theme.itemGap) {
Text("No questions")
.font(Theme.serif(.largeTitle, weight: .medium))
Text("This survey has no questions. The report will be saved with its time.")
.foregroundStyle(Theme.muted)
}
.frame(maxWidth: .infinity, alignment: .leading)
- .padding(24)
+ .padding(Theme.margin)
}
}
@@ -341,7 +341,7 @@ struct SurveyControls: View {
.buttonStyle(.plain)
.tint(Theme.ink)
.disabled(isSaving)
- .padding(.horizontal, 24)
+ .padding(.horizontal, Theme.margin)
.padding(.vertical, 12)
.background(Theme.paper)
}
diff --git a/Reportage/Views/Survey/TokenAnswer.swift b/Reportage/Views/Survey/TokenAnswer.swift
@@ -12,7 +12,7 @@ struct TokenAnswer: View {
var body: some View {
@Bindable var picker = picker
- VStack(spacing: 20) {
+ VStack(spacing: Theme.blockGap) {
if !picker.selectedEntries.isEmpty {
SelectedTokens(entries: picker.selectedEntries, onRemove: picker.toggle)
}
@@ -35,12 +35,12 @@ struct SelectedTokens: View {
var body: some View {
ScrollView(.horizontal) {
- HStack(spacing: 8) {
+ HStack(spacing: Theme.chipGap) {
ForEach(entries) { entry in
Button {
onRemove(entry.id)
} label: {
- HStack(spacing: 8) {
+ HStack(spacing: Theme.chipGap) {
Text(entry.text)
Image(systemName: "xmark")
.font(.caption.weight(.semibold))
@@ -55,7 +55,7 @@ struct SelectedTokens: View {
.accessibilityHint(Text("Removes this answer"))
}
}
- .padding(.horizontal, 24)
+ .padding(.horizontal, Theme.margin)
}
.scrollIndicators(.hidden)
}
@@ -69,7 +69,7 @@ struct TokenSearchField: View {
var body: some View {
UnderlinedField {
- HStack(spacing: 10) {
+ HStack(spacing: Theme.iconGap) {
Image(systemName: "magnifyingglass")
.foregroundStyle(Theme.muted)
TextField(placeholder ?? String(localized: "Search or add"), text: $query)
@@ -117,7 +117,7 @@ struct TokenList: View {
extension View {
func listRowStyle() -> some View {
- listRowInsets(EdgeInsets(top: 0, leading: 24, bottom: 0, trailing: 24))
+ listRowInsets(EdgeInsets(top: 0, leading: Theme.margin, bottom: 0, trailing: Theme.margin))
.listRowBackground(Theme.paper)
.listRowSeparatorTint(Theme.rule)
}
@@ -131,10 +131,10 @@ struct AddTokenRow: View {
var body: some View {
Button(action: onAdd) {
- HStack(spacing: 10) {
+ HStack(spacing: Theme.iconGap) {
Image(systemName: "plus")
.font(.body.weight(.semibold))
- VStack(alignment: .leading, spacing: 2) {
+ VStack(alignment: .leading, spacing: Theme.lineGap) {
Text("Add “\(text)”", comment: "Adds the typed text as a new answer")
.font(Theme.serif(.title3))
if let detail {
diff --git a/Reportage/Views/Theme/Theme.swift b/Reportage/Views/Theme/Theme.swift
@@ -14,6 +14,35 @@ enum Theme {
/// Text and icons drawn on `accent`.
static let onAccent = Color(light: 0xFFFFFF, dark: 0x141517)
+ // MARK: Spacing
+ //
+ // Named by role rather than size, so one role can change without the
+ // others that happen to share its value. Gaps tuned to particular fonts
+ // and the sizes of particular controls stay with their views.
+
+ /// The side margin of every screen.
+ static let margin: CGFloat = 24
+ /// Above the prompt on a survey page.
+ static let pageTop: CGFloat = 28
+ /// Between a survey prompt and its answer.
+ static let promptGap: CGFloat = 24
+ /// Between the parts of an answer: chosen tokens, the search field, the
+ /// map and the list.
+ static let blockGap: CGFloat = 20
+ /// Between items in a group: answer buttons, header buttons, a row's
+ /// columns.
+ static let itemGap: CGFloat = 12
+ /// Between an icon and its label.
+ static let iconGap: CGFloat = 10
+ /// Between chosen tokens, and between a token and its remove mark.
+ static let chipGap: CGFloat = 8
+ /// Between a title and the line of detail beneath it.
+ static let lineGap: CGFloat = 2
+ /// Above a section heading, such as a day in the timeline.
+ static let headingTop: CGFloat = 16
+ /// Above and below each report in the timeline.
+ static let rowPadding: CGFloat = 18
+
/// The serif, New York, at a Dynamic Type style.
static func serif(_ style: Font.TextStyle, weight: Font.Weight = .regular) -> Font {
.system(style, design: .serif, weight: weight)