Replace complex anchor system (anchorType, anchorId, anchorDay) with simple (day: Int, sortOrder: Double) positioning for custom items. Changes: - CustomItineraryItem: Remove anchor fields, add day and sortOrder - CKModels: Add migration fallback from old CloudKit fields - ItineraryTableViewController: Add calculateSortOrder() for midpoint insertion - TripDetailView: Simplify callbacks, itinerarySections, and routeWaypoints - AddItemSheet: Take simple day parameter instead of anchor - SavedTrip: Update LocalCustomItem SwiftData model Benefits: - Items freely movable via drag-and-drop - Route waypoints follow exact visual order - Simpler mental model: position = (day, sortOrder) - Midpoint insertion allows unlimited reordering Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
99 lines
2.7 KiB
Swift
99 lines
2.7 KiB
Swift
//
|
|
// CustomItemRow.swift
|
|
// SportsTime
|
|
//
|
|
// Row component for custom itinerary items with drag handle
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct CustomItemRow: View {
|
|
@Environment(\.colorScheme) private var colorScheme
|
|
|
|
let item: CustomItineraryItem
|
|
var onTap: () -> Void
|
|
var onDelete: () -> Void
|
|
|
|
// Drag handle visible - users can drag to reorder using .draggable/.dropDestination
|
|
|
|
var body: some View {
|
|
Button(action: onTap) {
|
|
HStack(spacing: 12) {
|
|
// Drag handle
|
|
Image(systemName: "line.3.horizontal")
|
|
.foregroundStyle(.tertiary)
|
|
.font(.caption)
|
|
|
|
// Category icon
|
|
Text(item.category.icon)
|
|
.font(.title3)
|
|
|
|
// Title
|
|
Text(item.title)
|
|
.font(.subheadline)
|
|
.foregroundStyle(Theme.textPrimary(colorScheme))
|
|
.lineLimit(2)
|
|
|
|
Spacer()
|
|
|
|
// Chevron to indicate tappable (tap to edit)
|
|
Image(systemName: "chevron.right")
|
|
.foregroundStyle(.tertiary)
|
|
.font(.caption)
|
|
}
|
|
.padding(.horizontal, Theme.Spacing.md)
|
|
.padding(.vertical, Theme.Spacing.sm)
|
|
.background {
|
|
// Opaque base + semi-transparent accent
|
|
RoundedRectangle(cornerRadius: 8)
|
|
.fill(Theme.cardBackground(colorScheme))
|
|
RoundedRectangle(cornerRadius: 8)
|
|
.fill(Theme.warmOrange.opacity(0.1))
|
|
}
|
|
.overlay {
|
|
RoundedRectangle(cornerRadius: 8)
|
|
.strokeBorder(Theme.warmOrange.opacity(0.3), lineWidth: 1)
|
|
}
|
|
}
|
|
.buttonStyle(.plain)
|
|
.contextMenu {
|
|
Button {
|
|
onTap()
|
|
} label: {
|
|
Label("Edit", systemImage: "pencil")
|
|
}
|
|
Button(role: .destructive) {
|
|
onDelete()
|
|
} label: {
|
|
Label("Delete", systemImage: "trash")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
VStack {
|
|
CustomItemRow(
|
|
item: CustomItineraryItem(
|
|
tripId: UUID(),
|
|
category: .restaurant,
|
|
title: "Joe's BBQ - Best brisket in Texas!",
|
|
day: 1
|
|
),
|
|
onTap: {},
|
|
onDelete: {}
|
|
)
|
|
CustomItemRow(
|
|
item: CustomItineraryItem(
|
|
tripId: UUID(),
|
|
category: .hotel,
|
|
title: "Hilton Downtown",
|
|
day: 1
|
|
),
|
|
onTap: {},
|
|
onDelete: {}
|
|
)
|
|
}
|
|
.padding()
|
|
}
|