Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 33 additions & 99 deletions Where/WhereUI/Sources/Primary/PrimaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct PrimaryView: View {
@State private var showingCalendar = false
@State private var calendarFocus: CalendarFocus?

/// Drives the passport's tilt-reactive holographic sheen. Started/stopped
/// Drives the region cards' tilt-reactive holographic sheen. Started/stopped
/// with the view's lifecycle; a no-op on hardware without device motion.
@State private var tilt = TiltProvider()

Expand All @@ -25,45 +25,41 @@ struct PrimaryView: View {

var body: some View {
NavigationStack {
VStack(spacing: 0) {
PassportMasthead(title: Strings.primaryTitle, tilt: tilt)
.padding(.horizontal)
.padding(.top, UIConstants.Spacings.small)
.padding(.bottom, UIConstants.Spacings.medium)

screen
}
.background(elevatedBackground)
.environment(\.colorScheme, .dark)
.navigationBarTitleDisplayMode(.inline)
.toolbarColorScheme(.dark, for: .navigationBar)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button {
showingTimeline = true
} label: {
Label(
Strings.primaryTimeline,
systemImage: "calendar.day.timeline.left",
)
screen
.background(elevatedBackground)
.environment(\.colorScheme, .dark)
.navigationBarTitleDisplayMode(.inline)
.toolbarColorScheme(.dark, for: .navigationBar)
// Hide the bar's material so the glass cards scroll underneath
// the floating toolbar buttons rather than behind an opaque bar.
.toolbarBackground(.hidden, for: .navigationBar)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button {
showingTimeline = true
} label: {
Label(
Strings.primaryTimeline,
systemImage: "calendar.day.timeline.left",
)
}
.accessibilityIdentifier("where_timeline_button")
}
.accessibilityIdentifier("where_timeline_button")
}
ToolbarItem(placement: .topBarTrailing) {
Button {
showingCalendar = true
} label: {
Label(
Strings.primaryCalendar,
systemImage: "calendar",
)
ToolbarItem(placement: .topBarTrailing) {
Button {
showingCalendar = true
} label: {
Label(
Strings.primaryCalendar,
systemImage: "calendar",
)
}
.accessibilityIdentifier("where_calendar_button")
}
ToolbarItem(placement: .topBarTrailing) {
YearSelector(report: report)
}
.accessibilityIdentifier("where_calendar_button")
}
ToolbarItem(placement: .topBarTrailing) {
YearSelector(report: report)
}
}
}
.onAppear { tilt.start() }
.onDisappear { tilt.stop() }
Expand Down Expand Up @@ -166,68 +162,6 @@ struct PrimaryView: View {
}
}

/// The Primary tab's masthead: the app wordmark embossed in gold foil that
/// catches a moving specular glint as the device tilts, like the gilt title on
/// a passport cover. Falls back to a fixed, gentle highlight under Reduce
/// Motion or on hardware without device motion.
private struct PassportMasthead: View {
let title: String
var tilt: TiltProvider?

@Environment(\.accessibilityReduceMotion) private var reduceMotion

/// Lateral position of the glint, normalized `-1...1`. Pinned to a gentle
/// off-center value when motion is unavailable or reduced.
private var glintRoll: Double {
guard !reduceMotion, let roll = tilt?.roll else { return 0.2 }
return min(1, max(-1, roll))
}

var body: some View {
let wordmark = Text(verbatim: title.uppercased())
.font(.system(
size: UIConstants.Size.mastheadFontSize,
weight: .heavy,
design: .serif,
))
.tracking(2)

return wordmark
.foregroundStyle(goldFoil)
.overlay {
LinearGradient(
colors: [.clear, .white.opacity(0.95), .clear],
startPoint: UnitPoint(x: glintRoll * 0.5 - 0.1, y: 0),
endPoint: UnitPoint(x: glintRoll * 0.5 + 0.6, y: 1),
)
.blendMode(.plusLighter)
}
.mask { wordmark }
.shadow(
color: .black.opacity(0.45),
radius: UIConstants.Spacings.xSmall,
y: UIConstants.Spacings.xxSmall,
)
.frame(maxWidth: .infinity, alignment: .leading)
.accessibilityAddTraits(.isHeader)
.accessibilityLabel(title)
}

/// Brushed-gold gradient that reads as embossed gilt on the dark cover.
private var goldFoil: LinearGradient {
LinearGradient(
colors: [
Color(red: 1.0, green: 0.93, blue: 0.7),
Color(red: 0.86, green: 0.66, blue: 0.32),
Color(red: 1.0, green: 0.9, blue: 0.66),
Color(red: 0.72, green: 0.52, blue: 0.24),
],
startPoint: .top,
endPoint: .bottom,
)
}
}

#if DEBUG
#Preview("Loaded") {
PrimaryView(report: PreviewSupport.loadedYearReportModel())
Expand Down
11 changes: 0 additions & 11 deletions Where/WhereUI/Sources/Resources/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -766,17 +766,6 @@
}
}
},
"primary.title" : {
"extractionState" : "manual",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Where"
}
}
}
},
"regionMap.empty.description" : {
"extractionState" : "manual",
"localizations" : {
Expand Down
5 changes: 0 additions & 5 deletions Where/WhereUI/Sources/Shared/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ enum Strings {

// MARK: Primary

/// The Primary tab's masthead wordmark.
static var primaryTitle: String {
localized("primary.title")
}

static var primaryTimeline: String {
localized("primary.timeline")
}
Expand Down
2 changes: 0 additions & 2 deletions Where/WhereUI/Sources/Shared/UIConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ enum UIConstants {
/// Point size of the oversized region glyph watermarked behind a card.
static let stampWatermark: CGFloat = 150
static let stampWatermarkCompact: CGFloat = 96
/// Point size of the Primary tab's gold-foil "Where" masthead.
static let mastheadFontSize: CGFloat = 52
/// Height of the map header on the Elsewhere region drill-in.
static let regionMapHeight: CGFloat = 220
/// Upper bound for a picker-grid thumbnail edge; the actual size flexes
Expand Down
1 change: 0 additions & 1 deletion Where/WhereUI/Tests/StringsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import WhereCore
struct StringsTests {
@Test func simpleKeysResolveToCatalogValues() {
#expect(Strings.tabElsewhere == "Elsewhere")
#expect(Strings.primaryTitle == "Where")
#expect(Strings.loadErrorTitle == "Couldn't load your year")
#expect(Strings.commonOK == "OK")
#expect(Strings.manualSaveErrorTitle == "Couldn't save that day")
Expand Down
Loading