WIP: map route updates and custom item drag/drop fixes (broken)

- Fixed map header not updating in ItineraryTableViewWrapper using Coordinator pattern
- Added routeVersion UUID to force Map re-render when routes change
- Fixed determineAnchor to scan backwards for correct anchor context
- Added location support to CustomItineraryItem (lat/lng/address)
- Added MapKit place search to AddItemSheet
- Added extensive debug logging for route waypoint calculation

Known issues:
- Custom items still not routing correctly after drag/drop
- Anchor type determination may still have bugs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-01-17 00:00:57 -06:00
parent 43501b6ac1
commit 8df33a5614
7 changed files with 605 additions and 57 deletions

View File

@@ -47,6 +47,14 @@ struct ItineraryTableViewWrapper<HeaderContent: View>: UIViewControllerRepresent
self.onAddButtonTapped = onAddButtonTapped
}
func makeCoordinator() -> Coordinator {
Coordinator()
}
class Coordinator {
var headerHostingController: UIHostingController<HeaderContent>?
}
func makeUIViewController(context: Context) -> ItineraryTableViewController {
let controller = ItineraryTableViewController(style: .plain)
controller.colorScheme = colorScheme
@@ -60,6 +68,9 @@ struct ItineraryTableViewWrapper<HeaderContent: View>: UIViewControllerRepresent
let hostingController = UIHostingController(rootView: headerContent)
hostingController.view.backgroundColor = .clear
// Store in coordinator for later updates
context.coordinator.headerHostingController = hostingController
// Pre-size the header view
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
let targetWidth = UIScreen.main.bounds.width
@@ -85,8 +96,9 @@ struct ItineraryTableViewWrapper<HeaderContent: View>: UIViewControllerRepresent
controller.onCustomItemDeleted = onCustomItemDeleted
controller.onAddButtonTapped = onAddButtonTapped
// Note: Don't update header content here - it causes infinite layout loops
// Header is set once in makeUIViewController and remains static
// Update header content by updating the hosting controller's rootView
// This avoids recreating the view hierarchy and prevents infinite loops
context.coordinator.headerHostingController?.rootView = headerContent
let (days, validRanges) = buildItineraryData()
controller.reloadData(days: days, travelValidRanges: validRanges)