Add specialized row components for the new unified itinerary system: - DayHeaderRow: Day number, date display, and add item button - GameItemRow: Prominent card with sport color bar for games - TravelItemRow: Gold-styled travel segments with drag handle - CustomItemRow: Minimal custom items with icon, title, and optional time All views follow existing Theme patterns and use SportColorBar for consistency. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
95 lines
2.9 KiB
Swift
95 lines
2.9 KiB
Swift
//
|
|
// TravelItemRow.swift
|
|
// SportsTime
|
|
//
|
|
// Row view for displaying travel segments in the itinerary.
|
|
// Uses gold/amber styling and includes a drag handle for reordering.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct TravelItemRow: View {
|
|
let item: ItineraryItem
|
|
let isHighlighted: Bool
|
|
|
|
@Environment(\.colorScheme) private var colorScheme
|
|
|
|
private var travelInfo: TravelInfo? {
|
|
item.travelInfo
|
|
}
|
|
|
|
var body: some View {
|
|
HStack(spacing: Theme.Spacing.md) {
|
|
// Drag handle
|
|
Image(systemName: "line.3.horizontal")
|
|
.font(.title3)
|
|
.foregroundStyle(Theme.textMuted(colorScheme))
|
|
|
|
// Car icon
|
|
ZStack {
|
|
Circle()
|
|
.fill(Theme.routeGold.opacity(0.2))
|
|
.frame(width: 36, height: 36)
|
|
|
|
Image(systemName: "car.fill")
|
|
.font(.body)
|
|
.foregroundStyle(Theme.routeGold)
|
|
}
|
|
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
if let info = travelInfo {
|
|
Text("\(info.fromCity) \u{2192} \(info.toCity)")
|
|
.font(.body)
|
|
.foregroundStyle(Theme.textPrimary(colorScheme))
|
|
|
|
HStack(spacing: Theme.Spacing.xs) {
|
|
if !info.formattedDistance.isEmpty {
|
|
Text(info.formattedDistance)
|
|
.font(.caption)
|
|
}
|
|
if !info.formattedDistance.isEmpty && !info.formattedDuration.isEmpty {
|
|
Text("\u{2022}")
|
|
}
|
|
if !info.formattedDuration.isEmpty {
|
|
Text(info.formattedDuration)
|
|
.font(.caption)
|
|
}
|
|
}
|
|
.foregroundStyle(Theme.textSecondary(colorScheme))
|
|
}
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.padding(Theme.Spacing.md)
|
|
.background(Theme.cardBackground(colorScheme))
|
|
.clipShape(RoundedRectangle(cornerRadius: Theme.CornerRadius.medium))
|
|
.overlay {
|
|
RoundedRectangle(cornerRadius: Theme.CornerRadius.medium)
|
|
.strokeBorder(isHighlighted ? Theme.routeGold : Theme.routeGold.opacity(0.3), lineWidth: isHighlighted ? 2 : 1)
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
let travelInfo = TravelInfo(
|
|
fromCity: "Boston",
|
|
toCity: "New York",
|
|
distanceMeters: 350000,
|
|
durationSeconds: 14400
|
|
)
|
|
let item = ItineraryItem(
|
|
tripId: UUID(),
|
|
day: 1,
|
|
sortOrder: 1.0,
|
|
kind: .travel(travelInfo)
|
|
)
|
|
|
|
VStack(spacing: 16) {
|
|
TravelItemRow(item: item, isHighlighted: false)
|
|
TravelItemRow(item: item, isHighlighted: true)
|
|
}
|
|
.padding()
|
|
.background(Color.gray.opacity(0.1))
|
|
}
|