- Add visual drop target indicator showing where items will land - Use stable travel anchor IDs (city names) instead of UUIDs that regenerate - Fix findDayForTravelSegment to look forward to arrival day, not backward - Add moveItemToBeginning() for inserting at position 0 when dropping on sections - Sort custom items by sortOrder in all filters - Sync shifted items to CloudKit after reorder - Add opaque backgrounds to CustomItemRow and TravelSection to hide timeline 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!",
|
|
anchorDay: 1
|
|
),
|
|
onTap: {},
|
|
onDelete: {}
|
|
)
|
|
CustomItemRow(
|
|
item: CustomItineraryItem(
|
|
tripId: UUID(),
|
|
category: .hotel,
|
|
title: "Hilton Downtown",
|
|
anchorDay: 1
|
|
),
|
|
onTap: {},
|
|
onDelete: {}
|
|
)
|
|
}
|
|
.padding()
|
|
}
|