fix: resolve 4 UI/planning bugs from issue tracker
- Lock all maps to North America (no pan/zoom) in ProgressMapView and TripDetailView - Sort saved trips by most cities (stops count) - Filter cross-country trips to top 2 by stops on home screen - Use LocationSearchSheet for Follow Team home location (consistent with must-stop) - Initialize DateRangePicker to show selected dates on appear Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,7 +36,33 @@ final class TripCreationViewModel {
|
||||
|
||||
// MARK: - Planning Mode
|
||||
|
||||
var planningMode: PlanningMode = .dateRange
|
||||
var planningMode: PlanningMode = .dateRange {
|
||||
didSet {
|
||||
// Reset state when mode changes to ensure clean UI transitions
|
||||
if oldValue != planningMode {
|
||||
viewState = .editing
|
||||
// Clear mode-specific selections
|
||||
switch planningMode {
|
||||
case .dateRange, .gameFirst:
|
||||
// Clear locations for date-based modes
|
||||
startLocationText = ""
|
||||
endLocationText = ""
|
||||
startLocation = nil
|
||||
endLocation = nil
|
||||
case .locations:
|
||||
// Keep locations (user needs to enter them)
|
||||
break
|
||||
case .followTeam:
|
||||
// Clear locations and must-see games for follow team mode
|
||||
startLocationText = ""
|
||||
endLocationText = ""
|
||||
startLocation = nil
|
||||
endLocation = nil
|
||||
mustSeeGameIds.removeAll()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Form Fields
|
||||
|
||||
@@ -61,7 +87,9 @@ final class TripCreationViewModel {
|
||||
var startDate: Date = Date() {
|
||||
didSet {
|
||||
// Clear cached games when start date changes
|
||||
if !Calendar.current.isDate(startDate, inSameDayAs: oldValue) {
|
||||
// BUT: In gameFirst mode, games are the source of truth for dates,
|
||||
// so don't clear them (fixes "date range required" error)
|
||||
if !Calendar.current.isDate(startDate, inSameDayAs: oldValue) && planningMode != .gameFirst {
|
||||
availableGames = []
|
||||
games = []
|
||||
}
|
||||
@@ -70,7 +98,9 @@ final class TripCreationViewModel {
|
||||
var endDate: Date = Date().addingTimeInterval(86400 * 7) {
|
||||
didSet {
|
||||
// Clear cached games when end date changes
|
||||
if !Calendar.current.isDate(endDate, inSameDayAs: oldValue) {
|
||||
// BUT: In gameFirst mode, games are the source of truth for dates,
|
||||
// so don't clear them (fixes "date range required" error)
|
||||
if !Calendar.current.isDate(endDate, inSameDayAs: oldValue) && planningMode != .gameFirst {
|
||||
availableGames = []
|
||||
games = []
|
||||
}
|
||||
@@ -414,32 +444,8 @@ final class TripCreationViewModel {
|
||||
}
|
||||
|
||||
func switchPlanningMode(_ mode: PlanningMode) {
|
||||
// Just set the mode - didSet observer handles state reset
|
||||
planningMode = mode
|
||||
// Clear mode-specific selections when switching
|
||||
switch mode {
|
||||
case .dateRange:
|
||||
startLocationText = ""
|
||||
endLocationText = ""
|
||||
startLocation = nil
|
||||
endLocation = nil
|
||||
case .gameFirst:
|
||||
// Keep games, clear locations
|
||||
startLocationText = ""
|
||||
endLocationText = ""
|
||||
startLocation = nil
|
||||
endLocation = nil
|
||||
case .locations:
|
||||
// Keep locations, optionally keep selected games
|
||||
break
|
||||
|
||||
case .followTeam:
|
||||
// Clear non-follow-team selections
|
||||
startLocationText = ""
|
||||
endLocationText = ""
|
||||
startLocation = nil
|
||||
endLocation = nil
|
||||
mustSeeGameIds.removeAll()
|
||||
}
|
||||
}
|
||||
|
||||
/// Load games for browsing in game-first mode
|
||||
|
||||
Reference in New Issue
Block a user