fix(native): the watch's booking and today cards fit the 40 mm case in every language

The booking's kind and status share one line and its day steps aside when
the countdown needs the room; the next stop's name is a size smaller on
the small cases; eyebrows shrink a little before they cut; the day header
points forward in right-to-left languages; the sample trip keeps the
watch's own 12 or 24 hour clock.
This commit is contained in:
Maurice
2026-11-07 14:25:34 +01:00
parent 35d2b19f4c
commit 3a0edafdf0
4 changed files with 51 additions and 33 deletions
+2 -2
View File
@@ -129,12 +129,12 @@ struct TimelineRow: View {
Text(stop.minutes.map { WatchFormat.time(minutes: $0, hour12: hour12) } ?? "")
.font(.system(.caption2, design: .rounded).weight(.semibold).monospacedDigit())
.foregroundStyle(state == .now ? Trek.confirmed : WatchLook.muted)
.frame(width: hour12 ? 50 : 36, alignment: .trailing)
.frame(width: (hour12 ? 50 : 36) - (WatchScreen.compact ? 4 : 0), alignment: .trailing)
.padding(.top, 5)
.lineLimit(1)
.minimumScaleFactor(0.7)
VStack(spacing: 0) {
StopGlyph(stop: stop, size: 22, dimmed: state == .past)
StopGlyph(stop: stop, size: WatchScreen.compact ? 18 : 22, dimmed: state == .past)
.overlay(Circle().stroke(Trek.confirmed, lineWidth: state == .now ? 2 : 0).padding(-3))
if !isLast {
Rectangle()
+46 -30
View File
@@ -1,4 +1,10 @@
import SwiftUI
import WatchKit
/// The 40 and 41 mm cases, where a line less decides whether a screen ends clean.
enum WatchScreen {
static let compact = WKInterfaceDevice.current().screenBounds.width < 180
}
// MARK: - Today
@@ -59,7 +65,7 @@ struct TodayPage: View {
VStack(alignment: .leading, spacing: 1) {
HStack(spacing: 3) {
Text(WatchFormat.dayOf(index, total)).watchEyebrow(.white.opacity(0.85))
Image(systemName: "chevron.right")
Image(systemName: "chevron.forward")
.font(.system(size: 9, weight: .heavy))
.foregroundStyle(WatchLook.muted)
}
@@ -96,7 +102,7 @@ struct FocusCard: View {
Spacer(minLength: 0)
}
Text(stop.name)
.font(.system(.title3, design: .rounded).weight(.bold))
.font(.system(WatchScreen.compact ? .headline : .title3, design: .rounded).weight(.bold))
.foregroundStyle(WatchLook.ink)
.lineLimit(2)
.minimumScaleFactor(0.75)
@@ -328,20 +334,20 @@ struct BookingSummary: View {
@Environment(\.trekNow) private var now
var body: some View {
VStack(alignment: .leading, spacing: 6) {
HStack(spacing: 6) {
KindBadge(kind: booking.kind, size: 22)
VStack(alignment: .leading, spacing: 0) {
Text(WatchLook.kindName(booking.kind)).watchEyebrow(.white.opacity(0.85))
HStack(spacing: 3) {
Circle().fill(booking.confirmed ? Trek.confirmed : Trek.pending).frame(width: 5, height: 5)
Text(L(booking.confirmed ? "booking.confirmed" : "booking.pending"))
}
VStack(alignment: .leading, spacing: WatchScreen.compact ? 4 : 6) {
// The kind and the status in one line: "FLIGHT · Confirmed".
HStack(spacing: 5) {
KindBadge(kind: booking.kind, size: 20)
Text(WatchLook.kindName(booking.kind)).watchEyebrow(.white.opacity(0.85))
Circle().fill(booking.confirmed ? Trek.confirmed : Trek.pending).frame(width: 5, height: 5)
Text(L(booking.confirmed ? "booking.confirmed" : "booking.pending"))
.font(.system(.caption2, design: .rounded).weight(.medium))
.foregroundStyle(WatchLook.muted)
}
.lineLimit(1)
.minimumScaleFactor(0.7)
Spacer(minLength: 0)
}
.accessibilityElement(children: .combine)
if let route = booking.route {
Text(route)
.font(.system(.title2, design: .rounded).weight(.heavy))
@@ -371,27 +377,37 @@ struct BookingSummary: View {
let moment = running ? booking.end : booking.start
let clock = running ? booking.checkOut ?? booking.endTime : booking.time
if let moment {
HStack(alignment: .firstTextBaseline, spacing: 5) {
if let clock, let minutes = TrekDate.minutes(clock) {
Text(WatchFormat.time(minutes: minutes, hour12: hour12))
.font(.system(.title3, design: .rounded).weight(.bold).monospacedDigit())
.layoutPriority(2)
}
Text(running ? L("booking.checkOut") : dayLabel(moment))
// The day goes first when the line is too short for all three.
ViewThatFits(in: .horizontal) {
timeLine(clock: clock, label: running ? L("booking.checkOut") : dayLabel(moment), moment: moment)
timeLine(clock: clock, label: nil, moment: moment)
}
}
}
private func timeLine(clock: String?, label: String?, moment: Date) -> some View {
HStack(alignment: .firstTextBaseline, spacing: 5) {
if let clock, let minutes = TrekDate.minutes(clock) {
Text(WatchFormat.time(minutes: minutes, hour12: hour12))
.font(.system(.title3, design: .rounded).weight(.bold).monospacedDigit())
.fixedSize()
}
if let label {
Text(label)
.font(.system(.caption2, design: .rounded).weight(.semibold))
.foregroundStyle(WatchLook.muted)
.fixedSize()
}
Spacer(minLength: 2)
if moment > now {
Text(WatchFormat.relative(moment, now: now))
.font(.system(.caption2, design: .rounded).weight(.bold))
.foregroundStyle(.white)
.lineLimit(1)
Spacer(minLength: 2)
if moment > now {
Text(WatchFormat.relative(moment, now: now))
.font(.system(.caption2, design: .rounded).weight(.bold))
.foregroundStyle(.white)
.lineLimit(1)
.padding(.horizontal, 7)
.padding(.vertical, 3)
.background(Capsule().fill(Trek.booking(booking.kind).color.opacity(0.85)))
.layoutPriority(1)
}
.minimumScaleFactor(0.8)
.padding(.horizontal, 7)
.padding(.vertical, 3)
.background(Capsule().fill(Trek.booking(booking.kind).color.opacity(0.85)))
}
}
}
@@ -121,7 +121,8 @@ enum WatchSample {
let todos = WatchSnapshot.Todos(items: todoList, open: todoItems.filter { !$0.3 }.count, total: todoItems.count)
return WatchSnapshot(
generatedAt: ISO8601DateFormatter().string(from: now.addingTimeInterval(-4 * 60)),
hour12: false,
// The clock of the watch's region, as a user's TREK setting would usually match it.
hour12: DateFormatter.dateFormat(fromTemplate: "j", options: 0, locale: .current)?.contains("a") ?? false,
trip: .init(id: 1, title: t("Autumn in Kyoto"), start: iso(0), end: iso(8), place: t("Kyoto, Japan"), cover: nil),
days: days,
bookings: bookings,
@@ -139,6 +139,7 @@ struct WatchEyebrow: ViewModifier {
.tracking(0.4)
.foregroundStyle(color)
.lineLimit(1)
.minimumScaleFactor(0.65)
}
}