Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

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

Maurice3a0edafdf0a6
diff --git a/client/ios/App/TREKWatch/Details.swift b/client/ios/App/TREKWatch/Details.swift
index eb5051fe3..5e4f2ddb6 100644
--- a/client/ios/App/TREKWatch/Details.swift
+++ b/client/ios/App/TREKWatch/Details.swift
@@ -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()
diff --git a/client/ios/App/TREKWatch/Pages.swift b/client/ios/App/TREKWatch/Pages.swift
index 25ac0f3cd..147adf2b0 100644
--- a/client/ios/App/TREKWatch/Pages.swift
+++ b/client/ios/App/TREKWatch/Pages.swift
@@ -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)))
}
}
}
diff --git a/client/ios/App/TREKWatchKit/WatchSample.swift b/client/ios/App/TREKWatchKit/WatchSample.swift
index 04906de96..37984827f 100644
--- a/client/ios/App/TREKWatchKit/WatchSample.swift
+++ b/client/ios/App/TREKWatchKit/WatchSample.swift
@@ -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,
diff --git a/client/ios/App/TREKWatchKit/WatchStyle.swift b/client/ios/App/TREKWatchKit/WatchStyle.swift
index c7a2c5340..49ed96f0e 100644
--- a/client/ios/App/TREKWatchKit/WatchStyle.swift
+++ b/client/ios/App/TREKWatchKit/WatchStyle.swift
@@ -139,6 +139,7 @@ struct WatchEyebrow: ViewModifier {
.tracking(0.4)
.foregroundStyle(color)
.lineLimit(1)
+ .minimumScaleFactor(0.65)
}
}